Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[daggy-u] - Fix copy and indentation #19496

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ lesson: '1'

# Why is asset-centric orchestration good for data engineering?

In a task-centric world, it can be difficult to tell how an asset is produced, whether it’s up-to-date, and how it relates to other assets. Decoupling tasks from assets is necessary not only to troubleshoot issues when they arise, but to come to a basic understanding of the workflow.

On the other hand, an asset-centric workflow puts the focus on the data that’s produced rather than how it’s produced. This can make it easy to determine how a change could impact other assets and allow stakeholders to understand how their data is produced.

Let’s go back to our cookie example and take a look at what different situations might look like for both a task-centric and asset-centric approach.
To answer this question, let’s go back to our cookie example and take a look at what different situations might look like for both a task-centric and asset-centric approach.

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Now that cursors have been explained, let’s start writing the sensor.
```python
from dagster import (
RunRequest,
SensorResult,
SensorResult,
sensor
)

Expand Down Expand Up @@ -132,10 +132,14 @@ Now that cursors have been explained, let’s start writing the sensor.
))
```

- Using `os.listdir` , iterate through the `data/requests` directory, look at every JSON file, and see if it’s been updated or looked at it before in `previous_state`
- If the file has been updated or a report hasn’t been run before, create a `RunRequest` for the file
- Construct a unique `run_key`, which includes the name of the file and when it was last modified
- Pass the `run_key` into the `RunRequest`'s configuration using the `run_config` argument. By using the `adhoc_request` key, you specify that the `adhoc_request` asset should use the config provided.
**Note**: When pasting this into the sensor, verify that the indentation is correct or you'll encounter a Python error.

This example:

- Uses `os.listdir` to iterate through the `data/requests` directory, looking at every JSON file, and seeing if it’s been updated or looked at it before in `previous_state`
- Creates a `RunRequest` for the file if it's been updated or a report hasn’t been run before
- Constructs a unique `run_key`, which includes the name of the file and when it was last modified
- Passes the `run_key` into the `RunRequest`'s configuration using the `run_config` argument. By using the `adhoc_request` key, you specify that the `adhoc_request` asset should use the config provided.

9. Sensors expect a `SensorResult` returned, which contains all the information for the sensor, such as which runs to trigger and what the new cursor is. Append the following to the end of the sensor function:

Expand Down
Loading