-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a "How to Automate Pipelines" guide. The idea behind this page is that it serves as the entry point for Automation. We explain the three ways to automate, each example offers links to a How-To guide with examples for that concept, and potentially a concept page. Not every idea needs a concept page. For example, Asset Sensors may only need a Guide and Reference API documentation. I did not include the section on Declarative Automation, but it would also fall here.
- Loading branch information
1 parent
1718a78
commit 4e1a1c9
Showing
14 changed files
with
217 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: Asset Sensors | ||
sidebar_position: 50 | ||
--- | ||
|
||
### Basic Asset Sensor Example | ||
|
||
<CodeExample filePath="guides/automation/simple-asset-sensor-example.py" language="python" title="Simple Asset Sensor Example" /> | ||
|
||
This Asset Sensor will trigger a run of `my_job` whenever the `asset_to_watch` asset is materialized. |
4 changes: 2 additions & 2 deletions
4
...ext/docs/guides/automation/creating-dynamic-pipelines-based-on-external-data.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: "Creating dynamic pipelines based on external data" | ||
sidebar_position: 3 | ||
sidebar_position: 30 | ||
--- | ||
|
||
# Creating dynamic pipelines based on external data | ||
# Creating dynamic pipelines based on external data |
6 changes: 0 additions & 6 deletions
6
docs/docs-next/docs/guides/automation/running-pipelines-on-a-schedule.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
title: "Scheduling pipelines" | ||
sidebar_label: "Running pipelines on a schedule" | ||
sidebar_position: 10 | ||
--- | ||
|
||
## Basic Schedule Example | ||
|
||
A basic schedule is defined by a `JobDefinition` and a `cron_schedule` using the `ScheduleDefinition` class. | ||
|
||
<CodeExample filePath="guides/automation/simple-schedule-example.py" language="python" title="Simple Schedule Example" /> | ||
|
||
## How to Set Custom Timezones | ||
|
||
By default, schedules without a timezone will run in UTC. If you want to run a schedule in a different timezone, you can | ||
set the `timezone` parameter. | ||
|
||
```python | ||
ecommerce_schedule = ScheduleDefinition( | ||
job=ecommerce_job, | ||
cron_schedule="15 5 * * 1-5", | ||
timezone="America/Los_Angeles", | ||
) | ||
``` | ||
|
||
## How to Create Partitioned Schedules | ||
|
||
If you have a partitioned asset and job, you can create a schedule from the partition using `build_schedule_from_partitioned_job`. | ||
The schedule will execute as the same cadence specified by the partition definition. | ||
|
||
```python | ||
from dagster import ( | ||
asset, | ||
build_schedule_from_partitioned_job, | ||
define_asset_job, | ||
DailyPartitionsDefinition, | ||
) | ||
|
||
daily_partition = DailyPartitionsDefinition(start_date="2024-05-20") | ||
|
||
|
||
@asset(partitions_def=daily_partition) | ||
def daily_asset(): ... | ||
|
||
partitioned_asset_job = define_asset_job("partitioned_job", selection=[daily_asset]) | ||
|
||
# highlight-start | ||
# This partition will run daily | ||
asset_partitioned_schedule = build_schedule_from_partitioned_job( | ||
partitioned_asset_job, | ||
) | ||
# highlight-end | ||
|
||
``` | ||
|
||
If you have a partitioned job, you can create a schedule from the partition using `build_schedule_from_partitioned_job`. | ||
|
||
```python | ||
from dagster import build_schedule_from_partitioned_job, job | ||
|
||
|
||
@job(config=partitioned_config) | ||
def partitioned_op_job(): ... | ||
|
||
# highlight-start | ||
partitioned_op_schedule = build_schedule_from_partitioned_job( | ||
partitioned_op_job, | ||
) | ||
# highlight-end | ||
``` | ||
|
||
--- | ||
|
||
For more information about how Schedules work, see the [About Schedules](/concepts/schedules) concept page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
title: Sensor Examples | ||
--- | ||
|
||
### Basic Sensor Example | ||
|
||
This example includes a `check_for_new_files` function that simulates finding new files. In a real scenario, this function would check an actual system or directory. | ||
|
||
The sensor runs every 5 seconds. If it finds new files, it starts a run of `my_job`. If not, it skips the run and logs "No new files found" in the Dagster UI. | ||
|
||
<CodeExample filePath="guides/automation/simple-sensor-example.py" language="python" title="Simple Sensor Example" /> | ||
|
||
:::tip | ||
|
||
By default, sensors aren't enabled when first deployed to a Dagster instance. | ||
Click "Automation" in the top navigation to find and enable a sensor. | ||
|
||
::: |
36 changes: 36 additions & 0 deletions
36
docs/docs-next/docs/guides/automation/simple-asset-sensor-example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from dagster import ( | ||
AssetExecutionContext, | ||
AssetKey, | ||
Definitions, | ||
RunRequest, | ||
asset, | ||
asset_sensor, | ||
define_asset_job, | ||
) | ||
|
||
|
||
@asset | ||
def asset_to_watch(context: AssetExecutionContext): | ||
context.log.info("Asset to watch") | ||
|
||
|
||
@asset | ||
def asset_to_trigger(context: AssetExecutionContext): | ||
context.log.info("Asset to trigger") | ||
|
||
|
||
my_job = define_asset_job("my_job", [asset_to_trigger]) | ||
|
||
|
||
# highlight-start | ||
@asset_sensor(asset_key=AssetKey("asset_to_watch"), job_name="my_job") | ||
def my_asset_sensor(): | ||
yield RunRequest() | ||
# highlight-end | ||
|
||
|
||
defs = Definitions( | ||
assets=[asset_to_watch, asset_to_trigger], | ||
jobs=[my_job], | ||
sensors=[my_asset_sensor], | ||
) |
25 changes: 25 additions & 0 deletions
25
docs/docs-next/docs/guides/automation/simple-schedule-example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from dagster import Definitions, ScheduleDefinition, asset, define_asset_job | ||
|
||
|
||
@asset | ||
def customer_data(): ... | ||
|
||
|
||
@asset | ||
def sales_report(): ... | ||
|
||
|
||
daily_refresh_job = define_asset_job("daily_refresh", selection=["customer_data", "sales_report"]) | ||
|
||
# highlight-start | ||
daily_schedule = ScheduleDefinition( | ||
job=daily_refresh_job, | ||
cron_schedule="0 0 * * *", # Runs at midnight daily | ||
) | ||
# highlight-end | ||
|
||
defs = Definitions( | ||
assets=[customer_data, sales_report], | ||
jobs=[daily_refresh_job], | ||
schedules=[daily_schedule], | ||
) |
Oops, something went wrong.
4e1a1c9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for dagster-docs-next ready!
✅ Preview
https://dagster-docs-next-cm3uh0xa2-elementl.vercel.app
Built with commit 4e1a1c9.
This pull request is being automatically deployed with vercel-action
4e1a1c9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for dagster-docs ready!
✅ Preview
https://dagster-docs-i4yl8o1t1-elementl.vercel.app
https://dagster-docs-next.dagster.dagster-docs.io
Built with commit 4e1a1c9.
This pull request is being automatically deployed with vercel-action