geoHeil
07/27/2022, 7:08 PMuser: "{{ env_var('WAREHOUSE_POSTGRES_USER') }}"
The dagster.yaml
file of the dagster-cloud runner actually provides these env vars:
run_launcher:
module: dagster_docker
class: DockerRunLauncher
config:
env_vars:
- WAREHOUSE_POSTGRES_DB=secret_value
- WAREHOUSE_POSTGRES_USER=secret_value
- WAREHOUSE_POSTGRES_PASSWORD=secret_value
However, the pipeline for:
name: myname
on: [pull_request]
jobs:
preview:
env:
WAREHOUSE_POSTGRES_DB: secret_value
WAREHOUSE_POSTGRES_PASSWORD: secret_value
WAREHOUSE_POSTGRES_USER: secret_value
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Create Dagster Cloud Code Preview
uses: dagster-io/dagster-cloud-cicd-action/preview@v0.2.5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
location-file: ./locations.yaml
dagit-url: https://${{ secrets.DAGSTER_CLOUD_ORGANIZATION }}.dagster.cloud/${{ secrets.DAGSTER_CLOUD_DEPLOYMENT }}
api-token: ${{ secrets.DAGSTER_CLOUD_AGENT_TOKEN }}
fails with:
/usr/bin/docker run <http://ghcr.io/my_org/my_project:git_hash|ghcr.io/my_org/my_project:git_hash> dagster-cloud workspace snapshot ***_cloud hash_token --url https://***.dagster.cloud/*** --api-token *** --image <http://ghcr.io/my_org/my_project:git_hash|ghcr.io/my_org/my_project:git_hash> --python-file MWF/repository.py --attribute ***_cloud
Encountered an error:
Parsing Error
Env var required but not provided: 'WAREHOUSE_POSTGRES_USER'
Where do I need to specify the env variables so they can be found when creating the preview?
The reason is that dagster-dbt and the CLI there needs these to import the DBT-based assets. It otherwise fails with an errorcode.Dagster Jarred
07/27/2022, 8:15 PMgeoHeil
07/28/2022, 3:34 AMdaniel
07/28/2022, 2:53 PMgeoHeil
07/28/2022, 2:58 PMdaniel
07/28/2022, 2:58 PMgeoHeil
07/28/2022, 3:01 PMdaniel
07/28/2022, 3:01 PMgeoHeil
07/28/2022, 3:07 PMdaniel
07/28/2022, 3:07 PMowen
07/28/2022, 4:20 PM"{{ env_var('WAREHOUSE_POSTGRES_USER') }}"
to user: "{{ env_var('WAREHOUSE_POSTGRES_USER', '') }}"
, so that if the environment variable is not present, an empty string will be supplied (rather than producing an error). Another option that would skirt around this issue would be to use load_assets_from_dbt_manifest
instead of load_assets_from_dbt_project
, as this way the project would already be compiled ahead of time, so dagster would not need to do that on the fly.geoHeil
07/28/2022, 4:59 PMload_assets_from_dbt_project
and would rather not want to move on to manifest - as a clean checkout of the project/ docker container should not include the compiled DBT definitions (at least I would not think this to be good practice)owen
07/28/2022, 5:55 PM...from_dbt_project()
workinggeoHeil
07/28/2022, 6:00 PMowen
07/28/2022, 6:07 PMenv_var()
calls in the dbt project would prevent this issue from cropping up regardless of the root problem (as it would make the question of "is x env var set in y place" irrelevant until dbt run
was called.geoHeil
07/28/2022, 6:10 PMowen
07/28/2022, 6:24 PMgeoHeil
07/28/2022, 6:25 PM