Lee-W commented on code in PR #44639: URL: https://github.com/apache/airflow/pull/44639#discussion_r1879427454
########## airflow/utils/context.py: ########## @@ -161,54 +176,57 @@ class OutletEventAccessor: :meta private: """ - raw_key: str | Asset | AssetAlias + key: BaseAssetUniqueKey extra: dict[str, Any] = attrs.Factory(dict) asset_alias_events: list[AssetAliasEvent] = attrs.field(factory=list) - def add(self, asset: Asset | str, extra: dict[str, Any] | None = None) -> None: + def add(self, asset: Asset, extra: dict[str, Any] | None = None) -> None: """Add an AssetEvent to an existing Asset.""" - if isinstance(asset, str): - asset_uri = asset - elif isinstance(asset, Asset): - asset_uri = asset.uri - else: + if not isinstance(self.key, AssetAliasUniqueKey): return - if isinstance(self.raw_key, str): - asset_alias_name = self.raw_key - elif isinstance(self.raw_key, AssetAlias): - asset_alias_name = self.raw_key.name - else: - return - - event = AssetAliasEvent(asset_alias_name, asset_uri, extra=extra or {}) + asset_alias_name = self.key.name + event = AssetAliasEvent( + source_alias_name=asset_alias_name, + dest_asset_key=AssetUniqueKey.from_asset(asset), + extra=extra or {}, + ) self.asset_alias_events.append(event) -class OutletEventAccessors(Mapping[str, OutletEventAccessor]): +class OutletEventAccessors(Mapping[Union[Asset, AssetAlias], OutletEventAccessor]): Review Comment: we probably should. but I think it might be better if we support it in the next PR. the purpose of this PR is adding `Asset.name` support to existing feature -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org