Skip to content

Commit

Permalink
Update connecting-to-external-services.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed Jul 30, 2024
1 parent e9cbff0 commit 6fd3ee8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/content/tutorial/connecting-to-external-services.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ You should use resources to manage communicating with external services because

Suppose your Hacker News pipeline in Dagster has picked up momentum, and your stakeholders want to learn more about who is using it. You are tasked with analyzing how many people sign up for Hacker News.

In the scaffolded Dagster project you made in Part 2 of the tutorial, you may have noticed a directory called `resources` with an `__init__.py` file in it. It exposes a resource called `DataGeneratorResource`. This resource generates simulated data about Hacker News signups. You'll use this resource to get the data needed to produce an asset for analysis.
In the scaffolded Dagster project you made in Part 2 of the tutorial, you may have noticed a file called `resources.py`. It exposes a resource called `DataGeneratorResource`. This resource generates simulated data about Hacker News signups. You'll use this resource to get the data needed to produce an asset for analysis.

<Note>
The signup data from Hacker News is fake and generated by the library. This is
simulated data and should not be used for real use cases.
</Note>

In your `__init__.py`, import the class, create an instance of it, and add it to the `resources` argument for your code location's <PyObject object="Definitions" /> object under the key `hackernews_api`. The key used to define a resource in the <PyObject object="Definitions" /> object is the key you'll use to reference the resource later in your code. In this case, we’ll call it `hackernews_api`.
In your `definitions.py`, import the class, create an instance of it, and add it to the `resources` argument for your code location's <PyObject object="Definitions" /> object under the key `hackernews_api`. The key used to define a resource in the <PyObject object="Definitions" /> object is the key you'll use to reference the resource later in your code. In this case, we’ll call it `hackernews_api`.

Verify that your code looks similar to the code below:

Expand Down Expand Up @@ -163,7 +163,7 @@ HACKERNEWS_NUM_DAYS_WINDOW=30

Rename this file from `.env.example` to `.env`.

Afterward, you'll use Dagster's `EnvVar` class to access the environment variable. Update your `__init__.py` with the changes below:
Afterward, you'll use Dagster's `EnvVar` class to access the environment variable. Update your `definitions.py` with the changes below:

```python file=/tutorial/connecting/connecting_with_envvar.py startafter=start_add_config_to_resource endbefore=end_add_config_to_resource
from dagster import (
Expand Down

0 comments on commit 6fd3ee8

Please sign in to comment.