Daniel Leicht
07/09/2025, 9:28 AMsync_minio_to_bronze.deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
image="myrepo/bullzai:latest",
build=False,
push=False,
)
Marvin
07/09/2025, 9:28 AMMarvin
07/09/2025, 9:29 AMpath
parameter in your deployment to specify where the flow file lives inside the image. The path should be relative to the working directory in your container.
Here's how you'd modify your deployment:
python
sync_minio_to_bronze.deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
image="myrepo/bullzai:latest",
path="/path/to/your/flow.py", # Add this line
build=False,
push=False,
)
A few important notes:
1. The path
parameter tells Prefect where to find the flow file inside the container
2. This path should match where your flow file ends up in your Dockerfile
3. If your flow file is at the root of your container's working directory, you can simply use the filename: path="flow.py"
For example, if your Dockerfile copies the flow file to /app/flows/sync_minio.py
, you'd set:
python
path="/app/flows/sync_minio.py"
Remember that this path needs to be accessible within the container at runtime, not on your local machine. If you're getting "flow not found" errors, double-check that the path matches your container's file structure.
Let me know if you need help with the Dockerfile setup to ensure your flow file lands in the right spot.Daniel Leicht
07/09/2025, 9:33 AMMarvin
07/09/2025, 9:33 AMMarvin
07/09/2025, 9:33 AMentrypoint
, not path
. Here's your corrected deployment:
python
sync_minio_to_bronze.deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
image="myrepo/bullzai:latest",
entrypoint="/path/to/your/flow.py", # This is the correct parameter
build=False,
push=False,
)
The entrypoint
parameter serves the same purpose - it tells Prefect where to find your flow file inside the container. The same rules apply:
1. The path should be relative to the working directory in your container
2. For a flow file at the root of your container's working directory, use just the filename: entrypoint="flow.py"
3. Match the path to where your Dockerfile places the file, e.g., entrypoint="/app/flows/sync_minio.py"
Terribly sorry about the confusion. Even a brain the size of a planet occasionally needs to keep up with parameter name changes.Daniel Leicht
07/09/2025, 9:34 AMMarvin
07/09/2025, 9:34 AMMarvin
07/09/2025, 9:35 AMfrom_source()
call, not in the deploy()
method. Here's the correct approach:
python
from prefect import flow
from prefect.deployments import Deployment
deployment = flow.from_source(
source="docker-container/myrepo/bullzai:latest",
entrypoint="path/to/your/flow.py:sync_minio_to_bronze"
).deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
build=False,
push=False,
)
The key points:
1. The flow location is specified in the entrypoint
parameter of from_source()
2. The format is "path/to/file.py:flow_name"
3. The path should be relative to the working directory in your container
If your flow is the only one in the file and has the same name as the file, you can omit the :flow_name
part.
This is infinitely more sensible than my previous suggestions, which were about as useful as a chocolate teapot. Let me know if you need help adjusting your deployment code to this format.Daniel Leicht
07/09/2025, 9:38 AMsync_minio_to_bronze.from_source(
source="docker-container/danielleicht/bullzai:latest",
entrypoint="/app/flow.py:sync_minio_to_bronze"
).deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
image="danielleicht/bullzai:latest",
entrypoint="/app/bronze.py",
build=False,
push=False,
)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\app\\flow.py'Marvin
07/09/2025, 9:38 AMMarvin
07/09/2025, 9:38 AMentrypoint
specified in both from_source()
and deploy()
, which is causing confusion.
Let's fix this. For a container-based deployment, you should use this format:
python
sync_minio_to_bronze.from_source(
source=f"docker-image/danielleicht/bullzai:latest", # Note: "docker-image", not "docker-container"
entrypoint="/app/bronze.py:sync_minio_to_bronze"
).deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
build=False,
push=False
)
Key changes:
1. Changed docker-container
to docker-image
in the source
2. Removed the duplicate entrypoint
and image
parameters from deploy()
3. Used the correct path to your flow file (/app/bronze.py
based on your last attempt)
The source
parameter with docker-image/
prefix tells Prefect to look for the flow file inside the container rather than on your local filesystem.
If you're still getting the error, double-check that:
1. The path /app/bronze.py
matches exactly where your flow file is located inside the container
2. The flow function name sync_minio_to_bronze
matches the actual flow name in your codeDaniel Leicht
07/09/2025, 9:39 AMsync_minio_to_bronze.from_source(
source=f"docker-image/danielleicht/bullzai:latest", # Note: "docker-image", not "docker-container"
entrypoint="/app/bronze.py:sync_minio_to_bronze"
).deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
build=False,
push=False
)
Still shows:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\app\\bronze.py'Marvin
07/09/2025, 9:39 AMMarvin
07/09/2025, 9:41 AMpython
sync_minio_to_bronze.deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
image="danielleicht/bullzai:latest",
job_configuration={
"file_path": "/app/bronze.py"
},
build=False,
push=False
)
The key changes:
1. Remove the from_source()
call entirely
2. Specify the image directly in the deploy()
method
3. Use job_configuration
to specify the file path inside the container
If this still doesn't work, there's one alternative approach:
python
from prefect.deployments import Deployment
Deployment.build_from_flow(
flow=sync_minio_to_bronze,
name="minio-to-bronze",
work_pool_name="K8s Pool",
image="danielleicht/bullzai:latest",
path="/app/bronze.py",
build=False,
push=False
)
Let me know if you're still encountering issues, and we can try a different approach. Also, it would be helpful to know:
1. Is the flow file definitely at /app/bronze.py
in your container?
2. What does your Dockerfile look like?
This might help us pinpoint the exact issue.Daniel Leicht
07/09/2025, 9:44 AMprefect.deployments:Deployment
has been removed. Use flow.serve()
, flow.deploy()
, or prefect deploy
instead.Marvin
07/09/2025, 9:44 AMMarvin
07/09/2025, 9:45 AMpython
sync_minio_to_bronze.deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
image="danielleicht/bullzai:latest",
build=False,
push=False
)
And then in your Dockerfile, make sure you have something like:
dockerfile
COPY bronze.py /app/bronze.py
WORKDIR /app
If you're still getting the file not found error, we might need to:
1. Verify the actual location of the flow file in your container (you can do this by running docker run -it danielleicht/bullzai:latest ls /app
)
2. Make sure your K8s work pool is configured correctly for Docker infrastructure
Would you mind sharing:
1. The contents of your Dockerfile?
2. The output of docker run -it danielleicht/bullzai:latest ls /app
?
This will help us ensure the file is actually where we expect it to be in the container.Daniel Leicht
07/09/2025, 9:46 AMFROM python:3.12-slim
RUN mkdir -p /app
WORKDIR /app
COPY requirements.txt /app
RUN pip install -r /app/requirements.txt
COPY flows/ /app/
2. docker run -it danielleicht/bullzai:latest ls /app
bronze.py requirements.txtMarvin
07/09/2025, 9:47 AMMarvin
07/09/2025, 9:47 AM/app/bronze.py
in your container.
The issue is that Prefect is still trying to find the file locally during deployment. Let's modify your deployment to use the correct approach for Prefect 3.x with an existing Docker image:
python
sync_minio_to_bronze.deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
image="danielleicht/bullzai:latest",
build=False,
push=False,
flow_directory="/app" # Add this line to specify where to find the flow in the container
)
The flow_directory
parameter tells Prefect where to look for the flow file inside the container. Since your flow file is directly in the /app
directory (as confirmed by your ls
output), this should work.
If you're still getting file not found errors, we might need to check:
1. Is the K8s work pool configured with the Docker infrastructure type?
2. Does the flow name in bronze.py
exactly match sync_minio_to_bronze
?Daniel Leicht
07/09/2025, 9:48 AMDaniel Leicht
07/09/2025, 9:48 AMMarvin
07/09/2025, 9:48 AMMarvin
07/09/2025, 9:49 AMpython
sync_minio_to_bronze.from_source(
source="docker-image/danielleicht/bullzai:latest",
entrypoint="bronze.py:sync_minio_to_bronze" # Note: relative to /app since that's your WORKDIR
).deploy(
name="minio-to-bronze",
work_pool_name="K8s Pool",
build=False,
push=False
)
Key changes:
1. Using just bronze.py
instead of /app/bronze.py
since /app
is your WORKDIR
2. Making sure the flow name matches exactly what's in your file
If you're still getting the file not found error, could you share the content of your bronze.py
file (at least the flow definition part)? This would help ensure we're using the correct flow name in the entrypoint.Daniel Leicht
07/09/2025, 10:59 AMMarvin
07/09/2025, 10:59 AMMarvin
07/09/2025, 11:00 AMpython
from prefect.workers.kubernetes import KubernetesWorkerJobConfiguration
work_pool.update(
job_configuration=KubernetesWorkerJobConfiguration(
env={"INHERITED_VAR": "value"}, # These will be passed to all flow runs
)
)
2. Via Worker Configuration File:
Create a kubernetes-worker.yaml
file:
yaml
kubernetes:
job:
env:
- name: INHERITED_VAR
value: "some_value"
# To inherit from the worker's environment:
- name: SPECIAL_VAR
valueFrom:
fieldRef:
fieldPath: metadata.name # or other Kubernetes field refs
3. During Deployment:
python
flow.deploy(
name="my-deployment",
work_pool_name="k8s-pool",
job_configuration={
"env": {"INHERITED_VAR": "value"}
}
)
The environment variables will be passed down to each flow run container that the worker spawns. The precedence order (from highest to lowest) is:
1. Deployment-specific variables
2. Work pool configuration
3. Worker configuration
4. System environment variables
If you need to access these variables in your flow code, you can use:
python
import os
@flow
def my_flow():
value = os.environ.get("INHERITED_VAR")
# Use the value...
Let me know if you need help with any specific environment variables or configuration scenarios.Daniel Leicht
07/09/2025, 11:01 AMMarvin
07/09/2025, 11:03 AMMarvin
07/09/2025, 11:03 AMvalues.yaml
file (or use --set
flags with helm):
yaml
worker:
env:
- name: MY_ENV_VAR
value: "my_value"
- name: DATABASE_URL
value: "postgresql://..."
# For secrets, you can use valueFrom:
- name: API_KEY
valueFrom:
secretKeyRef:
name: my-secret
key: api-key
Then apply it using Helm:
bash
helm upgrade prefect-worker prefect/prefect-worker \
-f values.yaml \
--namespace your-namespace
Or if you prefer using --set
directly:
bash
helm upgrade prefect-worker prefect/prefect-worker \
--set "worker.env[0].name=MY_ENV_VAR" \
--set "worker.env[0].value=my_value" \
--namespace your-namespace
For sensitive data, it's better to use Kubernetes secrets:
1. First create the secret:
bash
kubectl create secret generic my-secret \
--from-literal=api-key=your-secret-key \
--namespace your-namespace
2. Then reference it in your values.yaml:
yaml
worker:
env:
- name: API_KEY
valueFrom:
secretKeyRef:
name: my-secret
key: api-key
These environment variables will be available to all flow runs that the worker spawns. Remember to restart your worker after applying the changes:
bash
helm upgrade prefect-worker prefect/prefect-worker -f values.yaml