xyzz
04/12/2021, 11:38 AMxyzz
04/12/2021, 11:39 AMAmanda Wee
04/12/2021, 11:42 AMproject_name
should be in the context if you're using prefect cloud or prefect server, but not prefect core.xyzz
04/12/2021, 11:43 AMAmanda Wee
04/12/2021, 11:45 AMAmanda Wee
04/12/2021, 11:46 AMxyzz
04/12/2021, 11:47 AMxyzz
04/12/2021, 11:50 AMxyzz
04/12/2021, 12:14 PM@task()
def get_project_name():
return prefect.context.get("project_name")
xyzz
04/12/2021, 12:15 PMValueError: Must provide a project name.
xyzz
04/12/2021, 12:16 PMIf running with Prefect Core's server as the backend, this should not be provided.
xyzz
04/12/2021, 12:22 PMxyzz
04/12/2021, 12:37 PM@task()
def get_project_meta() -> Tuple[str, bool]:
project_name = prefect.context.get("project_name")
has_project_name = bool(project_name)
return project_name, has_project_name
flow_run = StartFlowRun()
with Flow("my-flow") as flow:
...
project_name, has_project_name = get_project_meta()
with case(has_project_name, True):
flow_run(flow_name='my-flow-check', project_name=project_name)
xyzz
04/12/2021, 12:39 PMZanie
StartFlowRun
task that does this for you e.g.
@task
def start_flow_run_with_prj(flow_name):
project_name = prefect.context.get("project_name")
if not project_name:
return
StartFlowRun(flow_name=flow_name, project_name=project_name).run()
xyzy
04/12/2021, 3:57 PM