kacpermuda commented on code in PR #49040:
URL: https://github.com/apache/airflow/pull/49040#discussion_r2039524371
##########
providers/openlineage/src/airflow/providers/openlineage/plugins/listener.py:
##########
@@ -457,6 +474,60 @@ def on_failure():
self._execute(on_failure, "on_failure", use_fork=True)
+ def _on_task_instance_manual_state_change(
+ self,
+ ti: TaskInstance,
+ dagrun: DagRun,
+ ti_state: TaskInstanceState,
+ error: None | str | BaseException = None,
+ ) -> None:
+ self.log.debug("`_on_task_instance_manual_state_change` was called
with state: `%s`.", ti_state)
+ end_date = timezone.utcnow()
+
+ @print_warning(self.log)
+ def on_state_change():
+ date = dagrun.logical_date or dagrun.run_after
+ parent_run_id = self.adapter.build_dag_run_id(
+ dag_id=dagrun.dag_id,
+ logical_date=date,
+ clear_number=dagrun.clear_number,
+ )
+
+ task_uuid = self.adapter.build_task_instance_run_id(
+ dag_id=dagrun.dag_id,
+ task_id=ti.task_id,
+ try_number=ti.try_number,
+ logical_date=date,
+ map_index=ti.map_index,
+ )
+
+ adapter_kwargs = {
+ "run_id": task_uuid,
+ "job_name": get_job_name(ti),
+ "parent_job_name": dagrun.dag_id,
+ "parent_run_id": parent_run_id,
+ "end_time": end_date.isoformat(),
+ "task": OperatorLineage(),
+ "run_facets": get_airflow_debug_facet(),
+ }
+
+ if ti_state == TaskInstanceState.FAILED:
+ event_type = RunState.FAIL.value.lower()
+ redacted_event = self.adapter.fail_task(**adapter_kwargs,
error=error)
+ elif ti_state == TaskInstanceState.SUCCESS:
+ event_type = RunState.COMPLETE.value.lower()
+ redacted_event = self.adapter.complete_task(**adapter_kwargs)
+ else:
+ raise ValueError(f"Unsupported ti_state: `{ti_state}`.")
Review Comment:
It's just a safety check, but yes, it should never happen.
--
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]