You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2026/06/14 10:20:20 UTC

[PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

potiuk opened a new pull request, #68533:
URL: https://github.com/apache/airflow/pull/68533

   `PythonVirtualenvOperator` / `ExternalPythonOperator` tests dominate the `Providers[standard]` suite (~450s of ~510s) because they build real virtualenvs, yet they were forced to run **serially**: they were marked `db_test`, so pytest-xdist could not parallelize them.
   
   Their only real DB coupling was the test harness, not the metadata DB — but the venv subprocess reconnects to the supervisor over a socket, so they can't use the plain `run_task` mock (no real socket → `OSError: Socket operation on non-socket`).
   
   This adds `tests_common.test_utils.in_process_taskrun.run_task_no_db`, which drives `InProcessTestSupervisor`'s **real socketpair** with an **in-memory stub Execution-API client** — so a venv operator runs with a working supervisor socket and no metadata DB. `TestPythonVirtualenvOperator` and `TestExternalPythonOperator` are converted onto it via a `_DBFreeVenvRun` mixin and **drop their `db_test` mark**, so they parallelize under `--skip-db-tests --use-xdist`. The module-level `db_test`/`need_serialized_dag` mark moves to the remaining DB classes; branch venv classes keep `db_test` (their multi-task state assertions need a real DAG run).
   
   **Measured:** the two classes run ~3× faster at `-n 4` (157 tests, 89s vs ~266s serial); larger gains at CI worker counts. Validated DB-free runs (External 43, Virtualenv 114, 0 failures) and confirmed no regression in the remaining DB classes.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 4.8)
   
   Generated-by: Claude Code (Opus 4.8) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #68533:
URL: https://github.com/apache/airflow/pull/68533#issuecomment-4704779473

   Also to add @kaxil -> the way it was done before was in order to only change the test code - so the trade-off here is that we need to modify "task-sdk"  - new null-by-default client and likely we will also have to add some compat code.


-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #68533:
URL: https://github.com/apache/airflow/pull/68533#discussion_r3411154296


##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,190 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This helper drives the *real* ``InProcessTestSupervisor`` socketpair machinery
+(created explicitly for VirtualEnv operators) but serves every Execution-API call
+from an in-memory stub instead of the DB-backed ``InProcessExecutionAPI`` — so the
+subprocess gets a working supervisor socket without touching the metadata DB. The
+result: such tests need no ``@pytest.mark.db_test`` and run under xdist.
+"""
+
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any
+from unittest import mock
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.types import Operator
+
+
+class _StubXComs:
+    """Dict-backed stand-in for ``client.xcoms`` (the only resource that must round-trip)."""
+
+    def __init__(self) -> None:
+        self.store: dict[tuple, Any] = {}
+
+    def set(self, dag_id, run_id, task_id, key, value, map_index, **kwargs):
+        self.store[(dag_id, run_id, task_id, key, map_index)] = value
+
+    def get(self, dag_id, run_id, task_id, key, map_index, include_prior_dates=False):
+        from airflow.sdk.api.datamodels._generated import XComResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if (dag_id, run_id, task_id, key, map_index) in self.store:
+            return XComResponse(key=key, value=self.store[(dag_id, run_id, task_id, key, map_index)])
+        return ErrorResponse(error=ErrorType.XCOM_NOT_FOUND)
+
+    def delete(self, *args, **kwargs):
+        return None
+
+
+class _StubVariables:
+    def __init__(self, values: dict[str, Any] | None = None) -> None:
+        self.store = dict(values or {})
+
+    def get(self, key):
+        from airflow.sdk.api.datamodels._generated import VariableResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if key in self.store:
+            return VariableResponse(key=key, value=self.store[key])
+        return ErrorResponse(error=ErrorType.VARIABLE_NOT_FOUND)
+
+    def set(self, key, value, description=None):
+        self.store[key] = value
+
+    def delete(self, key):
+        self.store.pop(key, None)
+        return None
+
+
+class _StubConnections:
+    def __init__(self, conns: dict[str, Any] | None = None) -> None:
+        self.store = dict(conns or {})
+
+    def get(self, conn_id):
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if conn_id in self.store:
+            return self.store[conn_id]
+        return ErrorResponse(error=ErrorType.CONNECTION_NOT_FOUND)
+
+
+class _InMemoryExecutionClient:

Review Comment:
   Done — collapsed into a real `Client(dry_run=True)` whose `MockTransport` remembers XCom writes in a dict (replaying the run-context, since `noop_handler`'s fake `TIRunContext` no longer validates against the live schema). The three `_Stub*` classes are gone, and with a real client there's no `MagicMock`/`__getattr__` fallback either, so the "passes against a mock" footgun is removed.
   
   ---
   Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting



##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,190 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This helper drives the *real* ``InProcessTestSupervisor`` socketpair machinery
+(created explicitly for VirtualEnv operators) but serves every Execution-API call
+from an in-memory stub instead of the DB-backed ``InProcessExecutionAPI`` — so the
+subprocess gets a working supervisor socket without touching the metadata DB. The
+result: such tests need no ``@pytest.mark.db_test`` and run under xdist.
+"""
+
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any
+from unittest import mock
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.types import Operator
+
+
+class _StubXComs:
+    """Dict-backed stand-in for ``client.xcoms`` (the only resource that must round-trip)."""
+
+    def __init__(self) -> None:
+        self.store: dict[tuple, Any] = {}
+
+    def set(self, dag_id, run_id, task_id, key, value, map_index, **kwargs):
+        self.store[(dag_id, run_id, task_id, key, map_index)] = value
+
+    def get(self, dag_id, run_id, task_id, key, map_index, include_prior_dates=False):
+        from airflow.sdk.api.datamodels._generated import XComResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if (dag_id, run_id, task_id, key, map_index) in self.store:
+            return XComResponse(key=key, value=self.store[(dag_id, run_id, task_id, key, map_index)])
+        return ErrorResponse(error=ErrorType.XCOM_NOT_FOUND)
+
+    def delete(self, *args, **kwargs):
+        return None
+
+
+class _StubVariables:
+    def __init__(self, values: dict[str, Any] | None = None) -> None:
+        self.store = dict(values or {})
+
+    def get(self, key):
+        from airflow.sdk.api.datamodels._generated import VariableResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if key in self.store:
+            return VariableResponse(key=key, value=self.store[key])
+        return ErrorResponse(error=ErrorType.VARIABLE_NOT_FOUND)
+
+    def set(self, key, value, description=None):
+        self.store[key] = value
+
+    def delete(self, key):
+        self.store.pop(key, None)
+        return None
+
+
+class _StubConnections:
+    def __init__(self, conns: dict[str, Any] | None = None) -> None:
+        self.store = dict(conns or {})
+
+    def get(self, conn_id):
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if conn_id in self.store:
+            return self.store[conn_id]
+        return ErrorResponse(error=ErrorType.CONNECTION_NOT_FOUND)
+
+
+class _InMemoryExecutionClient:
+    """In-memory stand-in for the Task SDK execution-API ``Client`` (no metadata DB)."""
+
+    def __init__(self, ti_context, variables=None, connections=None) -> None:
+        self.task_instances = mock.MagicMock(name="stub.task_instances")
+        self.task_instances.start.return_value = ti_context
+        self.xcoms = _StubXComs()
+        self.variables = _StubVariables(variables)
+        self.connections = _StubConnections(connections)
+
+    def __getattr__(self, name):
+        # Resources we don't model (assets, dag_runs, hitl, task_store, ...) are
+        # absorbed — venv operator tests don't exercise them.
+        if name.startswith("__"):
+            raise AttributeError(name)
+        return mock.MagicMock(name=f"stub_client.{name}")
+
+
+class TaskRunResultNoDB:

