How to have required_resource_keys for new Pythonic resources? #14372
Replies: 1 comment 4 replies
-
Can you explain "automatically loaded by the resource key"? What behavior where you seeing before? In the old resource system, you still needed to instantiate the depended resource, so I want to make sure I'm correctly addressing your issue. If you have a resource that needs to be a top-level resource and used as a resource dependency for another resource, you would do something like this: from dagster import Definitions, ConfigurableResource
class CredentialsResource(ConfigurableResource):
username: str
password: str
class FileStoreBucket(ConfigurableResource):
credentials: CredentialsResource
region: str
def write(self, data: str):
get_filestore_client(
username=self.credentials.username,
password=self.credentials.password,
region=self.region,
).write(data)
credentials_resource = CredentialsResource(username="my_user", password="my_password")
defs = Definitions(
assets=[my_asset],
resources={
"bucket": FileStoreBucket(
credentials=credentials_resource
region="us-east-1",
),
"credentials": credentails_resource
},
) |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Using the legacy resource system, you could specify required resource keys as arguments:
@resource(required_resource_keys=...
How to accomplish the similar thing using Pythonic resources? If i follow the guide
class MyResource(ConfigurableResource): a: SomeOtherResource
I have to specify the resource when instantiating the class, i would like to have it automatically loaded by the resource key.
Is there any way to do this?
Beta Was this translation helpful? Give feedback.
All reactions