Ben Epstein
02/05/2025, 9:27 PMNate
02/05/2025, 9:32 PMprefect.yaml
i'd guess something like this is what you want
https://github.com/zzstoatzz/prefect-pack/blob/477484d91c77309a942b5ed9b7109ef48731f6df/prefect.yaml#L59-L61
which shouldn't require you to cd into the cloned repo
note that my entrypoint is relative to the root of the repo being clonedBen Epstein
02/05/2025, 9:35 PMprefect deploy
to fail.
My repo is setup like
repo
|_ project
|_ _ Makefile
|_ _ prefect.yaml
|_ _ flows
|_ _ _ my_flow.py
and so in my prefect.yaml i have my deployment as
entrypoint: flows/my_flow.py:main
but then when its cloned, it needs to be project/flows/my_flow.py:main
Ben Epstein
02/05/2025, 9:36 PMprefect deploy
-- which means that unless im always calling prefect deploy from the root of my directory, this doesn't workBen Epstein
02/05/2025, 9:42 PMentrypoint
be a python module
flows.my_flow.main
which would not require this path routingNate
02/05/2025, 9:48 PMยป prefect --no-prompt deploy --prefect-file flows/nested_project/prefect.yaml
ยป prefect deployment run 'some-flow/nested-project-flow'
ยป prefect worker start --pool 'local' # not required in your case
and since my entrypoint
is still relative to the root of the repo (where I'm running the command from), this works as expected
> i think a more scalable option could be to let entrypoint
be a python module
this might be possible, feel free to flesh out the idea in an issue!Ben Epstein
02/05/2025, 9:52 PMworking_directory
now? I would definitely prefer not to restructure my entire project just to fit this parameter of where files exist for a prefect deployment.
Is there no way currently to achieve what i'm trying to do?Nate
02/05/2025, 9:54 PMentrypoint
as a path that's relative to the root of the repo you're cloning
โข run prefect deploy
from the root of that repo, using --prefect-file
to point at the right yamlBen Epstein
02/05/2025, 9:56 PMcd .. && prefect deploy
I could definitely create a makefile at the root just for prefect, it just feels a little silly to have it just for prefect.
But i'll do one of those if there's no way to work around this with the working_directory
stepBen Epstein
02/05/2025, 9:59 PMdeploy-prefect:
(cd .. && uv run prefect deploy --all --prefect-file ./project-1/src/flows/prefect.yaml)
and i'll open an issue with my thoughts on being able to provide a module. thanks!Ben Epstein
02/05/2025, 10:06 PMNate
02/05/2025, 10:08 PMmake deploy-prefect
which necessitates running prefect deploy
from the nested folder, and np - thanks for explaining!Ben Epstein
02/05/2025, 10:11 PMprefect.exceptions.ScriptError: Script at 'copilot/src/flows/auto_respond.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
even though the deploy does work from the rootBen Epstein
02/05/2025, 11:09 PMNate
02/05/2025, 11:10 PMBen Epstein
02/06/2025, 5:29 PMNate
02/06/2025, 5:53 PMBen Epstein
02/06/2025, 6:11 PMTrey Gilliland
02/06/2025, 6:49 PMBianca Hoch
02/06/2025, 6:53 PMBen Epstein
02/06/2025, 7:00 PMTrey Gilliland
02/06/2025, 7:55 PMBen Epstein
02/06/2025, 7:58 PMcredentials: '{{ prefect.blocks.github-credentials.prefect-modal }}'
โข You put the PAT into the block in the perfect dashboard UI?Ben Epstein
02/06/2025, 8:00 PMTrey Gilliland
02/06/2025, 8:01 PMBen Epstein
02/06/2025, 8:02 PMBen Epstein
02/06/2025, 8:04 PMTrey Gilliland
02/06/2025, 8:08 PM# pull section allows you to provide instructions for cloning this project in remote locations
pull:
- prefect.deployments.steps.git_clone:
id: clone-step
repository: "<https://github.com/MyOrg/my-repo.git>"
branch: feat/prefect/init
credentials: "{{ prefect.blocks.github-credentials.trey-gh-auth-token }}"
- prefect.deployments.steps.run_shell_script:
directory: "{{ clone-step.directory }}/services/prefect_cloud"
script: make setup
- prefect.deployments.steps.set_working_directory:
directory: "{{ clone-step.directory }}/services/prefect_cloud"
FileNotFoundError: [Errno 2] No such file or directory: 'my-repo-feat/prefect/init/services/prefect_cloud'
So parsing the branch as a directory path maybe? How is clone-step.directory set?Trey Gilliland
02/06/2025, 8:11 PMBen Epstein
02/06/2025, 8:23 PMBen Epstein
02/06/2025, 8:24 PM{{ clone-step.directory }}
the value of this is the repo name with the branchTrey Gilliland
02/06/2025, 8:24 PMTrey Gilliland
02/06/2025, 8:24 PMBen Epstein
02/06/2025, 8:25 PM"{{ clone-step.directory }}/services/prefect_cloud"
Trey Gilliland
02/06/2025, 8:28 PMBen Epstein
02/06/2025, 8:28 PMrepository: "<https://github.com/MyOrg/my-repo.git>"
branch: feat/prefect/init
it will
git clone <https://github.com/MyOrg/my-repo.git> && git checkout feat/prefect/init
and it will place you in the root of the repoTrey Gilliland
02/06/2025, 8:28 PMBen Epstein
02/06/2025, 8:28 PMmy-repo-main
Ben Epstein
02/06/2025, 8:29 PMpwd
will map to the root of your repo, then you move to ./services/prefect_cloud
-- dos that make sense?
this is what had me messed up for like 2 hours yesterday ๐Ben Epstein
02/06/2025, 8:30 PMTrey Gilliland
02/06/2025, 8:31 PMgit clone
the repository, it isn't going to include that branch in the pathBen Epstein
02/06/2025, 8:31 PMBen Epstein
02/06/2025, 8:34 PMTrey Gilliland
02/06/2025, 8:34 PMTrey Gilliland
02/06/2025, 8:53 PMTrey Gilliland
02/06/2025, 8:53 PMmake setup
directiveBen Epstein
02/06/2025, 8:54 PMTrey Gilliland
02/06/2025, 8:55 PMBen Epstein
02/06/2025, 8:56 PMpip install --upgrade 'uv>=0.5.6,<0.6'
Ben Epstein
02/06/2025, 8:56 PMBen Epstein
02/06/2025, 8:56 PMBen Epstein
02/06/2025, 8:56 PMTrey Gilliland
02/06/2025, 9:08 PMBen Epstein
02/06/2025, 9:10 PMBen Epstein
02/07/2025, 12:45 AMuv sync
in my setup, but that's creating a new virtual env which is different from the one prefect is using when it begins to process the flow. I'm struggling how to tell prefect to use my venv python as the one to execute. Because now i'm just getting ModuleNotFound issues
prefect.exceptions.ScriptError: Script at 'src/flows/auto_respond.py' encountered an exception: ModuleNotFoundError("No module named 'app'")
Nate
02/07/2025, 12:49 AMgit_clone
step, not the run_shell_script
hack (that only works for a process pool running started from the same venv) to install some deps at runtimeBen Epstein
02/07/2025, 12:52 AMuv.lock
file that I need to get into whatever the python executable isNate
02/07/2025, 12:52 AMEXTRA_PIP_PACKAGES='pandas whatever git+{your repo}'
which would use uv (in the prefect base image) to install deps at runtime
building an image
and sticking that on your work pool is the normal pattern for containerized work pool types thoBen Epstein
02/07/2025, 12:54 AMprefect.yaml
file? I assume it's in the build
?Ben Epstein
02/07/2025, 1:01 AMEXTRA_PIP_PACKAGES
in the docs? I see mentions of it but no actual usageNate
02/07/2025, 1:04 AMdeployments:
...
work_pool:
name: your-work-pool
job_variables:
env:
EXTRA_PIP_PACKAGES: pandas whatever
for contextBen Epstein
02/07/2025, 1:06 AMNate
02/07/2025, 1:06 AMBen Epstein
02/07/2025, 1:06 AMBen Epstein
02/07/2025, 1:15 AMFeb 06 20:13:21.558
=> Step 3: ENV EXTRA_PIP_PACKAGES='git+<https://github.com/>
it's not actually running anything, and i see the same error. I'll try out the docker flow tomorrowBen Epstein
02/07/2025, 2:16 AM- prefect.deployments.steps.run_shell_script:
directory: '{{ clone-step.directory }}'
script: |
pip install --upgrade 'uv>=0.5.6,<0.6'
/bin/sh -c "uv export --no-dev --no-editable --no-hashes --locked > requirements.txt"
- prefect.deployments.steps.pip_install_requirements:
directory: '/{{ clone-step.directory }}'
requirements_file: requirements.txt
to work, weird to me that it doesn't. It finds my package app
but i get a moduleNotFound app.baml_client
which is one of the subdirectories in my app...