Review Comment:
   Done — `run_task_no_db` now returns the stock `TaskRunResult` (plus the pushed-XCom dict for assertions); `TaskRunResultNoDB` is removed.
   
   ---
   Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting



##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,190 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This helper drives the *real* ``InProcessTestSupervisor`` socketpair machinery
+(created explicitly for VirtualEnv operators) but serves every Execution-API call
+from an in-memory stub instead of the DB-backed ``InProcessExecutionAPI`` — so the
+subprocess gets a working supervisor socket without touching the metadata DB. The
+result: such tests need no ``@pytest.mark.db_test`` and run under xdist.
+"""
+
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any
+from unittest import mock
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.types import Operator
+
+
+class _StubXComs:
+    """Dict-backed stand-in for ``client.xcoms`` (the only resource that must round-trip)."""
+
+    def __init__(self) -> None:
+        self.store: dict[tuple, Any] = {}
+
+    def set(self, dag_id, run_id, task_id, key, value, map_index, **kwargs):
+        self.store[(dag_id, run_id, task_id, key, map_index)] = value
+
+    def get(self, dag_id, run_id, task_id, key, map_index, include_prior_dates=False):
+        from airflow.sdk.api.datamodels._generated import XComResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if (dag_id, run_id, task_id, key, map_index) in self.store:
+            return XComResponse(key=key, value=self.store[(dag_id, run_id, task_id, key, map_index)])
+        return ErrorResponse(error=ErrorType.XCOM_NOT_FOUND)
+
+    def delete(self, *args, **kwargs):
+        return None
+
+
+class _StubVariables:
+    def __init__(self, values: dict[str, Any] | None = None) -> None:
+        self.store = dict(values or {})
+
+    def get(self, key):
+        from airflow.sdk.api.datamodels._generated import VariableResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if key in self.store:
+            return VariableResponse(key=key, value=self.store[key])
+        return ErrorResponse(error=ErrorType.VARIABLE_NOT_FOUND)
+
+    def set(self, key, value, description=None):
+        self.store[key] = value
+
+    def delete(self, key):
+        self.store.pop(key, None)
+        return None
+
+
+class _StubConnections:
+    def __init__(self, conns: dict[str, Any] | None = None) -> None:
+        self.store = dict(conns or {})
+
+    def get(self, conn_id):
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if conn_id in self.store:
+            return self.store[conn_id]
+        return ErrorResponse(error=ErrorType.CONNECTION_NOT_FOUND)
+
+
+class _InMemoryExecutionClient:
+    """In-memory stand-in for the Task SDK execution-API ``Client`` (no metadata DB)."""
+
+    def __init__(self, ti_context, variables=None, connections=None) -> None:
+        self.task_instances = mock.MagicMock(name="stub.task_instances")
+        self.task_instances.start.return_value = ti_context
+        self.xcoms = _StubXComs()
+        self.variables = _StubVariables(variables)
+        self.connections = _StubConnections(connections)
+
+    def __getattr__(self, name):
+        # Resources we don't model (assets, dag_runs, hitl, task_store, ...) are
+        # absorbed — venv operator tests don't exercise them.
+        if name.startswith("__"):
+            raise AttributeError(name)
+        return mock.MagicMock(name=f"stub_client.{name}")
+
+
+class TaskRunResultNoDB:
+    """Result of :func:`run_task_no_db`, mirroring the ``run_task`` fixture surface."""
+
+    def __init__(self, result, client: _InMemoryExecutionClient, ti) -> None:
+        self._result = result
+        self.client = client
+        self._ti = ti
+
+    @property
+    def state(self):
+        return self._result.state
+
+    @property
+    def error(self):
+        return self._result.error
+
+    @property
+    def msg(self):
+        return self._result.msg
+
+    def xcom_get(
+        self,
+        key: str = "return_value",
+        task_id: str | None = None,
+        dag_id: str | None = None,
+        run_id: str | None = None,
+        map_index: int | None = None,
+    ) -> Any:
+        task_id = task_id or self._ti.task_id
+        dag_id = dag_id or self._ti.dag_id
+        run_id = run_id or self._ti.run_id
+        map_index = map_index if map_index is not None else self._ti.map_index
+        return self.client.xcoms.store.get((dag_id, run_id, task_id, key, map_index))
+
+
+def run_task_no_db(
+    task: Operator,
+    create_runtime_ti: Callable[..., Any],
+    *,
+    logical_date: Any | None = None,
+    variables: dict[str, Any] | None = None,
+    connections: dict[str, Any] | None = None,
+) -> TaskRunResultNoDB:
+    """Run *task* DB-free through the real-socket in-process supervisor."""
+    from uuid6 import uuid7
+
+    from airflow.sdk.api.datamodels._generated import TaskInstance as TaskInstanceDTO
+    from airflow.sdk.execution_time.supervisor import InProcessTestSupervisor
+
+    ti_kwargs = {} if logical_date is None else {"logical_date": logical_date}
+    rti = create_runtime_ti(task, **ti_kwargs)
+    ti_context = rti._ti_context_from_server
+
+    # `start()` model_dumps `what`; the plain DTO dumps cleanly, whereas the
+    # operator-laden RuntimeTaskInstance trips forward refs (RetryPolicy/WeightRuleParam).
+    what = TaskInstanceDTO(
+        id=rti.id,
+        task_id=rti.task_id,
+        dag_id=rti.dag_id,
+        run_id=rti.run_id,
+        try_number=rti.try_number,
+        map_index=rti.map_index,
+        dag_version_id=uuid7(),
+        queue="default",
+    )
+
+    client = _InMemoryExecutionClient(ti_context, variables=variables, connections=connections)
+
+    class _StubBackendSupervisor(InProcessTestSupervisor):

Review Comment:
   Done — added an optional `client=` to `start()`/`run_task_in_process`; `run_task_no_db` injects through it, so the per-call subclass is gone on `main` (kept only as a compat shim for Task SDKs that have `InProcessTestSupervisor` but not the param yet).
   
   ---
   Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting



-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #68533:
URL: https://github.com/apache/airflow/pull/68533#discussion_r3411244849


##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,164 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This drives the *real* ``InProcessTestSupervisor`` (its socketpair machinery is
+created specifically for VirtualEnv operators) but injects a **dry-run Execution-API
+client** instead of the DB-backed in-process API server, so the subprocess gets a
+working supervisor socket without touching the metadata DB. Tests using it need no
+``@pytest.mark.db_test`` and run under xdist.
+
+The client is the real ``Client(dry_run=True)`` (which already fakes the run
+context and no-ops heartbeats via ``noop_handler``), with the discarding transport
+swapped for one that *remembers* XCom writes in an in-memory dict — exposed as
+``client.pushed_xcoms`` so tests can assert what a task pushed.
+
+Airflow 3+ only (``InProcessTestSupervisor`` does not exist on 2.x); callers must
+gate on ``AIRFLOW_V_3_0_PLUS``.
+"""
+
+from __future__ import annotations
+
+import inspect
+import json
+from typing import TYPE_CHECKING, Any
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.api.client import Client
+    from airflow.sdk.execution_time.supervisor import TaskRunResult
+    from airflow.sdk.types import Operator
+
+# XCom is the only resource that must round-trip; the run-context is fed back from the
+# (valid) ti_context the test built, and everything else (heartbeat, state updates) is the
+# stock ``noop_handler``. (``noop_handler``'s own run-context is stale vs the live schema.)
+_XCOM_PATH_PARTS = 5  # /xcoms/{dag_id}/{run_id}/{task_id}/{key}
+
+
+def _remembering_handler(store: dict, run_context_json: bytes) -> Callable:
+    """A dry-run transport handler: valid run-context + XCom round-trip from ``store``, else no-op."""
+    import httpx
+
+    from airflow.sdk.api.client import noop_handler

