Hi :wave_anim: I’m creating my own resource by ex...
# ask-community
m
Hi wave anim I’m creating my own resource by extending the
ConfigurableResource
. As per the Dagster docs, this means the new resource implements
ResourceDefinition
Copy code
class MyResource(ConfigurableResource)
However, when passing the resource to a graph, mypy complains that the resource passed across is an incompatible type
Copy code
my_resource = MyResource(...)

my_graph.to_job(
    name="my_job",
    resource_defs={
        "my_resource": my_resource,  # of type MyResource
    },
)
The mypy output:
Copy code
Argument "my_resource" to "my_job" has incompatible type "MyResource"; expected "ResourceDefinition"
Can anyone advise how this can be resolved? Using
dagster==1.4.6
o
try:
Copy code
my_graph.to_job(
    name="my_job",
    resource_defs={
        "my_resource": MyResource,  # of type MyResource
    },
)
m
Hi Odette, in my example.
my_resource
is already a constructed
MyResource
. E.g.:
Copy code
my_resource = MyResource(...)
o
gotcha - let me take a look
q
I’m having the same issue, I think this is a bug. Basically
ConfigurableResource
objects fail the
isinstance
check with type
ResourceDefinition
, as opposed to what says in the doc https://docs.dagster.io/_apidocs/resources#dagster.ConfigurableResource
This class is a subclass of both
ResourceDefinition
and
Config
.
Example:
Copy code
>>> from dagster import ConfigurableResource, ResourceDefinition
>>> class MyResource(ConfigurableResource):
...     name: str
... 
>>> my_resource = MyResource(name="abc")
>>> isinstance(my_resource, ResourceDefinition)
False