https://prefect.io logo
Title
a

Anna Gerlich

02/07/2023, 11:37 AM
Hi All. I'm getting a value error when deploying flows outside of working directory, which is already flagged as an issue https://github.com/PrefectHQ/prefect/issues/6777 created by @Cole Murray. Could you please advise if there is any progress on that? Is there a way to go around this error? 🤔
c

Cole Murray

02/07/2023, 6:11 PM
Hi Anna, I was able to resolve this by overriding the entrypoint parameter as part of the Deployment.build_from_flow call. Below is a code snippet of how it can be used. There’s a few other techniques depending on your use-case, but in general providing an override for the entrypoint is probably what you want.
module, method = module_name.rsplit('.', 1)
        mod = importlib.import_module(module)
        workflow_flow = getattr(mod, method)
        flow_filepath = getattr(mod, "__file__", None)

        print(f"Flow filepath: {flow_filepath}")

        deployment = Deployment.build_from_flow(
            flow=workflow_flow,
            name=schedule.id,
            version=1,
            entrypoint=f"{flow_filepath}:{workflow_flow.fn.__name__}",
            work_queue_name="default",
            parameters={},
            schedule=deployment_schedule,

        )
        deployment.apply()
a

Anna Gerlich

02/08/2023, 2:52 PM
Thank you Cole! It works perfectly well for me. I really appreciate it 🙂
🙌 1