Review Comment:
   I think it will have to be moved too compat.



##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,164 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This drives the *real* ``InProcessTestSupervisor`` (its socketpair machinery is
+created specifically for VirtualEnv operators) but injects a **dry-run Execution-API
+client** instead of the DB-backed in-process API server, so the subprocess gets a
+working supervisor socket without touching the metadata DB. Tests using it need no
+``@pytest.mark.db_test`` and run under xdist.
+
+The client is the real ``Client(dry_run=True)`` (which already fakes the run
+context and no-ops heartbeats via ``noop_handler``), with the discarding transport
+swapped for one that *remembers* XCom writes in an in-memory dict — exposed as
+``client.pushed_xcoms`` so tests can assert what a task pushed.
+
+Airflow 3+ only (``InProcessTestSupervisor`` does not exist on 2.x); callers must
+gate on ``AIRFLOW_V_3_0_PLUS``.
+"""
+
+from __future__ import annotations
+
+import inspect
+import json
+from typing import TYPE_CHECKING, Any
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.api.client import Client
+    from airflow.sdk.execution_time.supervisor import TaskRunResult
+    from airflow.sdk.types import Operator
+
+# XCom is the only resource that must round-trip; the run-context is fed back from the
+# (valid) ti_context the test built, and everything else (heartbeat, state updates) is the
+# stock ``noop_handler``. (``noop_handler``'s own run-context is stale vs the live schema.)
+_XCOM_PATH_PARTS = 5  # /xcoms/{dag_id}/{run_id}/{task_id}/{key}
+
+
+def _remembering_handler(store: dict, run_context_json: bytes) -> Callable:
+    """A dry-run transport handler: valid run-context + XCom round-trip from ``store``, else no-op."""
+    import httpx
+
+    from airflow.sdk.api.client import noop_handler

Review Comment:
   I think it will have to be moved to compat.



-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #68533:
URL: https://github.com/apache/airflow/pull/68533#discussion_r3442178496


##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,145 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This drives the *real* ``InProcessTestSupervisor`` (its socketpair machinery is
+created specifically for VirtualEnv operators) but injects a **dry-run Execution-API
+client** instead of the DB-backed in-process API server, so the subprocess gets a
+working supervisor socket without touching the metadata DB. Tests using it need no
+``@pytest.mark.db_test`` and run under xdist.
+
+The client is the real ``Client(dry_run=True)`` (which already fakes the run
+context and no-ops heartbeats via ``noop_handler``), with the discarding transport
+swapped for one that *remembers* XCom writes in an in-memory dict — exposed as
+``client.pushed_xcoms`` so tests can assert what a task pushed.
+
+Requires the Task SDK ``run_task_in_process(..., client=)`` parameter (newer than
+Airflow 3.0/3.1, and absent on 2.x); callers must gate on its availability and fall
+back to a DB-backed path otherwise.
+"""
+
+from __future__ import annotations
+
+import json
+from typing import TYPE_CHECKING, Any
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.api.client import Client
+    from airflow.sdk.execution_time.supervisor import TaskRunResult
+    from airflow.sdk.types import Operator
+
+# XCom is the only resource that must round-trip; the run-context is fed back from the
+# (valid) ti_context the test built, and everything else (heartbeat, state updates) is the
+# stock ``noop_handler``. (``noop_handler``'s own run-context is stale vs the live schema.)
+_XCOM_PATH_PARTS = 5  # /xcoms/{dag_id}/{run_id}/{task_id}/{key}
+
+
+def _remembering_handler(store: dict, run_context_json: bytes) -> Callable:
+    """A dry-run transport handler: valid run-context + XCom round-trip from ``store``, else no-op."""
+    import httpx
+
+    from airflow.sdk.api.client import noop_handler
+
+    def handler(request: httpx.Request) -> httpx.Response:
+        path = request.url.path
+        if path.startswith("/task-instances/") and path.endswith("/run"):
+            return httpx.Response(200, content=run_context_json)
+        parts = path.strip("/").split("/")
+        if len(parts) == _XCOM_PATH_PARTS and parts[0] == "xcoms":
+            dag_id, run_id, task_id, key = parts[1:]
+            sig = (dag_id, run_id, task_id, key)
+            if request.method == "POST":
+                store[sig] = json.loads(request.content or b"null")
+                return httpx.Response(201, json={"ok": True})
+            if request.method == "GET":
+                if sig in store:
+                    return httpx.Response(200, json={"key": key, "value": store[sig]})
+                return httpx.Response(404, json={"detail": "XCom not found"})
+        return noop_handler(request)
+
+    return handler
+
+
+def build_in_memory_client(ti_context) -> Client:
+    """A real ``Client(dry_run=True)`` that remembers XCom writes (no DB, no network).
+
+    ``ti_context`` (a ``TIRunContext``) is replayed for the task-start request. Pushed XCom
+    values are exposed as ``client.pushed_xcoms`` keyed by ``(dag_id, run_id, task_id, key)``.
+    """
+    import httpx

