amoghrajesh commented on code in PR #46020:
URL: https://github.com/apache/airflow/pull/46020#discussion_r1931994485


##########
task_sdk/src/airflow/sdk/execution_time/task_runner.py:
##########
@@ -501,26 +503,39 @@ def run(ti: RuntimeTaskInstance, log: Logger):
         # TODO: Get a real context object
         ti.hostname = get_hostname()
         ti.task = ti.task.prepare_for_execution()
-        context = ti.get_template_context()
-        with set_current_context(context):
-            jinja_env = ti.task.dag.get_template_env()
-            ti.task = ti.render_templates(context=context, jinja_env=jinja_env)
-            result = _execute_task(context, ti.task)
-
-        _push_xcom_if_needed(result, ti)
-
-        task_outlets, outlet_events = _process_outlets(context, 
ti.task.outlets)
-
-        # TODO: Get things from _execute_task_with_callbacks
-        #   - Clearing XCom
-        #   - Update RTIF
-        #   - Pre Execute
-        #   etc
-        msg = SucceedTask(
-            end_date=datetime.now(tz=timezone.utc),
-            task_outlets=task_outlets,
-            outlet_events=outlet_events,
-        )
+        if ti.task.inlets or ti.task.outlets:
+            inlets = [asset.asprofile() for asset in ti.task.inlets if 
isinstance(asset, Asset)]
+            outlets = [asset.asprofile() for asset in ti.task.outlets if 
isinstance(asset, Asset)]
+            
SUPERVISOR_COMMS.send_request(msg=RuntimeCheckOnTask(inlets=inlets, 
outlets=outlets), log=log)  # type: ignore
+            msg = SUPERVISOR_COMMS.get_message()  # type: ignore
+
+        if isinstance(msg, OKResponse) and not msg.ok:
+            log.info("Runtime checks failed for task, marking task as 
failed..")
+            msg = TaskState(
+                state=TerminalTIState.FAILED,
+                end_date=datetime.now(tz=timezone.utc),
+            )
+        else:
+            context = ti.get_template_context()
+            with set_current_context(context):
+                jinja_env = ti.task.dag.get_template_env()
+                ti.task = ti.render_templates(context=context, 
jinja_env=jinja_env)
+                result = _execute_task(context, ti.task)
+
+            _push_xcom_if_needed(result, ti)
+
+            task_outlets, outlet_events = _process_outlets(context, 
ti.task.outlets)
+
+            # TODO: Get things from _execute_task_with_callbacks
+            #   - Clearing XCom
+            #   - Update RTIF
+            #   - Pre Execute
+            #   etc

Review Comment:
   Yeah, copy paste error. Clearing xcom is also done. 



-- 
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]

Reply via email to