Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve usage of pythonic resources #80

Open
balazsdukai opened this issue Oct 31, 2024 · 0 comments
Open

Improve usage of pythonic resources #80

balazsdukai opened this issue Oct 31, 2024 · 0 comments

Comments

@balazsdukai
Copy link
Member

The new pythonic resources allow us to pass the resource directly as a parameter to the asset, instead of going through the asset context.

A simplified example of what we have now:

@asset(
    required_resource_keys={"file_store"},
    partitions_def=PartitionDefinitionAHN(),
)
def laz_files_ahn3(context):
    context.resources.file_store.file_store.data_dir

What is possible with the pythonic resource:

@asset(partitions_def=PartitionDefinitionAHN())
def laz_files_ahn3(context, file_store: FileStoreResource):
    file_store.data_dir

While the first works, the second approach has a few advantages, it's shorter and we get code completion and type checking in the editor.

Finish the migration of the assets to the pythonic resource usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants