Skip to content

Commit

Permalink
pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiedemaria committed Aug 28, 2024
1 parent 9593f31 commit 1e94b9d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/docs-beta/docs/guides/external-systems/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ To follow the steps in this guide, you'll need:

## Step 1: Write a resource to connect to an API

This example fetches the sunrise time for a given location from a REST API. Begin by defining a Dagster resource with a method to return the sunrise time for a location. In the first version of this resource, the location will be hardcoded to San Francisco International Airport.
This example fetches the sunrise time for a given location from a REST API.

Begin by defining a Dagster resource with a method to return the sunrise time for a location. In the first version of this resource, the location will be hard-coded to San Francisco International Airport.


<CodeExample filePath="guides/external-systems/apis/minimal_resource.py" language="python" title="Resource to connect to the Sunrise API" />


## Step 2: Use the resource in an asset

To use the resource written in Step 1, you can provide it as a parameter to an asset:
To use the resource written in Step 1, you can provide it as a parameter to an asset after including it in the Definitions object:

<CodeExample filePath="guides/external-systems/apis/use_minimal_resource_in_asset.py" language="python" title="Use the SunResource in an asset" />

Expand All @@ -55,9 +57,9 @@ When you materialize `sfo_sunrise`, Dagster will provide a `SunResource` initial


## Step 4: Source configuration values from environment variables
Resources can also be configured with environment variables. You can use Dagster's built-in `EnvVar` class to source configuration values from environment variables at materialization time.
Resources can also be configured with environment variables. You can use Dagster's built-in `EnvVar` class to source configuration values from environment variables at materialization time.
In this example, there is a new `home_sunrise` asset. Rather than hardcoding the location of your home, you can set it in environment variables, and configure the `SunResource` by reading those values:
In this example, there is a new `home_sunrise` asset. Rather than hard-coding the location of your home, you can set it in environment variables, and configure the `SunResource` by reading those values:
<CodeExample filePath="guides/external-systems/apis/env_var_configuration.py" language="python" title="Configure the resource with values from environment variables" />
Expand All @@ -66,7 +68,7 @@ When you materialize `home_sunrise`, Dagster will read the values set for the `H
The initialized `SunResource` will be provided to the `sun_resource` parameter.
:::note
You can also fetch environment variables using the `os` library. Dagster treats each approach to fetching environment variables differently, such as when they are fetched or how they display in the UI. Refer to the [Environment variables guide](/todo) for more information.
You can also fetch environment variables using the `os` library. Dagster treats each approach to fetching environment variables differently, such as when they're fetched or how they display in the UI. Refer to the [Environment variables guide](/todo) for more information.
:::


Expand Down

0 comments on commit 1e94b9d

Please sign in to comment.