hundreds-midnight-75494
02/11/2025, 6:39 PMhundreds-midnight-75494
02/12/2025, 1:45 AMvictorious-lawyer-58417
02/12/2025, 2:09 AMvictorious-lawyer-58417
02/12/2025, 2:09 AMvictorious-lawyer-58417
02/12/2025, 3:46 AMimport os
from multiprocessing import Pool
def latest_run(flow_name):
from metaflow import Flow
return Flow(flow_name).latest_run.pathspec
def call(op, args, profile=None):
os.environ['METAFLOW_PROFILE'] = profile
with Pool(processes=1) as pool:
return pool.apply(op, args)
if __name__ == '__main__':
print(call(latest_run, ('HelloFlow',), profile='local'))
print(call(latest_run, ('HelloFlow',), profile='mozart'))
i.e. if you can implement the operations you need as a function like latest_run
here, then you can call them via call
(or you can craft a fancier abstraction)hundreds-midnight-75494
02/12/2025, 12:17 PMhundreds-midnight-75494
02/13/2025, 5:38 PMvictorious-lawyer-58417
02/14/2025, 8:12 PMvictorious-lawyer-58417
02/14/2025, 8:12 PMhundreds-midnight-75494
02/18/2025, 8:00 PMvictorious-lawyer-58417
02/18/2025, 8:06 PMhundreds-midnight-75494
02/18/2025, 9:28 PMos.environ['METAFLOW_USERNAME'] = hex
to the call function, then I get this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
hex_cell_3f45a3d9-0ae9-4d5a-9e68-dd86735dfe50.py in <module>
13
14 if __name__ == '__main__':
---> 15 print(call(latest_run, ('HelloFlow',), profile='haus_prod'))
hex_cell_3f45a3d9-0ae9-4d5a-9e68-dd86735dfe50.py in call(op, args, profile)
7
8 def call(op, args, profile=None):
----> 9 os.environ['METAFLOW_USERNAME'] = hex
10 os.environ['METAFLOW_PROFILE'] = profile
11 with Pool(processes=1) as pool:
/usr/local/lib/python3.10/os.py in __setitem__(self, key, value)
683 def __setitem__(self, key, value):
684 key = self.encodekey(key)
--> 685 value = self.encodevalue(value)
686 putenv(key, value)
687 self._data[key] = value
/usr/local/lib/python3.10/os.py in encode(value)
755 def encode(value):
756 if not isinstance(value, str):
--> 757 raise TypeError("str expected, not %s" % type(value).__name__)
758 return value.encode(encoding, 'surrogateescape')
759 def decode(value):
TypeError: str expected, not builtin_function_or_method