I've been trying to run prefect based on a custom image. I have a rather complicated image build on ...
p

Paweł Biernat

over 1 year ago
I've been trying to run prefect based on a custom image. I have a rather complicated image build on a separate dockerfile. I wanted to just add prefect on top of that and cobbled up the following Dockerfile
FROM [original-image]

RUN pip install prefect smbprotocol

# I keep the flow definition in the "prefect" directory
COPY prefect prefect

# The image wouldn't work without that
ENV TZ=Etc/UTC
ENV MKL_THREADING_LAYER=GNU
ENV MKL_SERVICE_FORCE_INTEL=1

# Run our flow script when the container starts
CMD ["python", "prefect/flow.py"]
So far I've been testing it in a local docker pool and all was well. I now moved to ACI and am getting entrypoint-related errors:
Error: Failed to start container zuge6yxkhm5gm, Error response: to create containerd task: failed to create shim task: failed to create container 4d9adc93761405465a82af86e363832c0e7a043a584588e48a8ef0bb55faf532: guest RPC failure: failed to create container: failed to run runc create/exec call for container 4d9adc93761405465a82af86e363832c0e7a043a584588e48a8ef0bb55faf532 with exit status 1: container_linux.go:380: starting container process caused: exec: "/opt/prefect/entrypoint.sh": permission denied: unknown
I found that the ACI pool has a default entrypoint
/opt/prefect/entrypoint.sh
, so I cleared the entrypoint field, but no dice, I'm still getting the same error. I also tried to copy the entrypoint from prefect repo into the image (this one: https://github.com/PrefectHQ/prefect/blob/main/scripts/entrypoint.sh) but that still didn't work. Any suggestions? What's the intended way to run prefect based on a custom docker image? I want to avoid altering the original image as it's pretty difficult to build already.
Hi, new to Prefect and Python so apologies if what I’m about to describe is a pathetically trivial/o...
h

Huw Ringer

about 4 years ago
Hi, new to Prefect and Python so apologies if what I’m about to describe is a pathetically trivial/obvious problem. Here’s my environment: 1. Prefect Cloud for orchestration. 2. Azure Kubernetes Prefect Agent (note I don’t have an executor defined in Azure as I’m not sure how to do this yet, or whether I even need to, but it’s important that the entire Flow runs in Azure - ideally on the existing Agent if possible). Have imported KubernetesRun from
prefect.run_configs
in my Flow, and can see the Agent from Prefect Cloud, and was able to run ‘hello world’ successfully via it also. 3. Azure PostgreSQL database I need to run SQL against as part of a Prefect Task (have used a Secret in Prefect Cloud to create a dictionary with all the database login parameters) 4. Private API I need to call as part of a Prefect Task 5. GitHub storage for the whole Flow script (created a GitHub Access Token Secret to enable PrefectCloud to access the registered script) 6. Have run the
prefect backend cloud
CLI command on my local Mac, to hopefully force everything to execute in Azure rather than locally Here’s the journey I’ve been on: 1. I got the basic “hello world” flow executing on a local agent (yay!), with the Flow registered in the Prefect Cloud, and the code being pulled from GitHub 2. I then got it working against the Kubernetes agent, but for some reason the ‘hello world’ message didn’t appear in the logs. Is that because I need to set
prefect.config.cloud.send_flow_run_logs = True
somewhere/how, or something else? 3. Tried importing psycopg2 and creating a connection to the PostgreSQL database to retrieve a very simple count result. Am not sure if I need to be using the PostgresExecute API call (which itself uses Psycopg2) rather than importing psycopg2 into my Flow. Thoughts/recommendations welcome! 4. Also tried importing the requests Python module to call the API. 5. When I try running the script to register the Flow it appears to work (finished with exit code 0), but when I look in my Prefect Cloud Flows tab it’s not there. Any idea why, please? Sorry to bother you all about this, but am kind of at a loss on how to move forwards with this if I can’t even see the Flow I want to execute. Suspect it may be something to do with importing those libraries/modules and them not being available in the Execution environment, but have no idea from what I’ve read so far what I need to do to get that working. Any advice (even RTFM, if you can point me to the right topic) would be gratefully received. Thanks in advance! * UPDATE * Have posted the script to the below thread as requested by @Kevin Kho Huw