Hello everyone! I am questionning about good pract...
# ask-metaflow
p
Hello everyone! I am questionning about good practices for dealing with namespaces. In a flow PredictFlow, I need to access production runs from an other flow TrainingFlow but I have namespace issues that prevent me from getting it. Would you recommend an approach like in snippet A or redefine my production namespace to create group of consistent Flow under the same namespace like in snippet B ? snippet A
Copy code
from metaflow import Flow, FlowSpec, get_namespace, namespace, step, current


def get_production_runs(flow_id):
    current_namespace = get_namespace()
    namespace(None)
    runs = Flow(flow_id).runs("runtime:step-functions")
    namespace(current_namespace)
    return runs


class PredictFlow(FlowSpec):
    @step
    def start(self):
        training_flow = get_production_runs("TrainingFlow")

    @step
    def end(self):
        pass


if __name__ == "__main__":
    PredictFlow()
snippet B
Copy code
from metaflow import Flow, FlowSpec, namespace, step, get_namespace


class PredictFlow(FlowSpec):

    @step
    def start(self):
        if get_namespace().startwith(f"production:metaflow"):
            namespace('my_namespace')

        training_flow = Flow("TrainingFlow").runs()

    @step
    def end(self):
        pass
My guess is snippet B Thx for any advice! Deployment : AWS step-functions Metaflow : metaflow==2.10.7