Skip to content

Commit

Permalink
[docs] add example using EnvVar.get_value() method (#23392)
Browse files Browse the repository at this point in the history
## Summary & Motivation
Follow up from #23355

Worth documenting because if you try to access a Dagster `EnvVar` without it you'll get an error message that says explicitly "To access the environment variable value, call get_value on the EnvVar"

## How I Tested These Changes
👀
  • Loading branch information
garethbrickman authored Aug 19, 2024
1 parent ab2fe4b commit 804b6c4
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ deployment_name = os.getenv("DAGSTER_CLOUD_DEPLOYMENT_NAME")

Refer to the [Dagster+ Branch Deployments example](#example-2-dagster-branch-deployments) for a real-world example.

You can also call the `get_value()` method on the `EnvVar`:

```python
from dagster import EnvVar

database_name = EnvVar('DATABASE_NAME').get_value()
```

### From Dagster configuration

[Configurable Dagster objects](/concepts/configuration/config-schema) - such as ops, assets, resources, I/O managers, and so on - can accept configuration from environment variables. Dagster provides a native way to specify environment variables in your configuration. These environment variables are retrieved at launch time, rather than on initialization as with `os.getenv`. Refer to the [next section](#using-envvar-vs-osgetenv) for more info.
Expand Down

1 comment on commit 804b6c4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagster-docs ready!

✅ Preview
https://dagster-docs-lvfkmbphv-elementl.vercel.app
https://master.dagster.dagster-docs.io

Built with commit 804b6c4.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.