kaxil commented on code in PR #76575:
URL: https://github.com/apache/airflow/pull/76575#discussion_r4514932266


##########
dev/registry/fill_durable_versions.py:
##########
@@ -0,0 +1,166 @@
+#!/usr/bin/env python3
+# 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.
+"""Date each durable module in modules.json against the provider tags that 
first shipped it.
+
+Runs on the host rather than in Breeze with the rest of the module extraction, 
because it reads
+the ``providers-<id>/<version>`` git tags and Breeze does not mount ``.git``.
+
+Usage:
+    python dev/registry/fill_durable_versions.py --modules 
dev/registry/modules.json
+"""
+
+from __future__ import annotations
+
+import argparse
+import functools
+import json
+import subprocess
+import sys
+from pathlib import Path
+
+from packaging.version import InvalidVersion, Version
+
+AIRFLOW_ROOT = Path(__file__).parent.parent.parent
+
+# What to look for in the gating class's file to date the capability. Both 
tokens are the
+# mechanism itself, not its declaration: KubernetesPodOperator reconnected via 
task_state_store
+# in 10.20.0 but only declared `__supports_durable_execution` for the registry 
in 10.21.0, and
+# dating it by the declaration would report a release later than the behaviour 
shipped.
+DURABLE_TOKENS = {
+    "marker": "task_state_store",

Review Comment:
   This puts `AgentOperator` at common-ai 0.7.0, but `durable=True` already 
worked in 0.1.0 (journal in ObjectStorage). 0.7.0 is just when it moved to 
`task_state_store`. What about dating on when `durable` first shows up in the 
operator's signature? I checked and that gives 0.1.0 for the agent and 10.20.0 
for KPO.



##########
dev/registry/registry_contract_models.py:
##########
@@ -146,6 +146,11 @@ class ModuleContract(BaseModel):
     provider_name: str | None = None
     supports_durable_execution: bool = False
     supports_deferrable: bool = False
+    durable_mechanism: Literal["marker", "resumable_mixin"] | None = None
+    durable_gating_provider: str | None = None
+    durable_gating_class: str | None = None
+    durable_since_version: str | None = None
+    durable_default: bool | None = None

Review Comment:
   This only ever comes out `False` or `None`, since every on-by-default 
operator declares `durable: bool | None = None`. So for anyone reading 
`/api/modules.json`, `null` means "on". Would a plain `durable_opt_in: bool` 
say what the page actually checks?



##########
dev/registry/tests/test_extract_parameters.py:
##########
@@ -443,6 +446,45 @@ def execute(self, context):
         assert is_durable_capable(ExplicitDelegatesToIntermediate, 
FakeResumableJobMixin) is True
 
 
+class TestDurableMetadata:

Review Comment:
   Nothing here covers `durable_default`, which is what the Opt-in badge reads. 
No durable fixture has a `durable` param, so hard-coding it to `None` stays 
green. Could one fixture declare `durable: bool = False` in its `__init__`?



##########
registry/src/durable.njk:
##########
@@ -16,7 +16,7 @@ mainClass: durable-page
   <dl class="capabilities">
     <div>
       <dt><span class="durable-badge">Durable</span> {{ counts.durable }}</dt>
-      <dd>On retry, reconnects to the job it already started, or replays the 
progress it saved, instead of starting over. Controlled by the operator's 
<code>durable</code> flag: on by default for most, opt-in for the AI agent 
operators. Several only reconnect on Airflow 3.3+.</dd>
+      <dd>On retry, reconnects to the job it already started, or replays the 
progress it saved, instead of starting over. Controlled by the operator's 
<code>durable</code> flag; each module below says which provider version it 
needs, and whether you have to opt in. Needs Airflow 3.3 or later.</dd>

Review Comment:
   This reads like every durable operator needs 3.3, but KPO's `durable` falls 
back to label-search reattach below 3.3 and `AgentOperator` keeps its journal 
in ObjectStorage there. Can we keep the old "Several only reconnect on Airflow 
3.3+"?



##########
dev/registry/tests/test_fill_durable_versions.py:
##########
@@ -0,0 +1,231 @@
+# 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.
+
+from __future__ import annotations
+
+import json
+import subprocess
+from unittest import mock
+
+import pytest
+from fill_durable_versions import (
+    GitCommandError,
+    build_source_path,
+    durable_group,
+    find_first_releases,
+    get_released_tags,
+    main,
+    run_git,
+)
+
+POD_PATH = 
"providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py"
+POD_CLASS = 
"airflow.providers.cncf.kubernetes.operators.pod.KubernetesPodOperator"
+
+
[email protected](autouse=True)
+def clear_tag_cache():
+    get_released_tags.cache_clear()
+    yield
+    get_released_tags.cache_clear()
+
+
+def fake_git(tags=(), matches=()):

Review Comment:
   `fake_git` ignores everything after `args[0]`, so dropping `-l` from the 
grep stays green, and without it each match comes back as `tag:path:line` and 
nothing gets dated. `test_no_tags_means_no_grep_at_all` has the same gap, since 
a grep returning `[]` gives `{}` with or without the guard. Could the fake 
assert the argv (and raise on `grep` in the no-tags test)?



##########
dev/registry/registry_contract_models.py:
##########
@@ -146,6 +146,11 @@ class ModuleContract(BaseModel):
     provider_name: str | None = None
     supports_durable_execution: bool = False
     supports_deferrable: bool = False
+    durable_mechanism: Literal["marker", "resumable_mixin"] | None = None

Review Comment:
   These all land in `/api/modules.json` and the published OpenAPI spec. 
`durable_mechanism` and `durable_gating_class` only exist so 
`fill_durable_versions.py` knows which file to grep, and the page never reads 
them. Could we strip them after the fill so the public contract only gains 
`durable_since_version`, `durable_gating_provider` and `durable_default`?



##########
dev/breeze/src/airflow_breeze/commands/registry_commands.py:
##########
@@ -145,7 +145,28 @@ def extract_data(python: str, provider: str | None, 
allow_unreleased: bool):
         bring_compose_project_down(preserve_volumes=False, 
shell_params=shell_params)
         remove_docker_networks([f"{unique_project_name}_default"])
         fix_ownership_using_docker()
-    sys.exit(result.returncode)
+    if result.returncode:
+        sys.exit(result.returncode)
+
+    # Dating a durable module needs the providers-* tags, so it runs here 
rather than beside
+    # the module extraction in the container.
+    with ci_group("Dating durable modules"):

Review Comment:
   This breaks two tests in `dev/breeze/tests/test_registry_extract_data.py`: 
they check the last `run_command` call, which is now this one instead of 
`extract_metadata.py`.



##########
registry/src/css/main.css:
##########
@@ -3531,6 +3533,18 @@ main {
   color: light-dark(var(--color-blue-700), var(--color-blue-400));
 }
 
+:is(.provider-detail-page, .durable-page) .modules .module .content h3 
.version-badge {

Review Comment:
   This badge also matches the global `.version-badge` rule at line 1266, which 
adds a 1px border none of its neighbours have. Intended, or should this reset 
`border`?



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