Manish Khatri
08/29/2023, 5:01 PMConfigurableResource
. As per the Dagster docs, this means the new resource implements ResourceDefinition
class MyResource(ConfigurableResource)
However, when passing the resource to a graph, mypy complains that the resource passed across is an incompatible type
my_resource = MyResource(...)
my_graph.to_job(
name="my_job",
resource_defs={
"my_resource": my_resource, # of type MyResource
},
)
The mypy output:
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
Odette Harary
08/29/2023, 5:40 PMmy_graph.to_job(
name="my_job",
resource_defs={
"my_resource": MyResource, # of type MyResource
},
)
Manish Khatri
08/29/2023, 5:41 PMmy_resource
is already a constructed MyResource
. E.g.:
my_resource = MyResource(...)
Odette Harary
08/29/2023, 5:47 PMQuang Hanh Nguyen
09/26/2023, 2:06 PMConfigurableResource
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 bothExample:andResourceDefinition
.Config
>>> from dagster import ConfigurableResource, ResourceDefinition
>>> class MyResource(ConfigurableResource):
... name: str
...
>>> my_resource = MyResource(name="abc")
>>> isinstance(my_resource, ResourceDefinition)
False