Skip to content

Commit

Permalink
automate schema version naming
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishavlin committed Nov 10, 2023
1 parent c90261c commit 27980da
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/yt_napari/_schema_version.py
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion src/yt_napari/_tests/_test_json.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion src/yt_napari/_tests/_test_json_slice.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion src/yt_napari/_tests/_test_json_timeseries.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "yt-napari_0.2.0.json",
"$schema": "yt-napari_0.2.0.dev.json",
"datasets": [],
"timeseries": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/yt_napari/_tests/_test_json_timeseries_stack.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "yt-napari_0.2.0.json",
"$schema": "yt-napari_0.2.0.dev.json",
"datasets": [],
"timeseries": [
{
Expand Down
1 change: 1 addition & 0 deletions src/yt_napari/_tests/test_schema_version_comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions src/yt_napari/schemas/_version_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 27980da

Please sign in to comment.