我正在研究一个示例 dagster 管道。它应该从 Azurite Blobstorage 中挑选一些数据并将其写回到 Blobstorage 上的另一个文件夹中。
Blobstorage Azurite 也用于本地 MLflow 训练。
当我在本地执行 dagster 脚本时
# in bash
export DAGSTER_HOME="/home/heiko/Repos/dagster_azurite/.dagster"
dagster-daemon run
# in Powershell
Set-Variable -Name "DAGSTER_HOME" -value "./.dagster"
dagit -f repository.py
它工作正常并且管道是绿色的,因此代码按预期运行。dagster 资源被加载,.csv 文件被加载并按预期保存。
但是,当我尝试在 dagster 的 dockerfile 中运行此代码(repositroy.py 文件和依赖项)时,它无法捕获数据。
Docker Compose 文件包含:
docker_example_user_code:
build:
context: .
dockerfile: ./Dockerfile_user_code
container_name: docker_example_user_code
image: docker_example_user_code_image
restart: always
environment:
DAGSTER_POSTGRES_USER: "postgres_user"
DAGSTER_POSTGRES_PASSWORD: "postgres_password"
DAGSTER_POSTGRES_DB: "postgres_db"
DAGSTER_CURRENT_IMAGE: "docker_example_user_code_image"
ports:
- "4000:4000"
networks:
- docker_example_network
- general_nw
“general_nw”是 mlflow docker 容器的网络(见最后的链接)。
用于执行用户代码的 docker 是这样构建的:
# https://docs.dagster.io/deployment/guides/docker
# Dockerfile_user_code
FROM python:3.8-slim
RUN python -m pip install --upgrade pip
RUN pip install poetry
RUN pip install wheel
RUN apt-get update
RUN apt-get install inetutils-ping
RUN mkdir -p /opt/dagster/
RUN mkdir -p /opt/dagster/app
WORKDIR /opt/dagster/app
COPY pyproject.toml poetry.toml poetry.lock /opt/dagster/app/
RUN poetry install
# Set $DAGSTER_HOME and copy dagster instance there
ENV PATH=/opt/dagster/app/.venv/bin:$PATH
ENV DAGSTER_HOME=/opt/dagster/app/dagster_home
RUN mkdir -p $DAGSTER_HOME
COPY dagster.yaml $DAGSTER_HOME
RUN mkdir -p /opt/dagster/app/dagster_home
COPY dagster.yaml /opt/dagster/app/dagster_home
# Add repository code
WORKDIR /opt/dagster/app
COPY repo.py /opt/dagster/app
COPY repository.py /opt/dagster/app
COPY data_pipeline/ /opt/dagster/app/data_pipeline
COPY sampledata /opt/dagster/app/sampledata
# Run dagster gRPC server on port 4000
EXPOSE 4000
# Using CMD rather than ENTRYPOINT allows the command to be overridden in
# run launchers or executors to run other commands using this image
CMD ["dagster", "api", "grpc", "-h", "0.0.0.0", "-p", "4000", "-f", "repository.py"]
当我从 docker_example_user_code 容器 ping azurite blobcontainer 时,我得到了响应。
# works
docker exec -it blob ping docker_example_user_code
# result
PING docker_example_user_code (172.21.0.4): 56 data bytes
64 bytes from 172.21.0.4: seq=0 ttl=64 time=0.116 ms
docker exec -it docker_example_user_code ping blob
# result
PING blob (172.21.0.3): 56 data bytes
64 bytes from 172.21.0.3: icmp_seq=0 ttl=64 time=0.049 ms
所以我假设容器设置正确并且可以访问 azurite docker 容器。
我不想在此处添加整个代码,因为它在此azurite_dagster_pipeline链接下可用,并且您可以在此处找到带有其 azurite blobcontainer 的 local_mlflow 设置。
目前,这不是更大的 dagster 管道/教程的不工作基础。
我想我错过了在 docker-compose 或容器本身中设置变量。如果有人有一个想法或解决方案来修复 docker 环境中不工作的 dagster 管道,这将非常有帮助。
我希望你有所有的信息来提供一个解决方案。或建议。非常感谢您提前。