Is there a way to access the fields of a Configura...
# ask-community
c
Is there a way to access the fields of a ConfigurableResource after it has been created like a python object (or a dataclass)? I see that there's a
.dict()
function, but i'd like to use the fields directly if possible
🤖 1
b
Hi Chaitya, yes, you should be able to directly access the fields if I’m interpreting your question right:
Copy code
from dagster import ConfigurableResource, Definitions, asset

class MyResource(ConfigurableResource):
    foo: str

@asset
def my_asset(my_resource: MyResource):
    assert my_resource.foo == "bar"

defs = Definitions(
    assets=[my_asset],
    resources={
        "my_resource": MyResource(foo="bar")
    }
)
c
Ah, i had a mypy issue because i had my resource in a collection of type
ConfigurableResource[Any]
. That was preventing the type checker from knowing that the fields existed.
👍 1
Thanks!