mobuchowski commented on code in PR #31816:
URL: https://github.com/apache/airflow/pull/31816#discussion_r1226699888
##########
airflow/providers/amazon/aws/operators/sagemaker.py:
##########
@@ -275,14 +287,53 @@ def execute(self, context: Context) -> dict:
method_name="execute_complete",
)
- return {"Processing":
serialize(self.hook.describe_processing_job(self.config["ProcessingJobName"]))}
+ self.processing_job = {
+ "Processing":
serialize(self.hook.describe_processing_job(self.config["ProcessingJobName"]))
+ }
+ return self.processing_job
def execute_complete(self, context, event=None):
if event["status"] != "success":
raise AirflowException(f"Error while running job: {event}")
else:
self.log.info(event["message"])
- return {"Processing":
serialize(self.hook.describe_processing_job(self.config["ProcessingJobName"]))}
+ self.processing_job = {
+ "Processing":
serialize(self.hook.describe_processing_job(self.config["ProcessingJobName"]))
+ }
+ return self.processing_job
+
+ def get_openlineage_facets_on_complete(self, task_instance):
+ """Returns OpenLineage data gathered from SageMaker's API response
saved by processing job."""
+ from airflow.providers.openlineage.extractors.base import
OperatorLineage
+
+ inputs, outputs = [], []
+ try:
+ inputs, outputs = self._get_s3_datasets(
+
processing_inputs=self.processing_job["Processing"]["ProcessingInputs"],
+
processing_outputs=self.processing_job["Processing"]["ProcessingOutputConfig"]["Outputs"],
+ )
+ except KeyError:
+ self.log.exception("Could not find input/output information in
Xcom.")
+
+ return OperatorLineage(
+ inputs=inputs,
+ outputs=outputs,
+ )
+
+ def _get_s3_datasets(self, processing_inputs, processing_outputs):
Review Comment:
Renamed to `_extract_s3_dataset_identifiers`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]