-
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.
Add automation guide page and examples
- Loading branch information
1 parent
b5e66a4
commit 8e9ad76
Showing
4 changed files
with
111 additions
and
79 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
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], | ||
) |
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