Skip to content

Commit

Permalink
Merge pull request #131 from ACCESS-NRI/update_schema
Browse files Browse the repository at this point in the history
Update schema to allow version strings
  • Loading branch information
dougiesquire committed Oct 17, 2023
2 parents bb04f41 + 5e9a679 commit 1a1dbcd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 5 additions & 3 deletions bin/create_metadata_yaml_template.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env python

# Copyright 2023 ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: Apache-2.0

import argparse

import yaml

from access_nri_intake.catalog import METADATA_JSONSCHEMA
from access_nri_intake.catalog import EXP_JSONSCHEMA


def main():
Expand All @@ -14,8 +16,8 @@ def main():
)

template = {}
for name, descr in METADATA_JSONSCHEMA["properties"].items():
if name in METADATA_JSONSCHEMA["required"]:
for name, descr in EXP_JSONSCHEMA["properties"].items():
if name in EXP_JSONSCHEMA["required"]:
description = f"<REQUIRED {descr['description']}>"
else:
description = f"<{descr['description']}>"
Expand Down
12 changes: 5 additions & 7 deletions bin/validate_metadata_yaml.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env python

# Copyright 2023 ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: Apache-2.0

import argparse
import glob

from access_nri_intake.catalog import METADATA_JSONSCHEMA
from access_nri_intake.utils import load_metadata_yaml, validate_against_schema
from access_nri_intake.catalog import EXP_JSONSCHEMA
from access_nri_intake.utils import load_metadata_yaml


def main():
Expand All @@ -23,12 +25,8 @@ def main():
file = args.file

for f in glob.glob(file):
instance = load_metadata_yaml(f)

print(f"Validating {f}... ", end="")

validate_against_schema(instance, METADATA_JSONSCHEMA)

load_metadata_yaml(f, EXP_JSONSCHEMA)
print("success")


Expand Down
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ variable:
- <The variable(s) included in the experiment (string)>
nominal_resolution:
- <The nominal resolution(s) of model(s) used in the experiment (string)>
version: <The version of the experiment (number)>
version: <The version of the experiment (number, string)>
contact: <Contact name for the experiment (string)>
email: <Email address of the contact for the experiment (string)>
created: <Initial creation date of experiment (string)>
Expand Down
4 changes: 2 additions & 2 deletions src/access_nri_intake/catalog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
NAME_COLUMN = "name"
TRANSLATOR_GROUPBY_COLUMNS = ["model", "realm", "frequency"]

SCHEMA_URL = "https://raw.githubusercontent.com/ACCESS-NRI/schema/d4da77a0e627775c11ba394c0a3f72a2c654971c/experiment_asset.json"
SCHEMA_HASH = "b18cf5bdd06a6f5bcdc71dfc80f7336c63eb49f6d6f75c2cd3371e59eee5488b"
SCHEMA_URL = "https://raw.githubusercontent.com/ACCESS-NRI/schema/36abe2fe28eb2853a54f41c5eedfd964617d9d68/experiment_asset.json"
SCHEMA_HASH = "60d439a9ad5602464c7dad54072ac276d1fae3634f9524edcc82073a5a92616a"

EXP_JSONSCHEMA, CATALOG_JSONSCHEMA = get_jsonschema(
url=SCHEMA_URL, known_hash=SCHEMA_HASH, required=CORE_COLUMNS
Expand Down

0 comments on commit 1a1dbcd

Please sign in to comment.