> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Scheduling and triggering

export const GCell = ({children, className}) => <div className={`grid-table-cell ${className || ""}`} role="cell">
    {children}
  </div>;

export const GTH = ({children, className}) => <div className={`grid-table-th ${className || ""}`} role="columnheader">
    {children}
  </div>;

export const GRow = ({children}) => <div className="grid-table-row" role="row">{children}</div>;

export const GBody = ({children}) => <div className="grid-table-body" role="rowgroup">{children}</div>;

export const GHead = ({children}) => <div className="grid-table-head" role="rowgroup">{children}</div>;

export const GTable = ({children, className, cols}) => <div className={`grid-table not-prose overflow-hidden rounded-2xl ${className || ""}`} style={{
  "--grid-table-cols": cols
}} role="table">
    {children}
  </div>;

Metaflow flows can be started by a **time-based schedule** or by an **event** published from another flow. The decorators below are project-aware variants that register the schedule or trigger under the current project and branch.

Apply different schedules depending on which branch the flow is deployed to. If the branch doesn't match any pattern, no schedule is applied (the decorator is a no-op).

This wraps Metaflow's [`@schedule`](https://docs.metaflow.org/production/scheduling-metaflow-flows/introduction) with branch-aware routing: production can run on a tight cron while staging runs daily and feature branches get no schedule at all.

```python theme={null}
from obproject import ProjectFlow, project_schedule

@project_schedule({
    "main": {"cron": "0 8 * * 1-5", "timezone": "America/New_York"},
    "develop": {"daily": True},
    "release/*": {"hourly": True},
})
class MyFlow(ProjectFlow):
    @step
    def start(self):
        self.next(self.end)
```

<GTable cols="23% 10% 67%">
  <GHead>
    <GRow>
      <GTH>Parameter</GTH>
      <GTH>Type</GTH>
      <GTH>Description</GTH>
    </GRow>
  </GHead>

  <GBody>
    <GRow>
      <GCell>`schedule_map`</GCell>
      <GCell>dict</GCell>
      <GCell>Maps branch glob patterns to schedule specs</GCell>
    </GRow>
  </GBody>
</GTable>

Each schedule spec is a dict with keys matching Metaflow's `@schedule` parameters:

<GTable cols="16% 10% 74%">
  <GHead>
    <GRow>
      <GTH>Key</GTH>
      <GTH>Type</GTH>
      <GTH>Description</GTH>
    </GRow>
  </GHead>

  <GBody>
    <GRow>
      <GCell>`cron`</GCell>
      <GCell>str</GCell>
      <GCell>Cron expression (e.g., `"0 8 * * 1-5"`)</GCell>
    </GRow>

    <GRow>
      <GCell>`daily`</GCell>
      <GCell>bool</GCell>
      <GCell>Run daily (default if empty spec `{}` is given)</GCell>
    </GRow>

    <GRow>
      <GCell>`weekly`</GCell>
      <GCell>bool</GCell>
      <GCell>Run weekly</GCell>
    </GRow>

    <GRow>
      <GCell>`hourly`</GCell>
      <GCell>bool</GCell>
      <GCell>Run hourly</GCell>
    </GRow>

    <GRow>
      <GCell>`timezone`</GCell>
      <GCell>str</GCell>
      <GCell>IANA timezone (e.g., `"America/New_York"`)</GCell>
    </GRow>
  </GBody>
</GTable>

### Behavior

* Patterns are matched using `fnmatch` glob syntax (e.g., `release/*` matches `release/v2`)
* First matching pattern wins (dict insertion order), so place more specific patterns first
* If no pattern matches the deployed branch, no schedule is created
* Cannot be combined with an explicit `@schedule` decorator on the same flow

Subscribe a flow to project events published by other flows via `prj.publish_event()`:

```python theme={null}
from obproject import ProjectFlow, project_trigger

@project_trigger(event="model_trained")
class EvaluationFlow(ProjectFlow):
    @step
    def start(self):
        # Triggered when "model_trained" event is published
        self.next(self.end)
```

The decorator resolves the full event name (`prj.{project}.{branch}.{event}`) from project config, so triggers are automatically scoped to the same branch.
