batuan
09/10/2025, 8:45 AMMarvin
09/10/2025, 8:45 AMMarvin
09/10/2025, 8:49 AMbatuan
09/10/2025, 9:26 AMPosture in Prefect UI, can you give me an json file or yaml, python code for this set up?Marvin
09/10/2025, 9:26 AMMarvin
09/10/2025, 9:35 AMprefect deployment inspect "flow-a/deployment-a"
prefect deployment inspect "flow-b/deployment-b"
prefect deployment inspect "flow-c/deployment-c"
- “Same day” is best approximated with a time window (within). Given A=08:00 and B=15:00, use PT18H or PT24H as appropriate.
- Posture: You don’t need to set it; this is a reactive automation by default.
Option 1: Sequence trigger (A completes, then B completes, within a window)
JSON payload (replace placeholders):
{
"name": "Run C after A then B complete same day",
"description": "Trigger deployment C only after A completes and then B completes within the time window.",
"enabled": true,
"trigger": {
"type": "sequence",
"within": "PT24H",
"triggers": [
{
"type": "event",
"match": {
"event": "prefect.flow-run.Completed"
},
"match_related": [
{
"prefect.resource.id": "prefect.deployment.<DEPLOYMENT_ID_A>"
}
]
},
{
"type": "event",
"match": {
"event": "prefect.flow-run.Completed"
},
"match_related": [
{
"prefect.resource.id": "prefect.deployment.<DEPLOYMENT_ID_B>"
}
]
}
]
},
"actions": [
{
"type": "run-deployment",
"deployment_id": "<DEPLOYMENT_ID_C>",
"parameters": {}
}
]
}
Option 2: Compound trigger (A and B complete in any order within a window)
{
"name": "Run C after A and B complete same day (any order)",
"description": "Trigger deployment C after both A and B complete successfully within the time window.",
"enabled": true,
"trigger": {
"type": "compound",
"require": "all",
"within": "PT24H",
"triggers": [
{
"type": "event",
"match": {
"event": "prefect.flow-run.Completed"
},
"match_related": [
{
"prefect.resource.id": "prefect.deployment.<DEPLOYMENT_ID_A>"
}
]
},
{
"type": "event",
"match": {
"event": "prefect.flow-run.Completed"
},
"match_related": [
{
"prefect.resource.id": "prefect.deployment.<DEPLOYMENT_ID_B>"
}
]
}
]
},
"actions": [
{
"type": "run-deployment",
"deployment_id": "<DEPLOYMENT_ID_C>",
"parameters": {}
}
]
}
How to create the automation (curl)
- Set PREFECT_API_URL and PREFECT_API_KEY (Cloud) in your environment.
- Then:
curl -X POST "$PREFECT_API_URL/automations/" \
-H "Authorization: Bearer $PREFECT_API_KEY" \
-H "Content-Type: application/json" \
-d @automation.json
Where automation.json is one of the payloads above.
How to create the automation (Python)
```
import os
import httpx
PREFECT_API_URL = os.environ.get("PREFECT_API_URL", "http://127.0.0.1:4200/api")
PREFECT_API_KEY = os.environ.get("PREFECT_API_KEY") # Only needed for Cloud
payload = {
"name": "Run C after A then B complete same day",
"enabled": True,
"trigger": {
"type": "sequence",
"within": "PT24H",
"triggers": [
{
"type": "event",
"match": {"event": "prefect.flow-run.Completed"},
"match_related": [{"prefect.resource.id": "prefect.deployment.<DEPLOYMENT_ID_A>"}]
},
{
"type": "event",
"match": {"event": "prefect.flow-run.Completed"},
"match_related": [{"prefect.resource.id": "prefect.deployment.<DEPLOYMENT_ID_B>"}]
}
]
},
"actions": [Marvin
09/10/2025, 9:35 AMHow to get deployment IDs
- Replace with your names:
prefect deployment inspect "flow-a/deployment-a"
prefect deployment inspect "flow-b/deployment-b"
prefect deployment inspect "flow-c/deployment-c"
```
Copy the id from each and substitute into the JSON.
A few practical tips
- Tighten the window: If you strictly want “same day” in your local timezone, set a tighter within (e.g., PT18H for 08:00 → 15:00) to prevent cross-midnight pairing.
- Retries/reruns: Each pair that satisfies the trigger may cause a run of C; if you want just one, keep A and B on single daily schedules and avoid manual reruns, or consider adding a small controller flow.
Docs
- Creating automations and triggers: Creating automations and triggers
- Event triggers overview: Event triggers concept
If you share the actual deployment names/IDs for A, B, and C, I can fill in a final payload for you.batuan
09/10/2025, 1:38 PMMarvin
09/10/2025, 1:38 PMMarvin
09/10/2025, 1:39 PMparameters dict, Prefect will take those values and merge them over the deployment’s default parameters.
- The merge is shallow (top-level keys only):
- If you provide a key in the action’s parameters, it overrides the deployment’s default for that key.
- If you omit a key, the deployment’s default for that key is used.
- If you set a key to null (None), that null will override the default (i.e., the value becomes null).
- Nested dicts are not deeply merged; a provided nested dict replaces the entire value for that key.
Example
- Deployment C defaults:
{
"date": "today",
"region": "us-east-1",
"options": {
"full_refresh": false,
"batch_size": 1000
}
}
- Automation action parameters:
{
"region": "eu-west-1",
"options": {
"full_refresh": true
}
}
- Effective parameters at runtime:
{
"date": "today", # from defaults (not overridden)
"region": "eu-west-1", # overridden by action
"options": {"full_refresh": true}# replaced entirely (batch_size is NOT retained)
}
Rule of thumb:
- Provide only the keys you want to change.
- If you need to keep nested defaults, include them explicitly in the action payload (since it’s a replace, not a deep-merge).batuan
09/26/2025, 10:59 AMMarvin
09/26/2025, 10:59 AMresearch_prefect_topic
📊 Tools used:
• research_prefect_topic (1x)