Review Comment:
   `import httpx` (here and L60) and `from uuid6 import uuid7` (L122) are unconditional third-party deps present on every supported version, so they can move to the module top. Worth keeping these separate from the `airflow.sdk.*` imports you're moving to the compat shim in the other thread: those need version guarding, these don't.



##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,145 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This drives the *real* ``InProcessTestSupervisor`` (its socketpair machinery is
+created specifically for VirtualEnv operators) but injects a **dry-run Execution-API
+client** instead of the DB-backed in-process API server, so the subprocess gets a
+working supervisor socket without touching the metadata DB. Tests using it need no
+``@pytest.mark.db_test`` and run under xdist.
+
+The client is the real ``Client(dry_run=True)`` (which already fakes the run
+context and no-ops heartbeats via ``noop_handler``), with the discarding transport
+swapped for one that *remembers* XCom writes in an in-memory dict — exposed as
+``client.pushed_xcoms`` so tests can assert what a task pushed.
+
+Requires the Task SDK ``run_task_in_process(..., client=)`` parameter (newer than
+Airflow 3.0/3.1, and absent on 2.x); callers must gate on its availability and fall
+back to a DB-backed path otherwise.
+"""
+
+from __future__ import annotations
+
+import json
+from typing import TYPE_CHECKING, Any
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.api.client import Client
+    from airflow.sdk.execution_time.supervisor import TaskRunResult
+    from airflow.sdk.types import Operator
+
+# XCom is the only resource that must round-trip; the run-context is fed back from the
+# (valid) ti_context the test built, and everything else (heartbeat, state updates) is the
+# stock ``noop_handler``. (``noop_handler``'s own run-context is stale vs the live schema.)
+_XCOM_PATH_PARTS = 5  # /xcoms/{dag_id}/{run_id}/{task_id}/{key}
+
+
+def _remembering_handler(store: dict, run_context_json: bytes) -> Callable:
+    """A dry-run transport handler: valid run-context + XCom round-trip from ``store``, else no-op."""
+    import httpx
+
+    from airflow.sdk.api.client import noop_handler
+
+    def handler(request: httpx.Request) -> httpx.Response:
+        path = request.url.path
+        if path.startswith("/task-instances/") and path.endswith("/run"):
+            return httpx.Response(200, content=run_context_json)
+        parts = path.strip("/").split("/")
+        if len(parts) == _XCOM_PATH_PARTS and parts[0] == "xcoms":
+            dag_id, run_id, task_id, key = parts[1:]
+            sig = (dag_id, run_id, task_id, key)
+            if request.method == "POST":
+                store[sig] = json.loads(request.content or b"null")

Review Comment:
   Minor: `request.content` is always non-empty here, so the `or b"null"` fallback is dead. A POST to `/xcoms/...` carries the serialized value, and even a `None` value serializes to `b"null"` rather than empty bytes. Can simplify to `json.loads(request.content)`.



-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #68533:
URL: https://github.com/apache/airflow/pull/68533#discussion_r3442178496


##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,145 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This drives the *real* ``InProcessTestSupervisor`` (its socketpair machinery is
+created specifically for VirtualEnv operators) but injects a **dry-run Execution-API
+client** instead of the DB-backed in-process API server, so the subprocess gets a
+working supervisor socket without touching the metadata DB. Tests using it need no
+``@pytest.mark.db_test`` and run under xdist.
+
+The client is the real ``Client(dry_run=True)`` (which already fakes the run
+context and no-ops heartbeats via ``noop_handler``), with the discarding transport
+swapped for one that *remembers* XCom writes in an in-memory dict — exposed as
+``client.pushed_xcoms`` so tests can assert what a task pushed.
+
+Requires the Task SDK ``run_task_in_process(..., client=)`` parameter (newer than
+Airflow 3.0/3.1, and absent on 2.x); callers must gate on its availability and fall
+back to a DB-backed path otherwise.
+"""
+
+from __future__ import annotations
+
+import json
+from typing import TYPE_CHECKING, Any
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.api.client import Client
+    from airflow.sdk.execution_time.supervisor import TaskRunResult
+    from airflow.sdk.types import Operator
+
+# XCom is the only resource that must round-trip; the run-context is fed back from the
+# (valid) ti_context the test built, and everything else (heartbeat, state updates) is the
+# stock ``noop_handler``. (``noop_handler``'s own run-context is stale vs the live schema.)
+_XCOM_PATH_PARTS = 5  # /xcoms/{dag_id}/{run_id}/{task_id}/{key}
+
+
+def _remembering_handler(store: dict, run_context_json: bytes) -> Callable:
+    """A dry-run transport handler: valid run-context + XCom round-trip from ``store``, else no-op."""
+    import httpx
+
+    from airflow.sdk.api.client import noop_handler
+
+    def handler(request: httpx.Request) -> httpx.Response:
+        path = request.url.path
+        if path.startswith("/task-instances/") and path.endswith("/run"):
+            return httpx.Response(200, content=run_context_json)
+        parts = path.strip("/").split("/")
+        if len(parts) == _XCOM_PATH_PARTS and parts[0] == "xcoms":
+            dag_id, run_id, task_id, key = parts[1:]
+            sig = (dag_id, run_id, task_id, key)
+            if request.method == "POST":
+                store[sig] = json.loads(request.content or b"null")
+                return httpx.Response(201, json={"ok": True})
+            if request.method == "GET":
+                if sig in store:
+                    return httpx.Response(200, json={"key": key, "value": store[sig]})
+                return httpx.Response(404, json={"detail": "XCom not found"})
+        return noop_handler(request)
+
+    return handler
+
+
+def build_in_memory_client(ti_context) -> Client:
+    """A real ``Client(dry_run=True)`` that remembers XCom writes (no DB, no network).
+
+    ``ti_context`` (a ``TIRunContext``) is replayed for the task-start request. Pushed XCom
+    values are exposed as ``client.pushed_xcoms`` keyed by ``(dag_id, run_id, task_id, key)``.
+    """
+    import httpx

