Skip to content

Commit

Permalink
Merge pull request #82 from OpenEnergyPlatform/release/v0.1.1
Browse files Browse the repository at this point in the history
Release v0.1.1
  • Loading branch information
jh-RLI authored Nov 29, 2022
2 parents e5b855b + 12465bd commit d053137
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 152 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Changelog
current (2022-XX-XX)
--------------------

0.1.1 (2022-11-29)
--------------------
* update parser for v15 to handle former v13 key names, also update outdated License (data-)class in oem_v15 structure. (PR#77)
* change the validation to return a report and enable report file creation option to the arguments of validation method. (PR#81)

0.1.0 (2022-11-18)
--------------------
* Add validation and helper functionality - validation based on json schema and the oemetadata schema files that are published for each release (PR#63)
Expand Down
26 changes: 26 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,32 @@ Module usage::
schema = ... get a schema or import form oemetadata module
parser.is_valid(metadata, schema)

**Additional Fields - not related to the OEMetadata specification**

Sometimes it is necessary to store additional key-value pairs along with the keys included in the OEMetadata specification.
OMI's compiler methods are capable of handling additional arguments or key-value arguments, but this must be
be explicitly specified.

To add additional key-value pairs, you must:

NOTE: If you save the renderer return value in a json file and try to parse the file, the extra field is not included.
You must read the json file using Python and then add the extra field back oemetadata object as shown below.

1 Parse the oemetadata from json file / variable into omis internal structure::

from omi.dialects.oep.dialect import OEP_V_1_5_Dialect

min_inp = '{"id":"unique_id"} # or read from json file
minimal_oemetadata15 = OEP_V_1_5_Dialect.parse(min_inp)

2 Now you can get(from json file)/define the additional data::

data = "test"

3 And add it to the OEMetadata object that was parsed in step 1 by ading a key-value argument::

compiled = OEP_V_1_5_Dialect.compile(minimal_oemetadata15, _additionalField=data)
rendered = OEP_V_1_5_Dialect.render(compiled)

Development
===========
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def read(*names, **kwargs):

setup(
name="omi",
version="0.1.0",
version="0.1.1",
license="AGPL-3.0",
description="A library to process and translate open energy metadata.",
long_description="%s\n%s"
Expand Down
10 changes: 9 additions & 1 deletion src/omi/dialects/oep/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class JSONCompilerOEM15(JSONCompiler):
the metadata structure.
"""

__METADATA_VERSION = "OEP-1.5.1"
__METADATA_VERSION = "OEP-1.5.2"

def visit(self, obj, *args, **kwargs):
"""
Expand Down Expand Up @@ -302,6 +302,13 @@ def visit_temporal(self, temporal: oem_v15.Temporal, *args, **kwargs):
("referenceDate", self._compile_date(temporal.reference_date, "%Y-%m-%d")),
("timeseries", temporal.timeseries_collection),
)

def visit_license(self, lic: oem_v15.License, *args, **kwargs):
return self._construct_dict(
("name", lic.name),
("title", lic.title),
("path", lic.path),
)

def visit_isAbout(self, isAbout: oem_v15.IsAbout, *args, **kwargs):
return self._construct_dict(("name", isAbout.name), ("path", isAbout.path))
Expand Down Expand Up @@ -378,4 +385,5 @@ def visit_metadata(self, metadata: oem_v15.OEPMetadata, *args, **kwargs):
null="If not applicable use: null",
todo="If a value is not yet available, use: todo",
),
**kwargs
)
Loading

0 comments on commit d053137

Please sign in to comment.