kaxil commented on code in PR #65958:
URL: https://github.com/apache/airflow/pull/65958#discussion_r3307758236
##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -533,6 +535,25 @@ def _child_exec_main():
_fork_main(child_requests, child_stdout, child_stderr, 0, _subprocess_main)
+class ProcessTracker(Protocol):
Review Comment:
This new `ProcessTracker` Protocol promises support for `subprocess.Popen`
alongside `psutil.Process` (per the docstring), but the rest of the file still
catches psutil-only exceptions:
- `_send_kill_signal` at L991 catches `psutil.NoSuchProcess`.
- `_check_subprocess_exit` at L1069 catches `psutil.TimeoutExpired`.
A `Popen`-backed coordinator child raises `ProcessLookupError` /
`subprocess.TimeoutExpired`, which would propagate uncaught and break the
SIGINT -> SIGTERM -> SIGKILL escalation. Consistent with the "maybe avoid the
psutil.Process object altogether" direction from
https://github.com/apache/airflow/pull/65958#discussion_r3296624213 -- either
wrap `Popen` in `psutil.Process(p.pid)` at construction, or broaden these
`except` clauses.
##########
airflow-core/src/airflow/executors/base_executor.py:
##########
@@ -652,11 +652,10 @@ def run_workload(
if isinstance(workload, ExecuteTask):
from airflow.sdk.execution_time.supervisor import supervise_task
+ from airflow.sdk.execution_time.workloads.task import
TaskInstanceDTO as SDKTaskInstanceDTO
- # workload.ti is a TaskInstanceDTO which duck-types as
TaskInstance.
- # TODO: Create a protocol for this.
return supervise_task(
- ti=workload.ti, # type: ignore[arg-type]
+ ti=SDKTaskInstanceDTO.model_validate(workload.ti,
from_attributes=True),
Review Comment:
`SDKTaskInstanceDTO.model_validate(workload.ti, from_attributes=True)`
re-validates fields that are already validated executor-side, on every
workload. The two DTOs are kept identical by a prek hook (per the file
docstrings), so this is pure overhead on a hot path that runs in every
supervisor invocation across local/k8s/celery executors. Prefer
`model_construct` or `cast` -- or better, have `supervise_task` accept the
executor-side type directly (they share the base).
##########
task-sdk/src/airflow/sdk/coordinators/java/__init__.py:
##########
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Java runtime coordinator for the Apache Airflow Task SDK."""
+
+from __future__ import annotations
+
+from airflow.sdk.coordinators.java.coordinator import JavaCoordinator
+
Review Comment:
nit: the module docstring (L17) is the first thing `pydoc
airflow.sdk.coordinators.java` shows, and right now it doesn't mention
`JavaCoordinator` at all. A one-line "see :class:`JavaCoordinator` for
configuration" pointer would close the loop.
--
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]