From 4c25216c4d144eee9f3ec40898f4620e9142d7c6 Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Mon, 11 Aug 2025 09:25:10 +0200 Subject: [PATCH 1/4] fix usage of links --- README.rst | 2 +- RELEASE_PROCEDURE.md | 2 +- docs/user_documentation/install/index.md | 8 ++++---- environment.yaml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index b82e24c0..f98d898b 100644 --- a/README.rst +++ b/README.rst @@ -63,7 +63,7 @@ Collaboration | Everyone is invited to develop this repository with good intentions. | Please follow the workflow described in the `CONTRIBUTING.md `_. | Development work that aims to extend the oemetadata specification is added to the build_source/schemas/ directory for each release. -| To generate the schema, template & example JSON files see your script based `tooling <.metadata/latest/build_source/>`_ +| To generate the schema, template & example JSON files see the scripts based `tooling `_ Contributors: diff --git a/RELEASE_PROCEDURE.md b/RELEASE_PROCEDURE.md index 67049f32..93e28f9c 100644 --- a/RELEASE_PROCEDURE.md +++ b/RELEASE_PROCEDURE.md @@ -153,7 +153,7 @@ If you messed up, remove tags and start again - Change to `production` branch: 💠`git checkout production` - Update with online version: 💠`git pull` -- Activate environment and enter repository: 💻`activate py310` +- Activate environment and enter repository: 💻`activate oemetadata` - Test version: 💻`mike serve` - Publish new version: 💻`mike deploy --push --update-aliases 0.1 latest` diff --git a/docs/user_documentation/install/index.md b/docs/user_documentation/install/index.md index 3a344f9d..68ecb56a 100644 --- a/docs/user_documentation/install/index.md +++ b/docs/user_documentation/install/index.md @@ -5,15 +5,15 @@ With conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them.
Switching or moving between environments is called activating the environment. -You can also share an environment file and import from 📝 `requirements.txt`. - +You can also share an environment file and import from 📝 `requirements.txt`.
+
💻 `conda env create -f environment.yaml` Create conda environment
- 💻 `conda activate py310` Activate environment
+ 💻 `conda activate oemetadata` Activate environment
💻 `python --version` Check python version Delete existing environment:
💻 `conda deactivate`
- 💻 `conda remove --name py310 --all` + 💻 `conda remove --name oemetadata --all` ## Requirements diff --git a/environment.yaml b/environment.yaml index 041f49c3..bcf95e42 100644 --- a/environment.yaml +++ b/environment.yaml @@ -2,11 +2,11 @@ # SPDX-FileCopyrightText: super-repo v0.5.0 # SPDX-License-Identifier: MIT -name: py310 +name: oemetadata channels: - conda-forge dependencies: - - python=3.10 + - python=3.13 - pip - pip: - -r requirements.txt From 192d470752a154cb50b42bdd8ccc05eb05e48528 Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Mon, 11 Aug 2025 09:41:57 +0200 Subject: [PATCH 2/4] add the package itself to list of requirements --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index f8e5d4c3..ee17da02 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,3 +23,4 @@ tox twine uv wheel +-e . \ No newline at end of file From d98dba53cabb17b835e1e3c6615c35ad61b5fdf4 Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Mon, 11 Aug 2025 09:46:19 +0200 Subject: [PATCH 3/4] adjust tooling to generate correct files call the scripts using python oemetadata/v2/v20/build_source/scripts/create_schema.py python oemetadata/v2/v20/build_source/scripts/create_template.py python oemetadata/v2/v20/build_source/scripts/create_example.py --- CHANGELOG.md | 2 ++ .../build_source/scripts/create_example.py | 19 +++++++++---------- .../v20/build_source/scripts/create_schema.py | 3 ++- .../build_source/scripts/create_template.py | 3 ++- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddea0a25..21c39c7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Update TLDR URL in example sourceLicenses [(#275)](https://github.com/OpenEnergyPlatform/oemetadata/pull/275) +- Scripts in build_source produce same json as provided in repo [(#284)](https://github.com/OpenEnergyPlatform/oemetadata/pull/284) +- Update python env instructions to latest verion [(#284)](https://github.com/OpenEnergyPlatform/oemetadata/pull/284) ### Removed diff --git a/oemetadata/v2/v20/build_source/scripts/create_example.py b/oemetadata/v2/v20/build_source/scripts/create_example.py index 591911eb..237c577c 100644 --- a/oemetadata/v2/v20/build_source/scripts/create_example.py +++ b/oemetadata/v2/v20/build_source/scripts/create_example.py @@ -61,8 +61,7 @@ def read_metadata_schema(filepath: str) -> Dict[str, Any]: Dict[str, Any]: The JSON schema as a dictionary. """ if not os.path.exists(filepath): - logger.info(f"Error: File '{filepath}' does not exist.") - return {} + raise FileNotFoundError(f"Error: File '{filepath}' does not exist.") try: with open(filepath, encoding="utf-8") as file: @@ -78,8 +77,8 @@ def read_metadata_schema(filepath: str) -> Dict[str, Any]: # Additional debugging info: Check expected keys if "$schema" not in schema or "type" not in schema: - logger.info( - "Warning: Schema may be missing key fields like '$schema' or 'type'." + logger.warning( + "Schema may be missing key fields like '$schema' or 'type'." ) logger.info( @@ -89,11 +88,9 @@ def read_metadata_schema(filepath: str) -> Dict[str, Any]: return schema except json.JSONDecodeError as e: - logger.info(f"Error reading JSON: {e}") - return {} + raise Exception(f"Error reading JSON: {e}") except Exception as e: - logger.info(f"An unexpected error occurred while reading the schema: {e}") - return {} + raise Exception(f"An unexpected error occurred while reading the schema: {e}") # def generate_example_old( @@ -220,7 +217,8 @@ def save_json(data: Dict[str, Any], filename: Path) -> None: filename (str): The filename where the JSON data will be saved. """ with open(filename, "w", encoding="utf-8") as file: - json.dump(data, file, ensure_ascii=False, indent=4) + json.dump(data, file, indent=2) + file.write("\n") logger.info(f"example JSON generated and saved to {filename}") @@ -262,7 +260,8 @@ def replace_key_in_json(file_path, target_key, new_value): if find_and_replace_key(data, target_key, new_value): # Save the updated JSON data back to the file with open(file_path, "w", encoding="utf-8") as file: - json.dump(data, file, ensure_ascii=False, indent=4) + json.dump(data, file, ensure_ascii=False, indent=2) + file.write("\n") logger.info(f"Updated '{target_key}' to '{new_value}' in {file_path}") else: logger.info(f"Key '{target_key}' not found in JSON file.") diff --git a/oemetadata/v2/v20/build_source/scripts/create_schema.py b/oemetadata/v2/v20/build_source/scripts/create_schema.py index 395d4b35..63cac586 100644 --- a/oemetadata/v2/v20/build_source/scripts/create_schema.py +++ b/oemetadata/v2/v20/build_source/scripts/create_schema.py @@ -193,7 +193,8 @@ def main(debug): # Save the resolved schema to a new file with open(RESOLVED_SCHEMA_FILE_NAME, "w", encoding="utf-8") as output_file: - json.dump(resolved_schema, output_file, indent=2) + json.dump(resolved_schema, output_file, ensure_ascii=False, indent=2) + output_file.write("\n") # Load the expected schema and validate expected_schema = load_expected_schema(EXPECTED_SCHEMA_PATH) diff --git a/oemetadata/v2/v20/build_source/scripts/create_template.py b/oemetadata/v2/v20/build_source/scripts/create_template.py index f0d77659..90319e1c 100644 --- a/oemetadata/v2/v20/build_source/scripts/create_template.py +++ b/oemetadata/v2/v20/build_source/scripts/create_template.py @@ -133,7 +133,8 @@ def replace_key_in_json(file_path, target_key, new_value): if find_and_replace_key(data, target_key, new_value): # Save the updated JSON data back to the file with open(file_path, "w") as file: - json.dump(data, file, indent=4) + json.dump(data, file, indent=2) + file.write("\n") print(f"Updated '{target_key}' to '{new_value}' in {file_path}") else: print(f"Key '{target_key}' not found in JSON file.") From 27ba1e46e766c2d89ae2a48b6f2fa948ab6db21f Mon Sep 17 00:00:00 2001 From: Jonas Huber <38939526+jh-RLI@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:20:48 +0200 Subject: [PATCH 4/4] Fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21c39c7b..453e8fef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Update TLDR URL in example sourceLicenses [(#275)](https://github.com/OpenEnergyPlatform/oemetadata/pull/275) - Scripts in build_source produce same json as provided in repo [(#284)](https://github.com/OpenEnergyPlatform/oemetadata/pull/284) -- Update python env instructions to latest verion [(#284)](https://github.com/OpenEnergyPlatform/oemetadata/pull/284) +- Update python env instructions to latest version [(#284)](https://github.com/OpenEnergyPlatform/oemetadata/pull/284) ### Removed