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

[external-assets] Make execution_type an ExternalAssetNode property #19684

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

smackesey
Copy link
Collaborator

@smackesey smackesey commented Feb 8, 2024

Summary & Motivation

This adds execution_type as a property on ExternalAssetsNode and defines execution-type related helper properties on AssetsDefinition.

Logic is in place on ExternalAssetNode to ensure that execution_type specified as a param agrees with metadata.

How I Tested These Changes

Existing test suite.

@smackesey
Copy link
Collaborator Author

smackesey commented Feb 8, 2024

@smackesey smackesey force-pushed the sean/allow-mixed-asset-jobs branch from 9d22a35 to d881aa6 Compare February 8, 2024 19:35
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from a5a00c6 to 1a4ff9b Compare February 8, 2024 19:35
@smackesey smackesey force-pushed the sean/allow-mixed-asset-jobs branch from d881aa6 to a1490ca Compare February 8, 2024 20:12
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from 1a4ff9b to cfd2894 Compare February 8, 2024 20:12
@smackesey smackesey force-pushed the sean/allow-mixed-asset-jobs branch from a1490ca to 36d76b2 Compare February 8, 2024 22:55
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from cfd2894 to acd306f Compare February 8, 2024 22:55
@smackesey smackesey force-pushed the sean/allow-mixed-asset-jobs branch from 36d76b2 to be3a82e Compare February 9, 2024 10:20
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from acd306f to 69d7b3e Compare February 9, 2024 10:20
@smackesey smackesey force-pushed the sean/allow-mixed-asset-jobs branch from be3a82e to 33f844e Compare February 9, 2024 14:13
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from 69d7b3e to b507aba Compare February 9, 2024 14:13
@smackesey smackesey marked this pull request as ready for review February 9, 2024 17:34
@smackesey smackesey requested a review from schrockn February 9, 2024 17:34
@smackesey smackesey force-pushed the sean/allow-mixed-asset-jobs branch from 33f844e to 3268b72 Compare February 10, 2024 17:43
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from b507aba to da4cd8d Compare February 10, 2024 17:43
@smackesey smackesey force-pushed the sean/allow-mixed-asset-jobs branch from 3268b72 to b6eb4c3 Compare February 10, 2024 17:45
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from da4cd8d to a956af4 Compare February 10, 2024 17:45
@smackesey smackesey force-pushed the sean/allow-mixed-asset-jobs branch from b6eb4c3 to 58c9a32 Compare February 11, 2024 14:15
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from a956af4 to 5cceb48 Compare February 11, 2024 14:15
@smackesey smackesey force-pushed the sean/allow-mixed-asset-jobs branch from 58c9a32 to 0e3c817 Compare February 12, 2024 16:15
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from 5cceb48 to 71ef97e Compare February 12, 2024 16:15
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from 71ef97e to 046bc7f Compare February 13, 2024 14:30
@smackesey smackesey changed the base branch from sean/allow-mixed-asset-jobs to master February 13, 2024 14:30
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from 046bc7f to 46799c0 Compare February 13, 2024 15:45
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch 3 times, most recently from 461f3a7 to 74a61c6 Compare February 13, 2024 16:49
@smackesey smackesey changed the base branch from master to sean/duckdb-pin February 13, 2024 17:09
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from 74a61c6 to 078c860 Compare February 13, 2024 17:09
Base automatically changed from sean/duckdb-pin to master February 13, 2024 17:34
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from 078c860 to f035484 Compare February 13, 2024 17:41
Copy link
Member

@schrockn schrockn left a comment

Choose a reason for hiding this comment

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

Can we please do this without changing the public API for asset and multi_asset and friends? The _ prefixed arguments will pollute typeaheads, we'll need documentation, it will add confusion etc.

@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch 2 times, most recently from bee736f to 0ed5804 Compare February 14, 2024 15:07
@smackesey smackesey force-pushed the sean/make-asset-execution-type-property branch from 0ed5804 to 05f5a4c Compare February 14, 2024 15:11
)
or AssetExecutionType.MATERIALIZATION
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Even though we are sticking with metadata for now to specify AssetExecutionType on AssetsDefinition, We still need this check because when an ExternalAssetNode represents a source asset there is no such metadata.

@smackesey
Copy link
Collaborator Author

I tried to do this by directly constructing AssetsDefinition but found it would require too much duplicative logic-- there is way more logic in the asset decorator code than I would expect. Makes it so that it's quite impractical to build AssetsDefinition directly with any confidence, as one would intuitively expect to do in a factory. Maybe something we should address in the future.

For the time being I reverted to using metadata per your suggestion in the upstack PR. This PR does still add the property on ExternalAssetNode and various helpers on AssetsDefinition.

@smackesey smackesey requested a review from schrockn February 14, 2024 16:07
@smackesey smackesey changed the title [external-assets] Make execution_type an AssetsDefinition property [external-assets] Make execution_type an ExternalAssetNode Feb 14, 2024
Copy link
Member

@schrockn schrockn left a comment

Choose a reason for hiding this comment

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

Great

Comment on lines +1249 to +1260
val = metadata[SYSTEM_METADATA_KEY_ASSET_EXECUTION_TYPE]
if not isinstance(val, TextMetadataValue):
check.failed(
f"Expected metadata value for key {SYSTEM_METADATA_KEY_ASSET_EXECUTION_TYPE} to be a TextMetadataValue, got {val}"
)
metadata_execution_type = AssetExecutionType.str_to_enum(val.value)
if execution_type is not None:
check.invariant(
execution_type == metadata_execution_type,
f"Execution type {execution_type} in metadata does not match type inferred from metadata {metadata_execution_type}",
)
execution_type = metadata_execution_type
Copy link
Member

Choose a reason for hiding this comment

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

consider extracting out body of if into the helper function to compartmentalize the backward compat code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the reason I didn't are that there are subsequent commented backcompat blocks in the constructor, so it was more consistent to go inline

Copy link
Member

Choose a reason for hiding this comment

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

cool makes sense.

@smackesey smackesey changed the title [external-assets] Make execution_type an ExternalAssetNode [external-assets] Make execution_type an ExternalAssetNode property Feb 14, 2024
@smackesey smackesey merged commit 6788bb8 into master Feb 14, 2024
1 check passed
@smackesey smackesey deleted the sean/make-asset-execution-type-property branch February 14, 2024 19:03
PedramNavid pushed a commit that referenced this pull request Mar 28, 2024
…19684)

## Summary & Motivation

This adds `execution_type` as a property on `ExternalAssetsNode` and
defines execution-type related helper properties on `AssetsDefinition`.

Logic is in place on `ExternalAssetNode` to ensure that `execution_type`
specified as a param agrees with metadata.

## How I Tested These Changes

Existing test suite.
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