Moxit
02/08/2024, 7:16 PMNate
02/08/2024, 8:19 PMbuild_from_flow
with a prefect.yaml
?
with workers, you should no longer use that or have to worry about a path
for your deployment, only an entrypoint
that you set in your prefect.yaml
that's relative to the root of the place that your code livesMoxit
02/08/2024, 9:00 PMflows/flows/directory/flow_file.py:flow_name
and inside docker it is flows/directory/flow_file.py:flow_name
with a path variable of opt/prefect/flows
.Moxit
02/08/2024, 9:01 PMNate
02/08/2024, 9:03 PMset_working_directory
in your pull
step?Moxit
02/08/2024, 9:04 PMpull:
- prefect.deployments.steps.set_working_directory:
directory: /opt/prefect/flows
I have it set to thisNate
02/08/2024, 9:04 PMMoxit
02/08/2024, 9:04 PMNate
02/08/2024, 9:04 PMMoxit
02/08/2024, 9:06 PMWORKDIR /opt/prefect
COPY flows/flows/ /opt/prefect/flows
COPY flows/poetry.lock ./
COPY tools /opt/tools
COPY flows/pyproject.prod.toml ./
COPY flows/pyproject.dev.toml ./pyproject.toml
RUN poetry install --no-dev && rm -rf $POETRY_CACHE_DIR
# Runtime stage
FROM --platform=linux/amd64 prefecthq/prefect:2.13.0-python3.9
RUN apt-get update && apt-get install -y libpq-dev
# Copying only necessary artifacts from builder stage
COPY --from=builder /opt/prefect /opt/prefect
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
COPY --from=builder /opt/tools /opt/tools
WORKDIR /opt/prefect
I can share this much of where I'm performing the copy of local files to the WORKDIRNate
02/08/2024, 9:08 PMflows/flows
COPY flows/flows/ /opt/prefect/flows
Moxit
02/08/2024, 9:08 PMMoxit
02/08/2024, 9:09 PMflows/flows/directory/directory.py:flow_name
Moxit
02/08/2024, 9:11 PMMoxit
02/08/2024, 9:11 PMprefect.exceptions.ScriptError: Script at 'flows/flows/normalization/normalization.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
> Running set_working_directory step...
Nate
02/08/2024, 9:15 PMentrypoint
set in your prefect.yaml
?
also if its helpful sometimes i like to set little debug pull step like this or ls -la
Moxit
02/08/2024, 9:16 PMdeployments:
- name: test-worker
version: null
tags: []
description: null
schedule: {}
flow_name: null
entrypoint: flows/flows/normalization/normalization.py:normalization_flow
parameters: {}
work_pool:
name: null
work_queue_name: null
job_variables:
image: '{{ build_image.image }}'
Moxit
02/08/2024, 9:16 PMNate
02/08/2024, 9:22 PMWORKDIR /opt/prefect
COPY flows/flows/ /opt/prefect # or just .
instead of
WORKDIR /opt/prefect
COPY flows/flows/ /opt/prefect/flows
but yeah I would wanna log out stuff to double check myselfMoxit
02/08/2024, 9:23 PMNate
02/08/2024, 9:24 PMMoxit
02/08/2024, 9:34 PMCOPY flows/flows/ /opt/prefect/flows/flows
Thanks for the help!Nate
02/08/2024, 9:45 PMNate
02/08/2024, 9:45 PM