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

Simplified AssetExecutionContext #16487

Closed
wants to merge 3 commits into from

Conversation

jamiedemaria
Copy link
Contributor

@jamiedemaria jamiedemaria commented Sep 13, 2023

Summary & Motivation

Breaks out the AssetExecutionContext into it's own class. This class should implement the IContext from #16480, but I can't import from dagster-ext so need to figure that part out first...

How I Tested These Changes

@jamiedemaria jamiedemaria changed the title bare bones asset execution context Simplified AssetExecutionContext Sep 13, 2023

@public
@experimental
def get_asset_provenance(self, asset_key: AssetKey) -> Optional[DataProvenance]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we want to simplify the context even further, we could make get_asset_provenance and get_assets_code_version not public since provenance, provenance_by_asset_key, code_version and code_version_by_asset_key should cover all use cases. If we get requests, we could then make these methods public

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the other option is to have a single object that has all the code version/provenance-related info and only return that.


@public
# TODO - method naming. this needs work
def get_assets_code_version(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternate names:

  • get_code_versions_for_assets

Alternately, we could delete this method entirely, and update the impls of code_version and code_version_by_asset_key to

    @property
    def code_version(self) -> Optional[str]:
        return self.code_version_by_asset_key[self.asset_key]

    @property
    def code_version_by_asset_key(self) -> Mapping[AssetKey, Optional[str]]:
        return self.op_execution_context.instance.get_latest_materialization_code_versions(
            self.asset_keys
        )


@public
def partition_key_range_for_asset_key(self, asset_key: AssetKey) -> PartitionKeyRange:
"""TODO - implement in stacked pr."""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implementing this method will require some changes the to step execution context. Leaving it for a stacked PR so that this PR stays easier to review

@jamiedemaria jamiedemaria marked this pull request as ready for review September 14, 2023 13:46
"file_manager",
"has_assets_def",
"get_mapping_key",
# "get_step_execution_context", # used by internals
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add these internal methods to a different set and emit a different warning

@jamiedemaria
Copy link
Contributor Author

closing as we're going down the subclass route. Can re-open if needed

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

Successfully merging this pull request may close these issues.

2 participants