Ben Epstein
01/06/2024, 10:42 PMpull:
- prefect.deployments.steps.git_clone:
repository: <https://my_repo.git>
how does the actual repo get installed? ie into my VMs virtual environment?Nate
01/06/2024, 11:04 PMProcessWorker
? if so, by default the `git clone` will happen in a tmpdir unless you set a working_dir for that Process
work poolBen Epstein
01/06/2024, 11:08 PMin general your pull step will run wherever your worker / serve process is running
seems contradictory to
by default the `git clone` will happen in a tmpdir
So in my VM i ran
prefect worker start --pool "my-pool"
So when the next flow starts, and it does a git pull from my repo, will it end up right in my current working directory? Or will it be in a tmpdir?Ben Epstein
01/06/2024, 11:09 PMBen Epstein
01/06/2024, 11:10 PMNate
01/06/2024, 11:11 PMgit_clone
step will just clone the repo, not necessarily install it as a packageNate
01/06/2024, 11:12 PMpull
step that would run some pip install .
or somethingBen Epstein
01/06/2024, 11:12 PMalthough you could add another action to youroh interesting I didn't see this in the docs, this would be perfect! How would I do that exactly?step that would run somepull
or somethingpip install .
Nate
01/06/2024, 11:14 PMpull:
- prefect.deployments.steps.git_clone:
repository: <https://my_repo.git>
- prefect.deployments.steps.run_shell_script:
script: cd my_repo && pip install .
@Marvin check my workMarvin
01/06/2024, 11:14 PMprefect.deployments.steps.git_clone
and prefect.deployments.steps.run_shell_script
steps work within Prefect deployments:
- `prefect.deployments.steps.git_clone`: This utility step is used to clone a repository from GitHub, Bitbucket, or GitLab as part of a deployment's pull action. You can provide a repository URL and optionally an access token to clone private repositories. The access token can be securely provided using a Secret block.
Example usage:
yaml
pull:
- prefect.deployments.steps.git_clone:
repository: <https://bitbucket.org/org/repo.git>
access_token: "{{ prefect.blocks.secret.bitbucket-token }}"
- `prefect.deployments.steps.run_shell_script`: This utility step allows for the execution of shell commands in a subprocess. It can be used to run scripts that need a specific environment or have particular I/O requirements. The step returns the standard output and standard error of the script being executed.
Looking at your code snippet, it appears you are attempting to use these steps in sequence as part of a pull action:
yaml
pull:
- prefect.deployments.steps.git_clone:
repository: <https://my_repo.git>
- prefect.deployments.steps.run_shell_script:
script: cd my_repo && pip install .
However, there are a few potential issues with the script:
1. In the script line of the run_shell_script
, you've used &&
instead of &&
. In YAML, you shouldn't need to HTML-encode the ampersand.
2. Make sure to replace <https://my_repo.git>
with the actual URL of your Git repository.
With the corrections, it should look like:
yaml
pull:
- prefect.deployments.steps.git_clone:
repository: <https://my_repo.git>
- prefect.deployments.steps.run_shell_script:
script: cd my_repo && pip install .
Make sure that the repository path and the subsequent directory change command (cd
) correspond correctly after cloning the repository. If the repository is cloned into a directory with a different name, you need to adjust the script accordingly.Nate
01/06/2024, 11:15 PMyou've usedlol wutinstead of&&
&&
Nate
01/06/2024, 11:15 PMBen Epstein
01/06/2024, 11:16 PMNate
01/06/2024, 11:17 PMBen Epstein
01/06/2024, 11:18 PMwork_pool:
type: process
name: scraper-pool
work_queue_name: default
working_dir: /path/to/my/dir
Ben Epstein
01/06/2024, 11:30 PM- prefect.deployments.steps.set_working_directory:
directory: /path/to/my/dir
- prefect.deployments.steps.git_clone:
repository: <https://my_repo.git>
Nate
01/06/2024, 11:36 PMjob_variables
on a work pool for a given deployment (without changing the work pool globally for all deployments that pull their config from that work pool) you can do
deployments:
...
work_pool:
type: process
name: scraper-pool
job_variables:
working_dir: /path/to/my/dir
can you say more about why you need to set the work dir? there's a couple valid ways to do this and the one I'd recommend sort of depends on why you need to do itBen Epstein
01/06/2024, 11:37 PMprefect.deployments.steps.git_clone:
was perfectNate
01/06/2024, 11:53 PMpwd
action for a sanity check
> Running git_clone step...
> Running run_shell_script step...
/Users/nate/src/demos/prefect-monorepo/test
my repo got cloned to test/
wrt this repo root according to the working_dir
i set for this deploymentBen Epstein
01/07/2024, 3:46 PMpull:
- prefect.deployments.steps.set_working_directory:
directory: /path/to/my/dir
- prefect.deployments.steps.git_clone:
repository: <https://my_repo.git>
deployments:
- name: bla1
entrypoint: ...
work_pool:
name: my-pool
- name: bla2
entrypoint: ...
work_pool:
name: my-pool
Ben Epstein
01/07/2024, 4:33 PMpip install
code you shared isn't quite right, just wanted to let you know for the future.
When you do the git-clone, you are placed into the repo, so the cd
will fail. It should actually be just this:
pull:
- prefect.deployments.steps.git_clone:
repository: <https://my_repo.git>
- prefect.deployments.steps.run_shell_script:
script: pip install .
Nate
01/07/2024, 4:38 PMI want this to be the case for all my deploymentsyou could instead just set your working_dir on the work pool, since those configs will automatically apply to all deployments, then you don’t need an extra pull action to set the cwd for each deployment
Ben Epstein
01/07/2024, 4:40 PMNate
01/07/2024, 4:45 PMBen Epstein
01/07/2024, 4:45 PMNate
01/07/2024, 4:46 PM