https://dagster.io/ logo
#dagster-feedback
Title
# dagster-feedback
c

Caelan Schneider

02/16/2024, 2:45 PM
The with_resources documentation shows with_resources being used without the resource_defs parameter, but when I try it, I get the following error:
TypeError: with_resources() missing 1 required positional argument: 'resource_defs'
c

Colton Padden

02/16/2024, 3:00 PM
Hey @Caelan Schneider - thanks for pointing this out. You can find an example of using
with_resources
in this unit test. It's true that
resource_defs
is a required parameter. https://github.com/dagster-io/dagster/blob/02-16-_docs_fix_PipesLambdaClient_impor[…]/dagster_tests/core_tests/resource_tests/test_with_resources.py
Copy code
def test_config():
    the_asset, the_resource = get_resource_and_asset_for_config_tests()

    transformed_asset = with_resources(
        [the_asset],
        resource_defs={"foo": the_resource, "bar": the_resource},
        resource_config_by_key={"foo": {"config": "blah"}, "bar": {"config": "baz"}},
    )[0]

    transformed_asset(build_asset_context())
We'll make a task to update the docs. 🙏
c

Caelan Schneider

02/16/2024, 3:07 PM
@Colton thanks! I'm assuming there isn't but do you know if there's a way to configure a global resource (i.e. one that was defined in the
Definitions
object with
configure_at_launch()
) at the asset level? I know you can do it at the job level inside the config parameter, but I have two assets inside a job that I wanted to use the same global resource for , but configured differently.
c

Colton Padden

02/16/2024, 3:19 PM
For some more context, is the reason you want to use the same instance of the resource to manage # of connections, or something along those lines? Or is this configuration dynamic? Otherwise I'd maybe suggest creating two instances of the resource w/ different configurations. Or do the run_config approach.
c

Caelan Schneider

02/16/2024, 4:18 PM
Yeah basically I want to connect to two different databases. I ended up just using two different names.
👍 1