billowy-exabyte-36648
06/04/2024, 12:44 PMmetaflow.Runner
thing to note: there is some global state set when running a flow that isn't cleaned, in my case again with flow decorators. I have two flows with different class names in flow1.py
and flow2.py
that each use @project(name="myproject")
.
This crashes with `metaflow.decorators.DuplicateFlowDecoratorException: Flow already has a decorator 'project'. You can specify each decorator only once."`:
with metaflow.Runner("flow1.py").run() as running:
assert running.run.successful
with metaflow.Runner("flow2.py").run() as running:
assert running.run.successful
Any idea how to work around this?billowy-exabyte-36648
06/04/2024, 12:45 PMTraceback (most recent call last):
File "/Users/max.friedrich/c/metaflow-212-test/test.py", line 6, in <module>
with metaflow.Runner("flow2.py").run() as running:
File "/Users/max.friedrich/Library/Caches/pypoetry/virtualenvs/metaflow-212-test-CfFDw3qu-py3.10/lib/python3.10/site-packages/metaflow/runner/metaflow_runner.py", line 268, in init
self.api = MetaflowAPI.from_cli(self.flow_file, start)
File "/Users/max.friedrich/Library/Caches/pypoetry/virtualenvs/metaflow-212-test-CfFDw3qu-py3.10/lib/python3.10/site-packages/metaflow/runner/click_api.py", line 183, in from_cli
flow_parameters = extract_flowspec_params(flow_file)
File "/Users/max.friedrich/Library/Caches/pypoetry/virtualenvs/metaflow-212-test-CfFDw3qu-py3.10/lib/python3.10/site-packages/metaflow/runner/click_api.py", line 151, in extract_flowspec_params
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/max.friedrich/c/metaflow-212-test/flow2.py", line 5, in <module>
class TestFlow2(FlowSpec):
File "/Users/max.friedrich/Library/Caches/pypoetry/virtualenvs/metaflow-212-test-CfFDw3qu-py3.10/lib/python3.10/site-packages/metaflow/decorators.py", line 416, in wrap
return _base_flow_decorator(decofunc, f, **kwargs)
File "/Users/max.friedrich/Library/Caches/pypoetry/virtualenvs/metaflow-212-test-CfFDw3qu-py3.10/lib/python3.10/site-packages/metaflow/decorators.py", line 404, in _base_flow_decorator
raise DuplicateFlowDecoratorException(decofunc.name)
metaflow.decorators.DuplicateFlowDecoratorException: Flow already has a decorator 'project'. You can specify each decorator only once.
billowy-exabyte-36648
06/04/2024, 12:45 PMextract_flowspec_params
billowy-exabyte-36648
06/04/2024, 12:47 PMpython flow1.py ...
in a subprocess without checking which parameters the flow has, so I never had to run the flow file in the main test processancient-application-36103
06/04/2024, 3:01 PMbrainy-truck-72938
06/05/2024, 2:49 PMbillowy-exabyte-36648
06/06/2024, 7:26 AMFlowSpec._flow_decorators = {}
between tests anymore 😄