Repository: equinor/fmu-dataio

Issue:
`$schema` should produce the dev url in Komodo bleeding
https://github.com/equinor/fmu-dataio/blob/f073d3caf51c75468e03f4452140f5901a169271/src/fmu/dataio/_models/_schema_base.py#L164-L170

This will generate metadata pointing to the dev schemas when `DEV_SCHEMA` is set, but should also do so when running in Komodo bleeding.

This is possibly trickier for komodo-releases Drogon runs, but can be adapted there if it does not work already.

Hints from issue comments:

Solution patch:
diff --git a/src/fmu/dataio/_models/_schema_base.py b/src/fmu/dataio/_models/_schema_base.py
index bd4df1add..1c147f6f2 100644
--- a/src/fmu/dataio/_models/_schema_base.py
+++ b/src/fmu/dataio/_models/_schema_base.py
@@ -163,9 +163,14 @@ class SchemaBase(ABC):
 
     @classmethod
     def url(cls) -> str:
-        """Returns the URL this file will reside at, based upon class variables set here
-        and in FmuSchemas."""
-        if os.environ.get("DEV_SCHEMA", False):
+        """Returns the URL the schema resides at.
+
+        Schema URLs are composed from class variables set by children derived from this
+        base class. If we're in a development environment, or Komodo bleeding, return
+        the dev schema URL."""
+        if os.environ.get("DEV_SCHEMA", False) or "bleeding" in os.environ.get(
+            "KOMODO_RELEASE", os.environ.get("KOMODO_RELEASE_BACKUP", "")
+        ):
             return cls.dev_url()
         return cls.prod_url()
 


Test patch:
diff --git a/tests/test_schema/test_schemas_up_to_date.py b/tests/test_schema/test_schemas_up_to_date.py
index e88877e18..9cf17643e 100644
--- a/tests/test_schema/test_schemas_up_to_date.py
+++ b/tests/test_schema/test_schemas_up_to_date.py
@@ -63,6 +63,36 @@ def test_schema_url_changes_with_env_var(
     assert json["$schema"] == "https://json-schema.org/draft/2020-12/schema"
 
 
+@pytest.mark.parametrize("schema", schemas)
+@pytest.mark.parametrize("env_var", ["KOMODO_RELEASE", "KOMODO_RELEASE_BACKUP"])
+@pytest.mark.parametrize(
+    "env_var_value",
+    [
+        "bleeding",
+        "kenv_bleeding",
+        "bleeding-20250306-0207-py311-rhel8",
+    ],
+)
+def test_schema_url_changes_with_komodo_bleeding_env_var(
+    schema: SchemaBase, env_var: str, env_var_value: str, monkeypatch: MonkeyPatch
+) -> None:
+    """Tests that the schema uses the development url when KOMODO_RELEASE or
+    KOMODO_RELEASE_BACKUP is set to a bleeding release.
+
+    DEV_SCHEMA is set to 1 whenever the tests are run, so it is unset here."""
+    monkeypatch.delenv("DEV_SCHEMA", raising=False)
+    json = schema.dump()
+    assert schema.url().startswith(FmuSchemas.PROD_URL)
+    assert json["$id"].startswith(FmuSchemas.PROD_URL)
+    assert json["$schema"] == "https://json-schema.org/draft/2020-12/schema"
+
+    monkeypatch.setenv(env_var, env_var_value)
+    json = schema.dump()
+    assert schema.url().startswith(FmuSchemas.DEV_URL)
+    assert json["$id"].startswith(FmuSchemas.DEV_URL)
+    assert json["$schema"] == "https://json-schema.org/draft/2020-12/schema"
+
+
 @pytest.mark.parametrize("schema", schemas)
 def test_no_discriminator_mappings_leftover_in_schema(schema: SchemaBase) -> None:
     """Sumo's AJV validator doesn't like discriminator mappings leftover in the