<@ULVA73B9P> using prefect 3 how do i set working ...
# ask-marvin
d
@Marvin using prefect 3 how do i set working directory in a prefect deploy call using --job-variable?
m
To set the working directory for your deployment using
--job-variable
with Prefect 3.x, you should define this in your
prefect.yaml
file under the
job_variables
section. This section allows you to specify environment variables or other job-specific configurations that will be applied when deploying your flows. Here's a simplified example of how you could set up your
prefect.yaml
to include a working directory:
Copy code
yaml
deployments:
  - name: demo-deployment
    entrypoint: demo_project/demo_flow.py:some_work
    work_pool:
      name: local
    job_variables:
      env:
        WORKING_DIRECTORY: /path/to/your/working/directory
    schedule: null
In this example,
WORKING_DIRECTORY
is set as an environment variable. You can specify this when running the deployment command, ensuring your working directory is set accordingly:
Copy code
bash
prefect deploy -n demo-deployment
Make sure that the
WORKING_DIRECTORY
environment variable is appropriately used in your code to change the directory, if needed. For more detailed information, you can check the Prefect 3.x documentation on customizing deployments. This approach ensures that your specified working directory is considered during the deployment process.
n
doh, not quite
Copy code
prefect deploy .... -jv working_dir=some/path/etc
d
much gracias human @Nate
n
catjam
d
@Nate I have one more quandry, I have an override issue here.
n
sorry, whats the issue? the pull step you assign to run when the worker grabs your flow run and the working directory you set for your worker are two separate things, but you may want to remove one of the two?
d
i use this scheme to deploy, and its picking up the github workflow runner dir which i think is the problem.
Copy code
- name: Deploy flows
  id: flow-time
  run: |
      pip install --upgrade pip
      pip install prefect
      FLOW_NAME=$(basename ${{ matrix.flows }} .py)
      prefect deploy -n $POOL-base-deployment -t $POOL -p ecs-$POOL-pool -jv working_dir=opt/prefect/prefect ${{ matrix.flows }}:$FLOW_NAME
      echo "flow_manifest=$FLOW_NAME.yaml" >> $GITHUB_ENV
how would I augment that pull step
n
what type of work pool are you using?
d
ecs
n
the pull step is likely coming from your
prefect.yaml
- you might have a
pull
step defined at the top of the file that is globally applying to all deployments defined in that file? if you dont want that, you may want to set
pull: null
for each of the deployments it should not apply to, or remove it entirely and only specify it on deployments you need
d
ill give that a try. i havent pushed any prefect.yaml but ill do so with the null set and see what happens. appreciate it @Nate
g
chefs kiss
n
catjam