-
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.
- Loading branch information
1 parent
4dfc529
commit 8b520e7
Showing
6 changed files
with
282 additions
and
21 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
40 changes: 40 additions & 0 deletions
40
python_modules/dagster/dagster/_core/definitions/result.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import NamedTuple, Optional | ||
|
||
from .events import ( | ||
AssetKey, | ||
CoercibleToAssetKey, | ||
) | ||
from .metadata import MetadataUserInput | ||
|
||
|
||
class MaterializeResult( | ||
NamedTuple( | ||
"_MaterializeResult", | ||
[ | ||
("asset_key", Optional[AssetKey]), | ||
("metadata", Optional[MetadataUserInput]), | ||
], | ||
) | ||
): | ||
"""An object representing a successful materialization of an asset. These can be returned from | ||
@asset and @multi_asset decorated functions to pass metadata or specify specific assets were | ||
materialized. | ||
Attributes: | ||
asset_key (Optional[AssetKey]): Optional in @asset, required in @multi_asset to discern which asset this refers to. | ||
metadata (Optional[MetadataUserInput]): Metadata to record with the corresponding AssetMaterialization event. | ||
""" | ||
|
||
def __new__( | ||
cls, | ||
*, # enforce kwargs | ||
asset_key: Optional[CoercibleToAssetKey] = None, | ||
metadata: Optional[MetadataUserInput] = None, | ||
): | ||
asset_key = AssetKey.from_coercible(asset_key) if asset_key else None | ||
|
||
return super().__new__( | ||
cls, | ||
asset_key=asset_key, | ||
metadata=metadata, # check? | ||
) |
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
Oops, something went wrong.