Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Collaboration
| Everyone is invited to develop this repository with good intentions.
| Please follow the workflow described in the `CONTRIBUTING.md <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 <oemetadata/v2/v20/build_source/>`_

Contributors:

Expand Down
2 changes: 1 addition & 1 deletion RELEASE_PROCEDURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
8 changes: 4 additions & 4 deletions docs/user_documentation/install/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. <br>
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`.<br>
<br>
💻 `conda env create -f environment.yaml` Create conda environment <br>
💻 `conda activate py310` Activate environment <br>
💻 `conda activate oemetadata` Activate environment <br>
💻 `python --version` Check python version

Delete existing environment: <br>
💻 `conda deactivate` <br>
💻 `conda remove --name py310 --all`
💻 `conda remove --name oemetadata --all`

## Requirements

Expand Down
4 changes: 2 additions & 2 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# SPDX-FileCopyrightText: super-repo v0.5.0 <https://github.com/rl-institut/super-repo>
# SPDX-License-Identifier: MIT

name: py310
name: oemetadata
channels:
- conda-forge
dependencies:
- python=3.10
- python=3.13
- pip
- pip:
- -r requirements.txt
19 changes: 9 additions & 10 deletions oemetadata/v2/v20/build_source/scripts/create_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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}")

Expand Down Expand Up @@ -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.")
Expand Down
3 changes: 2 additions & 1 deletion oemetadata/v2/v20/build_source/scripts/create_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion oemetadata/v2/v20/build_source/scripts/create_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ tox
twine
uv
wheel
-e .