Jin
11/01/2023, 7:07 AMfrom prefect.deployments import run_deployment
response = run_deployment(deploy_id)
I'm running the deployment with this code then my agent container will run flow code.
what I need is I have to get the return value of flow after
response = run_deployment(deploy_id)
this code.
is there any genius who will be my lifesaver?Nate
11/01/2023, 2:00 PMresponse.state.result()
should be the return value of that flowJin
11/01/2023, 2:48 PMJin
11/01/2023, 10:27 PMValueError: Path /root/.prefect/storage/0666775b472b4342b56c3448eb86aeac does not exist.
it's really weird because when I run the code without response.state.result()
, it doesn't have any error. is there any pre-stage I have to do before using response.state.result()
?Nate
11/01/2023, 10:38 PMso as long as you’ve persisted resultsah so i would guess you're running this in a container where you don't have an external
result_storage
like (s3, gcs etc) that lives beyond your container. so you're probably persisting results onto the container that is torn down at the end of the run, and the storage dies with it. then when you call response.state.result()
, prefect thinks you're trying to refer to local (on your machine) storage
so i would update your flow that you're triggering like
@flow(..., result_storage=S3.load("my-s3-block") # or gcs)
or you can set
export PREFECT_DEFAULT_RESULT_STORAGE_BLOCK=gcs/my-gcs-block #again, same for s3 or azure
Jin
11/02/2023, 1:34 AMNate
11/02/2023, 3:52 AMJustin Trautmann
11/02/2023, 4:09 PMres = run_deployment(...).state.result()
there would be no use for it anymore immediately after it is retrieved. how could this be cleared? when removing this directly from the cloud storage, this would leave a dead link in the results tab of the flow run but i couldn't find a way to remove a result without removing the flow run.Nate
11/02/2023, 4:13 PMthere would be no use for it anymore immediately after it is retrievedif you use storage keys (
result_storage_key
kwarg on tasks) then you can overwrite the same key to avoid bloat, or if you have more complex clean up then you can do an on_completion
hook on the parent that accesses the result to delete whatever blobs you no longer needJustin Trautmann
11/02/2023, 4:19 PMNate
11/02/2023, 5:03 PM