Hi everyone, I'm trying to launch dagster in debug...
# ask-community
i
Hi everyone, I'm trying to launch dagster in debug mode in VS Code and I'm having a few issues with the configs/resources. Running dagit by itself in the terminal works perfectly, it's only when I use the debug mode I get the attached error message. 'dwh_conn_str' is an env var which the program is able to find so I'm not sure why it errors. I've also attached the launch.json file I have. Would greatly appreciate any help, I'm fairly new to this 🙏
c
it sounds like you're using
dwh_conn_str
as a dagster resource, but from your description it sounds like you defined it as an env var. Can you share a code snippet to show your use case?
i
It is defined as an env_var but it seems like it feeds in to a resource
@resource()
def dwh_conn_str(context):
return os.environ['DWH_CONN_STR']
c
I see. Do you specify the resource as a required resource key within your ops? Because the error message that you're getting is usually a result of trying to use a resource without defining a dependency on that resource.
i
It's a required_key on the io_manager:
Copy code
@io_manager(required_resource_keys={'dwh_conn_str', 'follower_conn_str'})
def lookout_db_io_manager(init_context):
    """ wrapper per <https://docs.dagster.io/concepts/io-management/io-managers> """
    return DatabaseIOManager() # This is a custom input manager
which feeds into the modes
Copy code
mode_def_dwh = ModeDefinition(  
    "data_warehouse_mode",
    resource_defs={
        "io_manager": lookout_db_io_manager,
        "dwh_conn_str": dwh_conn_str,
        "follower_conn_str": follower_conn_str
    },
)
When I run dagit in the UI, I select the data_warehouse_mode. I'm a little confused about why this works normally - just not in debug mode. If that's the case then I'm assuming I don't need to put the required resource key in every solid
It also seems to open a different dagit UI - it's greyed out instead of the normal blue UI
c
Hrmm interesting. A few things: 1. In vscode debug, you might need to specify explicitly env vars to pass to the subprocess: a la
Copy code
"env": {
                "EARLIEST_TESTED_RELEASE": "0.12.12"
            }
as part of your configuration. 2. We have a config type for passing env vars around called `StringSource`, which should help get better errors when things go wrong here.
Try these out, and let me know if the issue persists.
i
Thanks @chris, I ended up finding the problem. I was using a global dagit when I was running it normally which had a version of 0.12.8, the debug verison was using my local env which had 0.15.x. Putting my local env version to 0.12.8 seemed to fix the issue I really appreciate the help 🙏
❤️ 1