Austin Weisgrau
11/20/2024, 7:32 PMNate
11/20/2024, 7:37 PMflow.from_source(..).deploy(..)
is the analogue to Deployment.build_from_flow(...).apply(...)
which creates the deployment on the server
are you saying its harder to delete deployments now? there's a client method delete_deployment
otherwise can you explain whats harder to do now?Nate
11/20/2024, 7:37 PMAustin Weisgrau
11/20/2024, 7:38 PMNate
11/20/2024, 7:38 PMDeployment
was just basically a passthrough to that methodAustin Weisgrau
11/20/2024, 7:39 PMAustin Weisgrau
11/20/2024, 7:43 PMNate
11/20/2024, 7:46 PMtheis the analogue toflow.from_source(..).deploy(..)
Deployment.build_from_flow(...).apply(...)
Deployment
class is coupled to agents, which have been superseded by workers over the last couple years. the kwargs you passed into build_from_flow
can generally be passed to .deploy
(with the exception of infra/storage blocks, which are superseded by work pools and from_source
/ pull steps respectively)Krishnan Chandra
11/20/2024, 7:47 PMRunnerDeployment
object along with the deploy
method. Code example:
`flows.py`:
# Flow code omitted
def create_deployments() -> list[RunnerDeployment]:
foo_deployment = RunnerDeployment.from_entrypoint(
"flows:foo",
name="foo",
)
return [foo_deployment]
`ci_deploy.py`:
from prefect import deploy
from flows import create_deployments
private_deployment_ids = deploy(
*create_deployments(),
work_pool_name=settings.prefect_private_work_pool_name,
image=os.environ["DOCKER_IMAGE"],
build=False,
push=False,
print_next_steps_message=True,
)
<http://logger.info|logger.info>("Private deployments: {}", private_deployment_ids)
It’s a bit rough but I hope it helps to understand the basic ideaAustin Weisgrau
11/20/2024, 7:47 PMAustin Weisgrau
11/20/2024, 7:48 PMKrishnan Chandra
11/20/2024, 7:48 PMci_deploy.py
file which can be run in CIAustin Weisgrau
11/20/2024, 9:07 PMpath
attribute from the local filesystem, and contrary to the documentation it can't be overwritten by passing path
as an initialization variableAustin Weisgrau
11/20/2024, 9:09 PMentrypoint
is correctly specified, the deployment will still try and find the path relative to the absolute path of the filesystem where deployment.apply()
was run, which won't work if the local filesystem is different than the production filesystemNate
11/20/2024, 9:14 PMfrom_source
and .deploy()
and if you really need a class, you could pretty easily make a class that uses these methods under the hood
I wouldn't recommend using RunnerDeployment
directly because if you look at the implementation of from_source
and deploy
you'll see we handle a lot of the cases associated with different storage options there, so you'd be responsible for re-implementing that if you used RunnerDeployment
directly
post-agents, you shouldnt have to set a path
. like these examples show, if you're using the pythonic interface, you set source
to the repo or bucket or whatever you have, and then you set entrypoint
relative to that sourceAustin Weisgrau
11/20/2024, 9:16 PMAustin Weisgrau
11/20/2024, 9:16 PMNate
11/20/2024, 9:19 PMbuild
push
kwargsAustin Weisgrau
11/20/2024, 10:27 PMAustin Weisgrau
11/20/2024, 10:27 PMAustin Weisgrau
11/20/2024, 10:28 PMNate
11/20/2024, 10:29 PMAustin Weisgrau
11/20/2024, 10:31 PMAustin Weisgrau
11/20/2024, 10:31 PMNate
11/20/2024, 10:33 PMfrom_source
and point it at a git repo or bake their source into an image
sounds like all your code is on something like a VM and you have a process worker going there?Austin Weisgrau
11/20/2024, 10:34 PMAustin Weisgrau
11/20/2024, 10:34 PMAustin Weisgrau
11/20/2024, 10:34 PMAustin Weisgrau
11/20/2024, 10:35 PMAustin Weisgrau
11/20/2024, 10:35 PMNate
11/20/2024, 10:51 PMwell it is in an image
but the worker is running in that image (in an AWS ECS service)are you saying your flow code is stored in the same image as the one used to run
prefect worker start
in an ECS service?
but yeah unfortunately that guide is an early 2.x agent / infra blocks setup with a couple conceptual differences from workers and work pools, where i'd refer again to those docs I linked above or the video I linked where I go over how to use from_source
and deploy
Austin Weisgrau
11/20/2024, 10:51 PMAustin Weisgrau
11/20/2024, 10:51 PMAustin Weisgrau
11/20/2024, 10:51 PMAustin Weisgrau
11/20/2024, 10:54 PMAustin Weisgrau
11/20/2024, 10:54 PMNate
11/20/2024, 10:56 PMAustin Weisgrau
11/20/2024, 10:57 PMNate
11/20/2024, 10:58 PMset_working_directory
pull step I showed earlier, either in yaml or by updating the deployment objects pull steps with the client directly
the reason this is not a common pattern is because presumably you have to redeploy your worker every time your code changes, bc the code is in the workers image?Austin Weisgrau
11/20/2024, 10:59 PMAustin Weisgrau
11/20/2024, 11:00 PMAustin Weisgrau
11/20/2024, 11:00 PMAustin Weisgrau
11/20/2024, 11:03 PMNate
11/20/2024, 11:13 PMserve(*[<http://f.to|f.to>_deployment(...) for f in list___of_flows])
is going to effectively do the following
• start a process that listens for scheduled runs of each deployment
• run the flow run is a subprocess when it finds a scheduled run
so exactly the same thing as a process worker, except you don't have to engage with work pools / workers / pull steps etcAustin Weisgrau
11/20/2024, 11:14 PMNate
11/20/2024, 11:15 PMAustin Weisgrau
11/20/2024, 11:17 PMAustin Weisgrau
11/20/2024, 11:18 PMNate
11/20/2024, 11:18 PMNate
11/20/2024, 11:19 PMECS(...).run()
and using the infra block class without using it as a "prefect depoyment"? and just calling that from the flows that spun up as subprocesses of your process workerAustin Weisgrau
11/20/2024, 11:20 PMNate
11/20/2024, 11:21 PMprefect worker running in a long-lived AWS ECS servicedo you know the command that you use to start this process?
Austin Weisgrau
11/20/2024, 11:22 PMNate
11/20/2024, 11:23 PMprefect worker start
requires a work pool -p
, whereas prefect agent start
can be started with only a reference to a queue -q
Austin Weisgrau
11/20/2024, 11:26 PMprefect agent start -q dataflowops
Nate
11/20/2024, 11:31 PMAustin Weisgrau
11/20/2024, 11:34 PMAustin Weisgrau
11/20/2024, 11:35 PMNate
11/21/2024, 12:25 AMDeploymentUpdate
both client and server side to allow that, because right now pull_steps
is not a field on that schemaNate
11/21/2024, 12:26 AMAustin Weisgrau
11/21/2024, 8:25 PMNate
11/21/2024, 8:36 PM• using the Python API for deployments must be replaced with using yaml for deployments, to enable us to modify the pull steps
DeploymentUpdate
can be updated via a simple PR to allow patching pull_steps
, it wouldnt be a hard change
• flow code can't be kept local to the worker, but must be stored remotely and retrieved as part of flow runsin general this is not true, this is what
.serve
is for, where you can always use run_deployment
to trigger work on other infrastructures like ECS