Review Comment:
   `import httpx` (here and L60) and `from uuid6 import uuid7` (L122) are unconditional third-party deps present on every supported version, so they can move to the module top. Worth keeping these separate from the `airflow.sdk.*` imports you're moving to the compat shim in the other thread: those need version guarding, these don't.



-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #68533:
URL: https://github.com/apache/airflow/pull/68533


-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #68533:
URL: https://github.com/apache/airflow/pull/68533#discussion_r3409506360


##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,190 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This helper drives the *real* ``InProcessTestSupervisor`` socketpair machinery
+(created explicitly for VirtualEnv operators) but serves every Execution-API call
+from an in-memory stub instead of the DB-backed ``InProcessExecutionAPI`` — so the
+subprocess gets a working supervisor socket without touching the metadata DB. The
+result: such tests need no ``@pytest.mark.db_test`` and run under xdist.
+"""
+
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any
+from unittest import mock
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.types import Operator
+
+
+class _StubXComs:
+    """Dict-backed stand-in for ``client.xcoms`` (the only resource that must round-trip)."""
+
+    def __init__(self) -> None:
+        self.store: dict[tuple, Any] = {}
+
+    def set(self, dag_id, run_id, task_id, key, value, map_index, **kwargs):
+        self.store[(dag_id, run_id, task_id, key, map_index)] = value
+
+    def get(self, dag_id, run_id, task_id, key, map_index, include_prior_dates=False):
+        from airflow.sdk.api.datamodels._generated import XComResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if (dag_id, run_id, task_id, key, map_index) in self.store:
+            return XComResponse(key=key, value=self.store[(dag_id, run_id, task_id, key, map_index)])
+        return ErrorResponse(error=ErrorType.XCOM_NOT_FOUND)
+
+    def delete(self, *args, **kwargs):
+        return None
+
+
+class _StubVariables:
+    def __init__(self, values: dict[str, Any] | None = None) -> None:
+        self.store = dict(values or {})
+
+    def get(self, key):
+        from airflow.sdk.api.datamodels._generated import VariableResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if key in self.store:
+            return VariableResponse(key=key, value=self.store[key])
+        return ErrorResponse(error=ErrorType.VARIABLE_NOT_FOUND)
+
+    def set(self, key, value, description=None):
+        self.store[key] = value
+
+    def delete(self, key):
+        self.store.pop(key, None)
+        return None
+
+
+class _StubConnections:
+    def __init__(self, conns: dict[str, Any] | None = None) -> None:
+        self.store = dict(conns or {})
+
+    def get(self, conn_id):
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if conn_id in self.store:
+            return self.store[conn_id]
+        return ErrorResponse(error=ErrorType.CONNECTION_NOT_FOUND)
+
+
+class _InMemoryExecutionClient:

Review Comment:
   Most of this in-memory client already exists, just not collected in one place:
   
   - `Client(dry_run=True)` installs [`noop_handler`](https://github.com/apache/airflow/blob/06d4b1ea7d6e7795f1724662598e1f6885df0ac8/task-sdk/src/airflow/sdk/api/client.py#L1098), a no-network/no-DB client that already backs `InProcessTestSupervisor` (its `_api_client` builds the client with [`dry_run=True`](https://github.com/apache/airflow/blob/06d4b1ea7d6e7795f1724662598e1f6885df0ac8/task-sdk/src/airflow/sdk/api/client.py#L1168)). The only thing it lacks is remembering writes: `noop_handler` discards them ("It doesn't make sense for returning connections etc.").
   - `run_task` already round-trips XCom in-memory by spying `XCom.set`/`XCom.get_one` ([pytest_plugin.py](https://github.com/apache/airflow/blob/06d4b1ea7d6e7795f1724662598e1f6885df0ac8/devel-common/src/tests_common/pytest_plugin.py#L2731)), which is what `_StubXComs` re-implements.
   
   So the genuinely new capability is "a dry-run client that remembers." Teaching `noop_handler`/dry-run to round-trip from an in-memory dict would let this client and the three `_Stub*` classes collapse into the existing one instead of a test-only parallel.
   
   Separately, the `__getattr__` MagicMock fallback (L113) returns a MagicMock for any unmodeled resource (assets, dag_runs, task_store), so a future venv test that round-trips one of those would pass against a mock instead of real data. Raising on unmodeled names (keeping the `__`-dunder guard) makes that fail loudly.



##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,190 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This helper drives the *real* ``InProcessTestSupervisor`` socketpair machinery
+(created explicitly for VirtualEnv operators) but serves every Execution-API call
+from an in-memory stub instead of the DB-backed ``InProcessExecutionAPI`` — so the
+subprocess gets a working supervisor socket without touching the metadata DB. The
+result: such tests need no ``@pytest.mark.db_test`` and run under xdist.
+"""
+
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any
+from unittest import mock
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.types import Operator
+
+
+class _StubXComs:
+    """Dict-backed stand-in for ``client.xcoms`` (the only resource that must round-trip)."""
+
+    def __init__(self) -> None:
+        self.store: dict[tuple, Any] = {}
+
+    def set(self, dag_id, run_id, task_id, key, value, map_index, **kwargs):
+        self.store[(dag_id, run_id, task_id, key, map_index)] = value
+
+    def get(self, dag_id, run_id, task_id, key, map_index, include_prior_dates=False):
+        from airflow.sdk.api.datamodels._generated import XComResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if (dag_id, run_id, task_id, key, map_index) in self.store:
+            return XComResponse(key=key, value=self.store[(dag_id, run_id, task_id, key, map_index)])
+        return ErrorResponse(error=ErrorType.XCOM_NOT_FOUND)
+
+    def delete(self, *args, **kwargs):
+        return None
+
+
+class _StubVariables:
+    def __init__(self, values: dict[str, Any] | None = None) -> None:
+        self.store = dict(values or {})
+
+    def get(self, key):
+        from airflow.sdk.api.datamodels._generated import VariableResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if key in self.store:
+            return VariableResponse(key=key, value=self.store[key])
+        return ErrorResponse(error=ErrorType.VARIABLE_NOT_FOUND)
+
+    def set(self, key, value, description=None):
+        self.store[key] = value
+
+    def delete(self, key):
+        self.store.pop(key, None)
+        return None
+
+
+class _StubConnections:
+    def __init__(self, conns: dict[str, Any] | None = None) -> None:
+        self.store = dict(conns or {})
+
+    def get(self, conn_id):
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if conn_id in self.store:
+            return self.store[conn_id]
+        return ErrorResponse(error=ErrorType.CONNECTION_NOT_FOUND)
+
+
+class _InMemoryExecutionClient:
+    """In-memory stand-in for the Task SDK execution-API ``Client`` (no metadata DB)."""
+
+    def __init__(self, ti_context, variables=None, connections=None) -> None:
+        self.task_instances = mock.MagicMock(name="stub.task_instances")
+        self.task_instances.start.return_value = ti_context
+        self.xcoms = _StubXComs()
+        self.variables = _StubVariables(variables)
+        self.connections = _StubConnections(connections)
+
+    def __getattr__(self, name):
+        # Resources we don't model (assets, dag_runs, hitl, task_store, ...) are
+        # absorbed — venv operator tests don't exercise them.
+        if name.startswith("__"):
+            raise AttributeError(name)
+        return mock.MagicMock(name=f"stub_client.{name}")
+
+
+class TaskRunResultNoDB:
+    """Result of :func:`run_task_no_db`, mirroring the ``run_task`` fixture surface."""
+
+    def __init__(self, result, client: _InMemoryExecutionClient, ti) -> None:
+        self._result = result
+        self.client = client
+        self._ti = ti
+
+    @property
+    def state(self):
+        return self._result.state
+
+    @property
+    def error(self):
+        return self._result.error
+
+    @property
+    def msg(self):
+        return self._result.msg
+
+    def xcom_get(
+        self,
+        key: str = "return_value",
+        task_id: str | None = None,
+        dag_id: str | None = None,
+        run_id: str | None = None,
+        map_index: int | None = None,
+    ) -> Any:
+        task_id = task_id or self._ti.task_id
+        dag_id = dag_id or self._ti.dag_id
+        run_id = run_id or self._ti.run_id
+        map_index = map_index if map_index is not None else self._ti.map_index
+        return self.client.xcoms.store.get((dag_id, run_id, task_id, key, map_index))
+
+
+def run_task_no_db(
+    task: Operator,
+    create_runtime_ti: Callable[..., Any],
+    *,
+    logical_date: Any | None = None,
+    variables: dict[str, Any] | None = None,
+    connections: dict[str, Any] | None = None,
+) -> TaskRunResultNoDB:
+    """Run *task* DB-free through the real-socket in-process supervisor."""
+    from uuid6 import uuid7
+
+    from airflow.sdk.api.datamodels._generated import TaskInstance as TaskInstanceDTO
+    from airflow.sdk.execution_time.supervisor import InProcessTestSupervisor
+
+    ti_kwargs = {} if logical_date is None else {"logical_date": logical_date}
+    rti = create_runtime_ti(task, **ti_kwargs)
+    ti_context = rti._ti_context_from_server
+
+    # `start()` model_dumps `what`; the plain DTO dumps cleanly, whereas the
+    # operator-laden RuntimeTaskInstance trips forward refs (RetryPolicy/WeightRuleParam).
+    what = TaskInstanceDTO(
+        id=rti.id,
+        task_id=rti.task_id,
+        dag_id=rti.dag_id,
+        run_id=rti.run_id,
+        try_number=rti.try_number,
+        map_index=rti.map_index,
+        dag_version_id=uuid7(),
+        queue="default",
+    )
+
+    client = _InMemoryExecutionClient(ti_context, variables=variables, connections=connections)
+
+    class _StubBackendSupervisor(InProcessTestSupervisor):

