Abhishek Singh
02/20/2025, 10:19 AMMarvin
02/20/2025, 10:19 AMtask_run_name
parameter when defining a task. You can include placeholders in the task run name that will be replaced with the values of the task's input parameters.
2. Example Usage:
python
from prefect import task, flow
@task(task_run_name="MyTask-{param}")
def my_task(param):
return f"Processed {param}"
@flow
def my_flow():
my_task("example")
my_flow()
In the example above, the task run name will be MyTask-example
when the flow is executed. You can replace {param}
with any parameter passed to the task.
For more details, you can refer to the Prefect documentation on task customization.
If you have any more specific requirements or need further details, feel free to ask!Abhishek Singh
02/20/2025, 10:46 AMMarvin
02/20/2025, 10:46 AMAbhishek Singh
02/25/2025, 9:19 AMMarvin
02/25/2025, 9:19 AMAbhishek Singh
02/25/2025, 9:20 AMMarvin
02/25/2025, 9:21 AMAbhishek Singh
02/25/2025, 9:21 AMMarvin
02/25/2025, 9:21 AMAbhishek Singh
03/06/2025, 4:21 PMMarvin
03/06/2025, 4:22 PM.env
file to store environment variables such as the Prefect API URL and API key if you're using Prefect Cloud. Example:
bash
PREFECT_API_URL=<http://localhost:4200/api> # or prefect cloud url
PREFECT_API_KEY=pnu_1234567890abcdefghijklmnopqrstuvwxyz # if using prefect cloud
2. Docker Compose Configuration: Use a docker-compose.yaml
file to define your services. Here's a basic example for a Prefect worker:
yaml
services:
worker:
image: prefecthq/prefect:2-python3.12
restart: always
command:
[
"prefect",
"worker",
"start",
"--pool",
"docker-work",
"--install-policy",
"if-not-present"
]
env_file:
- ./.env
ports:
- "8081:8081"
volumes:
- /var/run/docker.sock
3. Running the Setup: Start the application with Docker Compose.
bash
docker compose up -d
4. Monitoring Logs: To stream the logs, use:
bash
docker compose logs -f
5. Stopping the Setup: When you need to stop the application, run:
bash
docker compose down
These steps should help you integrate Prefect into a Docker Compose environment. For more detailed examples, you can refer to the Prefect documentation or explore example setups.