<@ULVA73B9P> help me out in this, i have a deploym...
# marvin-ai
k
@Marvin help me out in this, i have a deployment created for a store and deployed via prefect.yaml which uses the workflow.py now the schedule attached to the flow is to run after every 30 minutes of interval, now in the schedule i have my dbt models which run in the flow, currently i have one task which i want to include in the same flow, but i dont want this flow to run on every 30 minutes, instead i want to run this once in a day but i want to include this task in the same flow so that i dont have to create another deployment for the same store with just different task is there a way i can do this?
m
thought for 334.3 seconds
Yes — you can keep a single deployment and add a second schedule with parameters that control which parts of the flow run. Pattern: - Add a boolean (or “mode”) parameter to your flow that gates the daily-only task. - Keep your existing 30‑minute schedule with the parameter set to false. - Add a daily schedule (on the same deployment) with the parameter set to true. Example flow code (Prefect 3.x):
Copy code
from prefect import flow, task, get_run_logger

@task
def run_dbt_models():
    # your dbt logic here
    ...

@task
def daily_only_task():
    # your once-per-day logic here
    ...

@flow
def store_workflow(run_daily: bool = False):
    logger = get_run_logger()
    # always run your regular tasks
    run_dbt_models()

    # only run this when the schedule sets run_daily=True
    if run_daily:
        <http://logger.info|logger.info>("Running daily-only task")
        daily_only_task()
    else:
        <http://logger.info|logger.info>("Skipping daily-only task")
prefect.yaml (one deployment, two schedules):
Copy code
deployments:
  - name: store-prod
    entrypoint: workflow.py:store_workflow
    parameters:
      run_daily: false
    work_pool:
      name: your-pool
    schedules:
      - interval: 1800        # every 30 minutes
        slug: every-30m
        active: true
        parameters:
          run_daily: false
      - cron: "0 2 * * *"     # once per day at 02:00 UTC
        timezone: "UTC"
        slug: daily
        active: true
        parameters:
          run_daily: true
Notes: - A single deployment can have multiple schedules; each schedule can provide its own parameters. Schedule parameters override deployment defaults for those runs. - This avoids creating a second deployment and ensures your “daily-only” task runs just once per day while the rest of the flow continues every 30 minutes. - You can manage schedules in YAML (recommended), via the UI, or with the CLI. If you edit YAML, re-run
prefect deploy
. Docs: - Create schedules - prefect.yaml reference Quick question to confirm the branching you want: - On the daily run, should the dbt tasks also run (plus the daily-only task), or do you want only the daily-only task to run? If it’s “only the daily task,” we can add another parameter (e.g.,
mode: "regular"|"daily"
) and conditionally skip the dbt section too. If you paste your current
workflow.py
and
prefect.yaml
, I can tailor the exact edits.