-
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.
move code examples to code_example folder
- Loading branch information
1 parent
c55b3f5
commit 7235e58
Showing
9 changed files
with
88 additions
and
36 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
docs/docs-next/docs/code_examples/guides/automation/asset-sensor-with-config.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,52 @@ | ||
from dagster import ( | ||
AssetExecutionContext, | ||
AssetKey, | ||
Definitions, | ||
EventLogEntry, | ||
RunRequest, | ||
SensorEvaluationContext, | ||
asset, | ||
asset_sensor, | ||
define_asset_job, | ||
) | ||
|
||
|
||
@asset | ||
def daily_sales_data(context: AssetExecutionContext): | ||
context.log.info("Asset to watch") | ||
|
||
|
||
@asset | ||
def weekly_report(context: AssetExecutionContext): | ||
context.log.info("Asset to trigger") | ||
|
||
|
||
my_job = define_asset_job("my_job", [weekly_report]) | ||
|
||
|
||
# highlight-start | ||
@asset_sensor(asset_key=AssetKey("daily_sales_data"), job=my_job) | ||
def daily_sales_data_sensor(context: SensorEvaluationContext, asset_event: EventLogEntry): | ||
# This satisifies the type checker. Asset events are guaranteed to have a dagster_event and asset_key. | ||
assert asset_event.dagster_event is not None | ||
assert asset_event.dagster_event.asset_key is not None | ||
|
||
return RunRequest( | ||
run_key=context.cursor, | ||
run_config={ | ||
"ops": { | ||
"read_materialization": { | ||
"config": { | ||
"asset_key": asset_event.dagster_event.asset_key.path, | ||
} | ||
} | ||
} | ||
}, | ||
) # highlight-end | ||
|
||
|
||
defs = Definitions( | ||
assets=[daily_sales_data, weekly_report], | ||
jobs=[my_job], | ||
sensors=[daily_sales_data_sensor], | ||
) |
36 changes: 36 additions & 0 deletions
36
docs/docs-next/docs/code_examples/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 daily_sales_data(context: AssetExecutionContext): | ||
context.log.info("Asset to watch") | ||
|
||
|
||
@asset | ||
def weekly_report(context: AssetExecutionContext): | ||
context.log.info("Asset to trigger") | ||
|
||
|
||
my_job = define_asset_job("my_job", [weekly_report]) | ||
|
||
|
||
# highlight-start | ||
@asset_sensor(asset_key=AssetKey("daily_sales_data"), job_name="my_job") | ||
def daily_sales_data_sensor(): | ||
return RunRequest() | ||
# highlight-end | ||
|
||
|
||
defs = Definitions( | ||
assets=[daily_sales_data, weekly_report], | ||
jobs=[my_job], | ||
sensors=[daily_sales_data_sensor], | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 0 additions & 36 deletions
36
docs/docs-next/docs/guides/automation/simple-asset-sensor-example.py
This file was deleted.
Oops, something went wrong.