Review Comment:
   The "override `_api_client` to skip the DB" seam is already an established pattern ([test_supervisor.py](https://github.com/apache/airflow/blob/06d4b1ea7d6e7795f1724662598e1f6885df0ac8/task-sdk/tests/task_sdk/execution_time/test_supervisor.py#L3441) does exactly this with a fake client), and [`run_task_in_process`](https://github.com/apache/airflow/blob/06d4b1ea7d6e7795f1724662598e1f6885df0ac8/task-sdk/src/airflow/sdk/execution_time/supervisor.py#L2181) already wraps `.start()`. Rather than a subclass per call, consider an optional `client=` param on `InProcessTestSupervisor.start()` (it currently hardcodes `client=cls._api_client(task.dag)` at [#L2038](https://github.com/apache/airflow/blob/06d4b1ea7d6e7795f1724662598e1f6885df0ac8/task-sdk/src/airflow/sdk/execution_time/supervisor.py#L2038)). Callers inject the in-memory client, the subclass goes away, and `run_task_no_db` becomes a thin wrapper over `run_task_in_process`.



##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,190 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This helper drives the *real* ``InProcessTestSupervisor`` socketpair machinery
+(created explicitly for VirtualEnv operators) but serves every Execution-API call
+from an in-memory stub instead of the DB-backed ``InProcessExecutionAPI`` — so the
+subprocess gets a working supervisor socket without touching the metadata DB. The
+result: such tests need no ``@pytest.mark.db_test`` and run under xdist.
+"""
+
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any
+from unittest import mock
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.types import Operator
+
+
+class _StubXComs:
+    """Dict-backed stand-in for ``client.xcoms`` (the only resource that must round-trip)."""
+
+    def __init__(self) -> None:
+        self.store: dict[tuple, Any] = {}
+
+    def set(self, dag_id, run_id, task_id, key, value, map_index, **kwargs):
+        self.store[(dag_id, run_id, task_id, key, map_index)] = value
+
+    def get(self, dag_id, run_id, task_id, key, map_index, include_prior_dates=False):
+        from airflow.sdk.api.datamodels._generated import XComResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if (dag_id, run_id, task_id, key, map_index) in self.store:
+            return XComResponse(key=key, value=self.store[(dag_id, run_id, task_id, key, map_index)])
+        return ErrorResponse(error=ErrorType.XCOM_NOT_FOUND)
+
+    def delete(self, *args, **kwargs):
+        return None
+
+
+class _StubVariables:
+    def __init__(self, values: dict[str, Any] | None = None) -> None:
+        self.store = dict(values or {})
+
+    def get(self, key):
+        from airflow.sdk.api.datamodels._generated import VariableResponse
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if key in self.store:
+            return VariableResponse(key=key, value=self.store[key])
+        return ErrorResponse(error=ErrorType.VARIABLE_NOT_FOUND)
+
+    def set(self, key, value, description=None):
+        self.store[key] = value
+
+    def delete(self, key):
+        self.store.pop(key, None)
+        return None
+
+
+class _StubConnections:
+    def __init__(self, conns: dict[str, Any] | None = None) -> None:
+        self.store = dict(conns or {})
+
+    def get(self, conn_id):
+        from airflow.sdk.exceptions import ErrorType
+        from airflow.sdk.execution_time.comms import ErrorResponse
+
+        if conn_id in self.store:
+            return self.store[conn_id]
+        return ErrorResponse(error=ErrorType.CONNECTION_NOT_FOUND)
+
+
+class _InMemoryExecutionClient:
+    """In-memory stand-in for the Task SDK execution-API ``Client`` (no metadata DB)."""
+
+    def __init__(self, ti_context, variables=None, connections=None) -> None:
+        self.task_instances = mock.MagicMock(name="stub.task_instances")
+        self.task_instances.start.return_value = ti_context
+        self.xcoms = _StubXComs()
+        self.variables = _StubVariables(variables)
+        self.connections = _StubConnections(connections)
+
+    def __getattr__(self, name):
+        # Resources we don't model (assets, dag_runs, hitl, task_store, ...) are
+        # absorbed — venv operator tests don't exercise them.
+        if name.startswith("__"):
+            raise AttributeError(name)
+        return mock.MagicMock(name=f"stub_client.{name}")
+
+
+class TaskRunResultNoDB:

Review Comment:
   This duplicates the existing [`TaskRunResult`](https://github.com/apache/airflow/blob/06d4b1ea7d6e7795f1724662598e1f6885df0ac8/task-sdk/src/airflow/sdk/execution_time/supervisor.py#L1953), which exposes the same `state`/`msg`/`error` and is exactly what `_StubBackendSupervisor.start()` returns (captured as `result` at L189). Only `xcom_get` is new. Returning the existing `TaskRunResult` plus a small xcom accessor avoids a second result type that has to be kept in sync with the first.



-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #68533:
URL: https://github.com/apache/airflow/pull/68533#issuecomment-4704756093

   Thanks @kaxil — all three make this much smaller, applied them:
   
   **`client=` on `start()`** — `InProcessTestSupervisor.start()` and `run_task_in_process()` now take an optional `client=`, defaulting to `cls._api_client(task.dag)` as before. `run_task_no_db` injects an in-memory client through it, so the per-call subclass is gone on `main`. (For released Task SDKs that have `InProcessTestSupervisor` but not the param yet, it falls back to overriding `_api_client` — kept only as a version-compat shim.)
   
   **Reuse the dry-run client** — dropped the three `_Stub*` classes. It's now a real `Client(dry_run=True)` whose `MockTransport` does exactly the "remembers writes" bit you described: round-trips XCom from an in-memory dict, delegating everything else to `noop_handler`. (I do replay the run-context explicitly rather than rely on `noop_handler`'s — its fake `TIRunContext` no longer validates against the live schema.) Since it's a real client, there's no `MagicMock`/`__getattr__` fallback anymore, so the "passes against a mock" footgun is gone too.
   
   **`TaskRunResult`** — `run_task_no_db` now returns the stock `TaskRunResult` plus the pushed-XCom dict; `TaskRunResultNoDB` is removed.
   
   Compat: on Airflow 2.x (no `InProcessTestSupervisor`) the venv classes fall back to the DB path and keep `db_test`.
   
   ---
   Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting


-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #68533:
URL: https://github.com/apache/airflow/pull/68533#discussion_r3411252172


##########
providers/standard/tests/unit/standard/operators/test_python.py:
##########
@@ -1072,8 +1085,9 @@ def test_context(self):
         def f(templates_dict):
             return templates_dict["ds"]
 
-        task = self.run_as_task(f, templates_dict={"ds": "{{ ds }}"})
-        assert task.templates_dict == {"ds": self.ds_templated}
+        # the callable receives (and returns) the rendered templates_dict value
+        ti = self.run_as_task(f, return_ti=True, templates_dict={"ds": "{{ ds }}"})
+        assert self._pull_xcom(ti) == self.ds_templated

Review Comment:
   Because when we use mocked *operations to db we cannot **realy** resolve the templates. That was one of the changes needed to mock those.



-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #68533:
URL: https://github.com/apache/airflow/pull/68533#discussion_r3448521071


##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,145 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This drives the *real* ``InProcessTestSupervisor`` (its socketpair machinery is
+created specifically for VirtualEnv operators) but injects a **dry-run Execution-API
+client** instead of the DB-backed in-process API server, so the subprocess gets a
+working supervisor socket without touching the metadata DB. Tests using it need no
+``@pytest.mark.db_test`` and run under xdist.
+
+The client is the real ``Client(dry_run=True)`` (which already fakes the run
+context and no-ops heartbeats via ``noop_handler``), with the discarding transport
+swapped for one that *remembers* XCom writes in an in-memory dict — exposed as
+``client.pushed_xcoms`` so tests can assert what a task pushed.
+
+Requires the Task SDK ``run_task_in_process(..., client=)`` parameter (newer than
+Airflow 3.0/3.1, and absent on 2.x); callers must gate on its availability and fall
+back to a DB-backed path otherwise.
+"""
+
+from __future__ import annotations
+
+import json
+from typing import TYPE_CHECKING, Any
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.api.client import Client
+    from airflow.sdk.execution_time.supervisor import TaskRunResult
+    from airflow.sdk.types import Operator
+
+# XCom is the only resource that must round-trip; the run-context is fed back from the
+# (valid) ti_context the test built, and everything else (heartbeat, state updates) is the
+# stock ``noop_handler``. (``noop_handler``'s own run-context is stale vs the live schema.)
+_XCOM_PATH_PARTS = 5  # /xcoms/{dag_id}/{run_id}/{task_id}/{key}
+
+
+def _remembering_handler(store: dict, run_context_json: bytes) -> Callable:
+    """A dry-run transport handler: valid run-context + XCom round-trip from ``store``, else no-op."""
+    import httpx
+
+    from airflow.sdk.api.client import noop_handler
+
+    def handler(request: httpx.Request) -> httpx.Response:
+        path = request.url.path
+        if path.startswith("/task-instances/") and path.endswith("/run"):
+            return httpx.Response(200, content=run_context_json)
+        parts = path.strip("/").split("/")
+        if len(parts) == _XCOM_PATH_PARTS and parts[0] == "xcoms":
+            dag_id, run_id, task_id, key = parts[1:]
+            sig = (dag_id, run_id, task_id, key)
+            if request.method == "POST":
+                store[sig] = json.loads(request.content or b"null")

Review Comment:
   Done in 1ce60b1 — you're right, `request.content` is always populated here (a `None` value still serializes to `b"null"`), so the fallback was dead. Simplified to `json.loads(request.content)`.
   
   ---
   Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting



-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #68533:
URL: https://github.com/apache/airflow/pull/68533#issuecomment-4704898449

   > One comment to this PR - I remember back when VirtualEnvCaching was added that we made it a way that all tests use a cached Venv - have no oversight - is this still true? Or do we "waste" time in the venv tests because the venv is re-installed multiple times?
   
   That's a good question @jscheffl  -the code is still there:
   
   ```
       @staticmethod
       def default_kwargs(*, python_version=DEFAULT_PYTHON_VERSION, **kwargs):
           kwargs["python_version"] = python_version
           if "do_not_use_caching" in kwargs:
               kwargs.pop("do_not_use_caching")
           else:
               # Caching by default makes the tests run faster except few cases we want to test with regular venv
               if "venv_cache_path" not in kwargs:
                   kwargs["venv_cache_path"] = venv_cache_path
           return kwargs
   ```
   
   It worked fine (one temp cache folder for db_tests and one-per-worker in xdist. But I noticed we never delete those - which might cause local  venv bloat. Added ther right finalisation.


-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #68533:
URL: https://github.com/apache/airflow/pull/68533#discussion_r3411202603


##########
providers/standard/tests/unit/standard/operators/test_python.py:
##########
@@ -1072,8 +1085,9 @@ def test_context(self):
         def f(templates_dict):
             return templates_dict["ds"]
 
-        task = self.run_as_task(f, templates_dict={"ds": "{{ ds }}"})
-        assert task.templates_dict == {"ds": self.ds_templated}
+        # the callable receives (and returns) the rendered templates_dict value
+        ti = self.run_as_task(f, return_ti=True, templates_dict={"ds": "{{ ds }}"})
+        assert self._pull_xcom(ti) == self.ds_templated

Review Comment:
   Why this change? The original checked if templates_dict attribute was rendered and the new check verifies what the callable returned via xcom. I dont think these are equivalent? 



##########
devel-common/src/tests_common/test_utils/in_process_taskrun.py:
##########
@@ -0,0 +1,164 @@
+# 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.
+"""DB-free, xdist-safe execution of a task through a *real* supervisor socket.
+
+`run_task` (in ``pytest_plugin``) mocks supervisor comms entirely in-process and
+has **no real socket**, so operators that spawn a subprocess which re-connects to
+the supervisor — ``PythonVirtualenvOperator``, ``ExternalPythonOperator``,
+``run_as_user`` — fail there with ``OSError: Socket operation on non-socket``.
+
+This drives the *real* ``InProcessTestSupervisor`` (its socketpair machinery is
+created specifically for VirtualEnv operators) but injects a **dry-run Execution-API
+client** instead of the DB-backed in-process API server, so the subprocess gets a
+working supervisor socket without touching the metadata DB. Tests using it need no
+``@pytest.mark.db_test`` and run under xdist.
+
+The client is the real ``Client(dry_run=True)`` (which already fakes the run
+context and no-ops heartbeats via ``noop_handler``), with the discarding transport
+swapped for one that *remembers* XCom writes in an in-memory dict — exposed as
+``client.pushed_xcoms`` so tests can assert what a task pushed.
+
+Airflow 3+ only (``InProcessTestSupervisor`` does not exist on 2.x); callers must
+gate on ``AIRFLOW_V_3_0_PLUS``.
+"""
+
+from __future__ import annotations
+
+import inspect
+import json
+from typing import TYPE_CHECKING, Any
+
+if TYPE_CHECKING:
+    from collections.abc import Callable
+
+    from airflow.sdk.api.client import Client
+    from airflow.sdk.execution_time.supervisor import TaskRunResult
+    from airflow.sdk.types import Operator
+
+# XCom is the only resource that must round-trip; the run-context is fed back from the
+# (valid) ti_context the test built, and everything else (heartbeat, state updates) is the
+# stock ``noop_handler``. (``noop_handler``'s own run-context is stale vs the live schema.)
+_XCOM_PATH_PARTS = 5  # /xcoms/{dag_id}/{run_id}/{task_id}/{key}
+
+
+def _remembering_handler(store: dict, run_context_json: bytes) -> Callable:
+    """A dry-run transport handler: valid run-context + XCom round-trip from ``store``, else no-op."""
+    import httpx
+
+    from airflow.sdk.api.client import noop_handler

Review Comment:
   Is there any issue with these being top level imports?



-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run standard venv operator tests DB-free so they parallelize under xdist [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on PR #68533:
URL: https://github.com/apache/airflow/pull/68533#issuecomment-4708851122

   > Also to add @kaxil -> the way it was done before was in order to only change the test code - so the trade-off here is that we need to modify "task-sdk" - new null-by-default client and likely we will also have to add some compat code.
   
   Yeah, that's a fair trade-off. Ok, maybe probably safer to keep it test only for now -- especially if tests are failing on old compat task-sdk tests (I haven't looked)


-- 
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-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org