From 27980da2adb019643799263a8436d7dd23e09105 Mon Sep 17 00:00:00 2001 From: chrishavlin Date: Fri, 10 Nov 2023 09:50:44 -0600 Subject: [PATCH] automate schema version naming --- src/yt_napari/_schema_version.py | 8 +++++--- src/yt_napari/_tests/_test_json.json | 2 +- src/yt_napari/_tests/_test_json_slice.json | 2 +- src/yt_napari/_tests/_test_json_timeseries.json | 2 +- src/yt_napari/_tests/_test_json_timeseries_stack.json | 2 +- src/yt_napari/_tests/test_schema_version_comparisons.py | 1 + src/yt_napari/schemas/_version_comparison.py | 5 +++++ 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/yt_napari/_schema_version.py b/src/yt_napari/_schema_version.py index 04279d8..e0014ca 100644 --- a/src/yt_napari/_schema_version.py +++ b/src/yt_napari/_schema_version.py @@ -1,3 +1,5 @@ -schema_version = "0.2.0" -schema_version_tuple = (0, 2, 0) -schema_name = "yt-napari_" + schema_version + ".json" +from yt_napari._version import version, version_tuple + +schema_version_tuple = version_tuple[:3] +schema_version = ".".join([str(i) for i in schema_version_tuple]) +schema_name = "yt-napari_" + version + ".json" diff --git a/src/yt_napari/_tests/_test_json.json b/src/yt_napari/_tests/_test_json.json index d6da465..364ddb0 100644 --- a/src/yt_napari/_tests/_test_json.json +++ b/src/yt_napari/_tests/_test_json.json @@ -1,4 +1,4 @@ -{"$schema": "yt-napari_0.2.0.json", +{"$schema": "yt-napari_0.2.0.dev.json", "dataset": [{"filename": "IsolatedGalaxy/galaxy0030/galaxy0030", "selections": { "regions": [ diff --git a/src/yt_napari/_tests/_test_json_slice.json b/src/yt_napari/_tests/_test_json_slice.json index 92ef496..a55ae50 100644 --- a/src/yt_napari/_tests/_test_json_slice.json +++ b/src/yt_napari/_tests/_test_json_slice.json @@ -1,4 +1,4 @@ -{"$schema": "yt-napari_0.2.0.json", +{"$schema": "yt-napari_0.2.0.dev.json", "datasets": [{"filename": "IsolatedGalaxy/galaxy0030/galaxy0030/", "selections": { "slices": [ diff --git a/src/yt_napari/_tests/_test_json_timeseries.json b/src/yt_napari/_tests/_test_json_timeseries.json index 5b33d0f..a6f1390 100644 --- a/src/yt_napari/_tests/_test_json_timeseries.json +++ b/src/yt_napari/_tests/_test_json_timeseries.json @@ -1,5 +1,5 @@ { - "$schema": "yt-napari_0.2.0.json", + "$schema": "yt-napari_0.2.0.dev.json", "datasets": [], "timeseries": [ { diff --git a/src/yt_napari/_tests/_test_json_timeseries_stack.json b/src/yt_napari/_tests/_test_json_timeseries_stack.json index 8bd31f1..2228b4e 100644 --- a/src/yt_napari/_tests/_test_json_timeseries_stack.json +++ b/src/yt_napari/_tests/_test_json_timeseries_stack.json @@ -1,5 +1,5 @@ { - "$schema": "yt-napari_0.2.0.json", + "$schema": "yt-napari_0.2.0.dev.json", "datasets": [], "timeseries": [ { diff --git a/src/yt_napari/_tests/test_schema_version_comparisons.py b/src/yt_napari/_tests/test_schema_version_comparisons.py index d11e71c..81ce60c 100644 --- a/src/yt_napari/_tests/test_schema_version_comparisons.py +++ b/src/yt_napari/_tests/test_schema_version_comparisons.py @@ -24,6 +24,7 @@ def test_version_tupling(string_to_test, expected): ("yt-napari_0.0.1.json", True), ("yt-napari_1000.1.0.json", False), ("/blah/blah/yt-napari_latest.json", True), + ("yt-napari_0.2.1.dev.json", True), ], ) def test_schema_str_validation(string_to_test, expected): diff --git a/src/yt_napari/schemas/_version_comparison.py b/src/yt_napari/schemas/_version_comparison.py index 36b7a64..a5561af 100644 --- a/src/yt_napari/schemas/_version_comparison.py +++ b/src/yt_napari/schemas/_version_comparison.py @@ -23,6 +23,11 @@ def schema_version_is_valid( # now we check the actual version. since the schema prefix (yt-napari) is # in the supplied schema_version, we can assume a form of yt-napari_x.x.x.json + # or yt-napari_x.x.x.dev+.json + if "dev" in schema_version: + ytnapari_log.info("Using development schema.") + return True + sc_version = _schema_version_tuple_from_str(schema_version) _version_tuple = _get_version_tuple() if sc_version < _version_tuple: