https://dagster.io/ logo
#ask-community
Title
# ask-community
p

Phil Landin

03/28/2023, 3:50 PM
Hi all! I'm starting to use environmental variables from a .env file with my run configurations, and am running into some challenges. Using the instructions on run configuration at this link, I've written the following in my job file:
Copy code
defs = Definitions(
    jobs=[
        pq_first_load_graph.to_job(
            resource_defs={'s3': s3_res},
            config={
                'ops': {
                    'get_city_data': {
                        'config': {
                            'cities': {'env': 'CITIES'}
                        }
                    }
                }
            }
        )
    ]
)
When I run "dagster dev -f <job_file>", I get the following error:
Copy code
dagster._core.errors.DagsterInvalidConfigError: Invalid default_value for Field. Error 1: Invalid scalar at path root:get_city_data:config:cities. Value "{'env': 'CITIES'}" of type "<class 'dict'>" is not valid for expected type "String".
Any ideas on what I'm doing wrong? Also, out of curiosity, once I solve this issue, will I have to manually enter the cities value in the job launchpad? I had previously been using os.getenv to load the environmental variables and couldn't figure out a way to get around entering them manually in the launchpad.
🤖 1
s

sean

03/28/2023, 4:28 PM
Hi Phil, You need
StringSource
set in the config schema for your
get_city_data
op, see here: https://docs.dagster.io/concepts/configuration/config-schema#passing-secrets-as-configuration I recognize that that snippet of docs you linked is misleading because it does not include this, I will fix it.
Also, out of curiosity, once I solve this issue, will I have to manually enter the cities value in the job launchpad? I had previously been using os.getenv to load the environmental variables and couldn’t figure out a way to get around entering them manually in the launchpad.
You shouldn’t need to do this if you have a
.env
file with the necessary values in the folder where dagit is launched.
p

Phil Landin

03/28/2023, 4:54 PM
Ok perfect. I've got it working now -- thanks very much @sean!
11 Views