<@ULVA73B9P> does `Deployment.build_from_flow` han...
# ask-marvin
s
@Marvin does
Deployment.build_from_flow
handle pushing and pulling flow code to remote storage like an S3Bucket storage block whereas
Flow.from_source().deploy()
will only pull flow code from remote storage?
m
It looks like both methods offer distinct functionalities regarding managing flow code in remote storage: * Deployment.build_from_flow: - This method does handle the pushing of flow code to remote storage, ensuring that the code is uploaded to a specified location (like an S3 bucket) during deployment. - There's evidence from GitHub issues that when using
Deployment.build_from_flow
, the current working directory is uploaded to the remote storage, which includes all relevant files unless specified otherwise. * Flow.from_source().deploy(): - This method appears to pull flow code from remote storage but does not inherently push or upload the flow code to remote storage during deployment. - It seems optimized for running flows that have been defined and are stored in a remote repository, where it pulls the necessary code to run the flow. For more information, check out: - Official documentation on Prefect Deployments: Prefect Deploy Documentation - GitHub issue detailing remote storage behavior for `Deployment.build_from_flow`: GitHub Issue #13140 - GitHub discussions on `Flow.from_source().deploy()`: GitHub Issue #11546 If you need to ensure both uploading and pulling of flow code in a seamless manner, Deployment.build_from_flow seems to be the more robust choice.
e
What's the ideal solution now that the past one will be deprecated?
@Marvin
s
Hi @Eric Ramirez, it is
Flow.from_source().deploy()
. One thing to note is that
Deployment.build_from_flow
would upload flow code to S3 (in our case) and download the flow code as well.
Flow.from_source().deploy()
will download your flow code from storage but not upload. Originally we were using the S3 block and tried the S3 bucket block, however, we had issues so we ended up writing our own logic to upload our flow code to S3.
This is for work pools and workers
e
Thanks Scott! And I guess you upload it before deploying the flow?
s
Yes, that is correct
e
Would it be possible to share your code?
s
Copy code
flow_instance = Flow.from_source(
    source=s3_bucket_name,
    entrypoint="path/to/flow/my_flow_code.py:flow")
e
How are you uploading it to S3?
e
Understood
Thank you, Scott. Have a nice day/good night
thank you 1
s
You too 😄