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

[module-loaders] Further simplify asset checks path #26527

Merged

Conversation

dpeng817
Copy link
Contributor

@dpeng817 dpeng817 commented Dec 16, 2024

Summary & Motivation

We can further simplify the load_asset_from_x code path by making the asset checks loader return AssetsDefinitions, and changing the assertions to just make sure that the returned assets only contain checks.

How I Tested These Changes

Altered existing tests

Copy link
Contributor Author

dpeng817 commented Dec 16, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Contributor

@OwenKephart OwenKephart left a comment

Choose a reason for hiding this comment

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

I thought about this a bit more, and as much as it really is unlikely that this causes issues, it is part of our public api and we should do our best to respect semver. These bits of code are ugly but not necessarily an ongoing maintenance concern

@yuhan
Copy link
Contributor

yuhan commented Dec 17, 2024

The return type of load_asset_checks_from_modules has been changed from Sequence[AssetChecksDefinition] to Sequence[AssetsDefinition]. AssetChecksDefinition is a thin wrapper around AssetsDefinition, so we don't anticipate this should require any code behavior changes on the part of our users.

"AssetChecksDefinition is a thin wrapper around AssetsDefinition" predates this PR, but i actually think exposing this implementation is a little risky as many users may not think asset check is a thin wrapper around asset definition (if you look at our doc today, asset_check feels like a peer concept to asset than a extending implementation.

with that, i'm with owen that while this isn't a significant change, it could be a thrash to existing users. for example, a concrete confusing case could be:

schedules: Sequence[ScheduleDefinition] = ...
sensors: Sequence[SensorDefinition] = ...
# one may question why this returns a list of AssetsDefinition's but still need to be provided separately 
asset_checks: Sequence[AssetsDefinition]  = load_asset_checks_from_modules([checks_module])
# ok...this assets type hint is a separate issue that we worry about later...
assets: Sequence[Union[AssetsDefinition, SourceAsset, CacheableAssetsDefinition]] = load_assets_from_modules([assets_modle])

defs = Definitions(
    assets=assets,
    asset_checks=asset_checks,
    schedules=schedules,
   sensors=sensors,
)

@dpeng817
Copy link
Contributor Author

Perhaps an alternative could be an easy transformation API that coerces an AssetsDefinition to an AssetChecksDefinition, assuming the properties line up. That way we don't have to have this boilerplate in multiple places, at least

@dpeng817 dpeng817 force-pushed the dpeng817/include_specs branch from 1570691 to 203c228 Compare December 18, 2024 02:52
@dpeng817 dpeng817 force-pushed the dpeng817/simply_check_path branch from 1c711a7 to 9dd1552 Compare December 18, 2024 02:52
@dpeng817 dpeng817 force-pushed the dpeng817/include_specs branch from 203c228 to 1fff846 Compare December 18, 2024 03:35
@dpeng817 dpeng817 force-pushed the dpeng817/simply_check_path branch from 9dd1552 to 42f1009 Compare December 18, 2024 03:35
@dpeng817 dpeng817 requested a review from OwenKephart December 18, 2024 14:46
@dpeng817 dpeng817 dismissed OwenKephart’s stale review December 18, 2024 14:46

switched to a coercion method on AssetsDefinition

@dpeng817 dpeng817 changed the title Further simplify asset checks path [module-loaders] Further simplify asset checks path Dec 18, 2024
Copy link

graphite-app bot commented Dec 18, 2024

Graphite Automations

"Add a 'docs-to-migrate' label to PRs with docs" took an action on this PR • (12/18/24)

1 label was added to this PR based on Christopher DeCarolis's automation.

@dpeng817 dpeng817 force-pushed the dpeng817/delete_extra_source_assets branch from 2219a42 to 2853ef1 Compare December 18, 2024 18:36
@dpeng817 dpeng817 changed the base branch from dpeng817/delete_extra_source_assets to dpeng817/include_specs December 18, 2024 18:37
@dpeng817 dpeng817 force-pushed the dpeng817/include_specs branch from 2219a42 to 2b63520 Compare December 18, 2024 18:41
@dpeng817 dpeng817 force-pushed the dpeng817/simply_check_path branch from 081e1e8 to 82f47fd Compare December 18, 2024 18:42
@dpeng817 dpeng817 changed the base branch from dpeng817/include_specs to dpeng817/delete_extra_source_assets December 18, 2024 19:29
@dpeng817 dpeng817 force-pushed the dpeng817/delete_extra_source_assets branch from 2b63520 to 50fb6a7 Compare December 18, 2024 20:24
@dpeng817 dpeng817 force-pushed the dpeng817/simply_check_path branch from 82f47fd to 4292bbd Compare December 18, 2024 20:24
@dpeng817 dpeng817 force-pushed the dpeng817/delete_extra_source_assets branch from 50fb6a7 to 80674c2 Compare December 18, 2024 20:50
@dpeng817 dpeng817 force-pushed the dpeng817/simply_check_path branch 2 times, most recently from e31896e to 3c7b7af Compare December 18, 2024 20:55
@dpeng817 dpeng817 force-pushed the dpeng817/delete_extra_source_assets branch from 80674c2 to 8e93c2e Compare December 18, 2024 21:27
@dpeng817 dpeng817 force-pushed the dpeng817/simply_check_path branch from 3c7b7af to 2b54d94 Compare December 18, 2024 21:27
@dpeng817 dpeng817 force-pushed the dpeng817/delete_extra_source_assets branch from 8e93c2e to 0291fcc Compare December 19, 2024 00:27
@dpeng817 dpeng817 force-pushed the dpeng817/simply_check_path branch from 2b54d94 to 43c784b Compare December 19, 2024 00:27
@dpeng817 dpeng817 force-pushed the dpeng817/delete_extra_source_assets branch from 0291fcc to c2914bc Compare December 19, 2024 01:18
@dpeng817 dpeng817 force-pushed the dpeng817/simply_check_path branch from 43c784b to 35682c5 Compare December 19, 2024 01:18
@dpeng817 dpeng817 force-pushed the dpeng817/delete_extra_source_assets branch from c2914bc to db63c88 Compare December 19, 2024 02:05
@dpeng817 dpeng817 force-pushed the dpeng817/simply_check_path branch from 35682c5 to 66e1db2 Compare December 19, 2024 02:05
Copy link
Contributor

@yuhan yuhan left a comment

Choose a reason for hiding this comment

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

make sure you remove the changelog section which seems no longer valid.

@dpeng817 dpeng817 force-pushed the dpeng817/delete_extra_source_assets branch from db63c88 to e99f85b Compare December 19, 2024 14:18
@dpeng817 dpeng817 force-pushed the dpeng817/simply_check_path branch from 66e1db2 to 254076c Compare December 19, 2024 14:18
@dpeng817 dpeng817 merged commit e3763d4 into dpeng817/delete_extra_source_assets Dec 19, 2024
1 check was pending
@dpeng817 dpeng817 deleted the dpeng817/simply_check_path branch December 19, 2024 14:19
dpeng817 added a commit that referenced this pull request Dec 19, 2024
## Summary & Motivation
We can further simplify the load_asset_from_x code path by making the
asset checks loader return AssetsDefinitions, and changing the
assertions to just make sure that the returned assets only contain
checks.

## How I Tested These Changes
Altered existing tests
dpeng817 added a commit that referenced this pull request Dec 19, 2024
## Summary & Motivation
We can further simplify the load_asset_from_x code path by making the
asset checks loader return AssetsDefinitions, and changing the
assertions to just make sure that the returned assets only contain
checks.

## How I Tested These Changes
Altered existing tests
dpeng817 added a commit that referenced this pull request Dec 19, 2024
## Summary & Motivation
We can further simplify the load_asset_from_x code path by making the
asset checks loader return AssetsDefinitions, and changing the
assertions to just make sure that the returned assets only contain
checks.

## How I Tested These Changes
Altered existing tests
dpeng817 added a commit that referenced this pull request Dec 19, 2024
## Summary & Motivation
We can further simplify the load_asset_from_x code path by making the
asset checks loader return AssetsDefinitions, and changing the
assertions to just make sure that the returned assets only contain
checks.

## How I Tested These Changes
Altered existing tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-to-migrate Docs to migrate to new docs site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants