With Prefect (2) Cloud, how do I use python or the...
# ask-community
j
With Prefect (2) Cloud, how do I use python or the cli to create a deployment that references an existing flow by id? I.e. without referring to the flow code again as
prefect deployment build
seems to want? Specifically I want to create a deployment that uses an existing flow in a particular work pool with the flow parameters given for the deployment similar to a "Custom Run" in the Cloud UI. And of course set the schedule etc.
...the Cloud already knows the flow_id and the storage for fetching the code, so why do I have to provide the code again to make a new deployment?
j
i don't know enough about what you're wanting to do to give a specific answer, but I suspect it's because the deployment has to read the flow to get the parameters (and potentially other information), as these are bundled with the deployment - as far as i can see in the UI the flow doesn't show the parameters, so the CLI would have to read the flow to get these
j
Copy code
prefect deployment build \
		--name deployment-name \
		--pool work-pool \
		--infra process \
		--skip-upload \
		--timezone 'America/New_York' \
		--cron '0 2 * * 1-5' `# 2am mon-fri` \
		--apply `# install this deployment in cloud` \
		`# skip this due to --apply: --output out.yaml` \
		--storage-block 'remote-file-system/code-storage' \
		`# any necessary --param` \
		`# entrypoint:` \
		flow.py:flow_func
@Jessica Smith it seems as if the above command should not need flow.py to exist in the working directory where the command is run, for the following reasons: • skip-upload/storage-block, the code is already in the storage block, which is named • unless I'm misunderstanding something, all the deployment needs to do is tell the worker where to get the code (storage-block) and what to run once it is in hand (entrypoint). So why does flow.py need to be accessible to run this command?
Copy code
# flow.py
from prefect import flow
@flow
# if real func has args
# seems like we can skip them here
def flow_func():
    pass
It seems as if a stub flow.py is enough, so I'm pretty sure the command could be changed to not require it at all