Skip to content

Commit

Permalink
Merge pull request #30 from PrefectHQ/some-2x-updates
Browse files Browse the repository at this point in the history
Some 2.x updates
  • Loading branch information
cicdw authored Nov 8, 2024
2 parents 9782525 + af25a1c commit 9b5fc44
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions test_oss_cloud_api_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
import pytest


PREFECT_V2 = False


@pytest.fixture
def oss_schema():
return load_schema("oss_schema.json")
schema = load_schema("oss_schema.json")
if schema["info"]["version"].startswith("2"):
global PREFECT_V2
PREFECT_V2 = True
return schema


@pytest.fixture
Expand Down Expand Up @@ -252,11 +259,21 @@ def extract_types(d):
return {item.get("type") for item in d["anyOf"] if item.get("type")}
return set()

def extract_format(d):
if "format" in d:
return d["format"]
# in practice, this will have only one format
elif "anyOf" in d:
for option in d["anyOf"]:
if option.get("format"):
return option.get("format")
return None

# TODO: add sorts and filters
prop_gettr = lambda name, d: (
name,
extract_types(d),
d.get("format"),
extract_format(d),
hashable_default(d),
d.get("deprecated"),
)
Expand Down Expand Up @@ -295,6 +312,11 @@ def extract_types(d):
# failures when looping over fields
print("parameter name:", oss_name)

if oss_name == "history_interval_seconds":
oss_name = "history_interval" # cloud aliases this which doesn't appear in the schema
elif oss_name == "schema" and PREFECT_V2:
oss_name = "json_schema" # UI schema validation doesnt really matter for 2.x OSS compat

assert oss_name in cloud_props[1]
(
cloud_name,
Expand Down Expand Up @@ -393,6 +415,14 @@ def preprocess_pydantic_v1_type(schema):
# test failures when looping over fields
print("field name:", field_name)

# fields are ignored in all cases
if (
PREFECT_V2
and name == "StateCreate"
and field_name in ["timestamp", "id"]
):
continue

assert field_name in cloud_props

oss_options = set()
Expand Down

0 comments on commit 9b5fc44

Please sign in to comment.