plain-barista-93517
09/05/2024, 4:51 PMNBRunner
but in a my_parent_flow.py setting
params = {"alpha": 1, "beta": True}
run = NBRunner(MyFlow).nbrun(**params)
I tried to do it in the init method of my child flow like this
class ChildFlow1(FlowSpec):
def __init__(self, parameters):
self.alpha = Parameter(
"alpha",
help="Alpha parameter for ChildFlow1",
default=parameters.get("alpha", 1.0),
)
self.beta = Parameter(
"beta",
help="Beta parameter for ChildFlow1",
default=parameters.get("beta", "default"),
)
@step
def start(self):
self.result = f"Result from ChildFlow1: alpha={self.alpha}, beta={self.beta}"
self.next(self.end)
@step
def end(self):
print(
f"ChildFlow1 completed with parameters: alpha={self.alpha}, beta={self.beta}"
)
Then I run the child flow from my parent flow like this:
child1_run = ChildFlow1(parameters={"alpha": 2.5, "beta": "custom"})
child1_run.run()
self.child1_result = child1_run.result
However, I'm seeing a cryptic RecursionError: maximum recursion depth exceeded error. Any pointers in the right direection?ancient-application-36103
09/05/2024, 4:54 PMclass ChildFlow1(FlowSpec):
alpha = Parameter(
"alpha",
help="Alpha parameter for ChildFlow1",
default=1.0,
)
beta = Parameter(
"beta",
help="Beta parameter for ChildFlow1",
default="default",
)
@step
def start(self):
self.result = f"Result from ChildFlow1: alpha={self.alpha}, beta={self.beta}"
self.next(self.end)
@step
def end(self):
print(
f"ChildFlow1 completed with parameters: alpha={self.alpha}, beta={self.beta}"
)dry-beach-38304
09/05/2024, 4:55 PMself.alpha = Parameter but jsut alpha = Parameter (same for beta)dry-beach-38304
09/05/2024, 4:55 PMancient-application-36103
09/05/2024, 4:58 PMplain-barista-93517
09/05/2024, 5:02 PMplain-barista-93517
09/05/2024, 5:06 PMclass ParentFlow(FlowSpec):
@step
def start(self):
self.next(self.run_child_flows)
@step
def run_child_flows(self):
namespace("default")
# Execute ChildFlow1 with custom parameters
child1_run = ChildFlow1()
child1_run.run()
self.child1_result = child1_run.result
self.next(self.end)
@step
def end(self):
print(
f"Results:\nChildFlow1: {self.child1_result}"
)
2024-09-05 17:01:23.833 Workflow starting (run-id 32):
2024-09-05 17:01:24.521 [32/start/1465 (pid 1297796)] Task is starting.
2024-09-05 17:01:25.795 [32/start/1465 (pid 1297796)] Task finished successfully.
2024-09-05 17:01:25.957 [32/run_child_flows/1466 (pid 1297819)] Task is starting.
2024-09-05 17:01:26.661 [32/run_child_flows/1466 (pid 1297819)] Invalid command:
2024-09-05 17:01:26.661 [32/run_child_flows/1466 (pid 1297819)] Step run_child_flows doesn't exist.
2024-09-05 17:01:27.037 [32/run_child_flows/1466 (pid 1297819)]
2024-09-05 17:01:27.079 [32/run_child_flows/1466 (pid 1297819)] Task failed.
2024-09-05 17:01:27.206 Workflow failed.
2024-09-05 17:01:27.206 Terminating 0 active tasks...
2024-09-05 17:01:27.206 Flushing logs...ancient-application-36103
09/05/2024, 5:10 PM# Execute ChildFlow1 with custom parameters
child1_run = ChildFlow1()
child1_run.run()
you would need to use the NBRunner or the Runner APIplain-barista-93517
09/05/2024, 5:14 PMchild1_run = NBRunner(ChildFlow1)
child1_run.nbrun()
metaflow.runner.nbrun.NBRunnerInitializationError: 'NBRunner' requires an interactive Python environment (such as Jupyter)plain-barista-93517
09/05/2024, 5:15 PMbrainy-truck-72938
09/05/2024, 5:16 PMbrainy-truck-72938
09/05/2024, 5:16 PMbrainy-truck-72938
09/05/2024, 5:23 PMbrainy-truck-72938
09/05/2024, 5:24 PMbrainy-truck-72938
09/05/2024, 5:26 PMchild_runner = Runner("./child_flow.py").run(alpha=2, beta="pavan")plain-barista-93517
09/05/2024, 5:33 PMpython parent_flow.py run --with kubernetes:image=custom_image
will the child flows be in the same environment as the parent?brainy-truck-72938
09/05/2024, 5:37 PM--with kubernetes as well
this can be done with decospecs I guess, see the example which has
Runner("myflow.py", decospecs=["kubernetes:gpu=4"])
https://outerbounds.com/blog/metaflow-in-notebooks-and-scripts/#the-new-runner-apibrainy-truck-72938
09/05/2024, 5:41 PMplain-barista-93517
09/05/2024, 5:41 PMdecospecs) results in a successful run of the parent flow within the same kuberenetes podbrainy-truck-72938
09/05/2024, 5:42 PMbrainy-truck-72938
09/05/2024, 5:42 PMbrainy-truck-72938
09/05/2024, 5:42 PMplain-barista-93517
09/05/2024, 5:42 PM