haf
10/19/2021, 2:56 PMKevin Kho
haf
10/19/2021, 2:59 PMhaf
10/19/2021, 2:59 PMStep 26/26 : RUN python /opt/prefect/healthcheck.py '["/opt/prefect/flows/dbt-data-pipelines.prefect", "/opt/prefect/flows/exchange-rates.prefect", "/opt/prefect/flows/nightly-mmm.prefect"]' '(3, 8)'
---> Running in 9613f643e8e1
/opt/prefect/healthcheck.py:152: UserWarning: Flow uses module which is not importable. Refer to documentation on how to import custom modules <https://docs.prefect.io/api/latest/storage.html#docker>
flows = cloudpickle_deserialization_check(flow_file_paths)
Traceback (most recent call last):
File "/opt/prefect/healthcheck.py", line 152, in <module>
flows = cloudpickle_deserialization_check(flow_file_paths)
File "/opt/prefect/healthcheck.py", line 44, in cloudpickle_deserialization_check
flows.append(cloudpickle.loads(flow_bytes))
ModuleNotFoundError: No module named 'mmm.model'
Kevin Kho
haf
10/19/2021, 3:00 PMhaf
10/19/2021, 3:00 PMhaf
10/19/2021, 3:01 PMhaf
10/19/2021, 3:01 PMprefect_utils
I use to construct tasks?haf
10/19/2021, 3:01 PMhaf
10/19/2021, 3:02 PMOtherwise the modules can be set independently when using a custom base image prior to the build here.
haf
10/19/2021, 3:02 PMhaf
10/19/2021, 3:02 PMhaf
10/19/2021, 3:02 PMKevin Kho
Kevin Kho
haf
10/19/2021, 3:07 PMcd infer/prefect_utils && pip install -e .
cd ../..
pipenv install
dockerfile:
FROM prefecthq/prefect:0.15.4-python3.8
RUN pip install --upgrade pip setuptools wheel twine \
&& pip install pipenv \
&& apt-get update \
&& apt-get install -y --no-install-recommends curl gcc python3-dev libssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/prefect
COPY Pipfile* packages.yml profiles.yml .user.yml .python-version dbt_project.yml postinstall.py ./
COPY infer ./infer
COPY dbt ./dbt
# <https://docs.pipenv.org/en/latest/advanced.html#managing-system-dependencies>
# or else /opt/prefect/healthcheck.py:152: UserWarning: Flow uses module which is not importable.
# Refer to documentation on how to import custom modules
# <https://docs.prefect.io/api/latest/storage.html#docker>
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
ENV PATH="/opt/prefect/.venv/bin:$PATH"
RUN python postinstall.py
COPY flows /opt/prefect/flows
Kevin Kho
docker build
yourself. And then on the Flow side, just use DockerRun
with that image you build. Do you want the flow inside that image or outside like S3 or Github?haf
10/20/2021, 6:05 AMKevin Kho
haf
10/20/2021, 6:09 AMflows = sorted(Path("flows").glob("*.py"))
# Add flows
for file in flows:
flow = extract_flow_from_file(file_path=file)
<http://logger.info|logger.info>("Extracted flow from file before build")
docker.add_flow(flow)
haf
10/20/2021, 6:09 AMhaf
10/20/2021, 6:09 AMhaf
10/20/2021, 6:09 AMhaf
10/20/2021, 6:10 AMKevin Kho
Local Storage
with DockerRun
and provide a path to the file.haf
10/20/2021, 6:12 AMflow = extract_flow_from_file(file_path=file)
otherwise I can't assign the storage to the flow, right?haf
10/20/2021, 6:12 AMhaf
10/20/2021, 6:12 AMKevin Kho
Local Storage
with KubernetesRun
and if the image is already created and the flow is already inside, you just point your storage like `Local(path=...,, stored_as_script=True)`and then the flow will be relative to the image.Kevin Kho
haf
10/20/2021, 6:13 AMKevin Kho
Kevin Kho
haf
10/20/2021, 6:15 AMhaf
10/20/2021, 6:16 AMhaf
10/20/2021, 6:17 AMKevin Kho
haf
10/20/2021, 6:18 AMhaf
10/20/2021, 6:18 AMhaf
10/20/2021, 6:19 AMhaf
10/20/2021, 6:19 AMhaf
10/20/2021, 6:20 AMhaf
10/20/2021, 6:20 AMKevin Kho
haf
10/20/2021, 6:21 AMhaf
10/20/2021, 6:22 AMKevin Kho
Kevin Kho
haf
10/20/2021, 6:25 AMhaf
10/20/2021, 6:25 AMKevin Kho
haf
10/20/2021, 6:25 AMhaf
10/20/2021, 6:25 AMhaf
10/20/2021, 6:25 AMKevin Kho
Kevin Kho
haf
10/20/2021, 6:27 AMhaf
10/20/2021, 6:27 AMhaf
10/20/2021, 6:27 AMKevin Kho
haf
10/20/2021, 6:28 AMhaf
10/20/2021, 6:28 AMKevin Kho
haf
10/20/2021, 6:29 AMhaf
10/20/2021, 6:29 AMKevin Kho
haf
10/20/2021, 6:29 AMhaf
10/20/2021, 6:48 AMrun_config=DockerRun(image="europe-docker.pkg.dev/ex/cd/data-pipelines:latest"),
I never want to run the latest container; I always want to set a very specific versionhaf
10/20/2021, 6:48 AM