-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow attaching IO managers to specs (#23674)
## Summary For purposes of migrating older `@multi_assets` without dropping custom IO manager capability, it's useful to be able to specify an IO manager to use for each asset output. Currently, an invariant will error if the special `SYSTEM_METADATA_KEY_IO_MANAGER_KEY` key is set on a materializable multi-asset. This PR drops that requirement and threads through this IO manager expectation into the `Out`, also allowing any data type to be returned if an IO manager override is specified. Before: ```python @multi_asset( outs={ "foo": AssetOut(key=AssetKey("foo_asset"), io_manager_key="foo_io_manager", dagster_type=int) "bar": AssetOut(key=AssetKey("bar_asset"), io_manager_key="bar_io_manager", dagster_type=int) } ) def my_multi_asset(): ... yield Output(output_name="foo", value=5) yield Output(output_name="bar", value=10) ``` After: ```python @multi_asset( specs=[ AssetSpec(key=AssetKey("foo_asset"), metadata={SYSTEM_METADATA_KEY_IO_MANAGER_KEY: "foo_io_manager"}), AssetSpec(key=AssetKey("bar_asset"), metadata={SYSTEM_METADATA_KEY_IO_MANAGER_KEY: "bar_io_manager"}), ] ) def my_multi_asset(): ... yield Output(output_name=AssetKey("foo_asset").to_python_identifier(), value=5) yield Output(output_name=AssetKey("bar_asset").to_python_identifier(), value=10) ``` This is not particularly elegant, but lets us update existing multi-assets with IO-manager-processed outputs in-place to use specs, without breaking downstream assets which might depend on them. For a concrete example, see #23676. We wouldn't expect users to replicate this pattern, & shouldn't do so on any greenfield code. ## Test Plan New unit tests.
- Loading branch information
Showing
4 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters