diff --git a/CHANGELOG.md b/CHANGELOG.md index ced9ebbb..00f14c0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,8 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Start new version 2.1. [(#)](https://github.com/OpenEnergyPlatform/oemetadata/pull/) - Add badges for Zenodo publication, FAIRsharing DOI and RDA MSC [(#273)](https://github.com/OpenEnergyPlatform/oemetadata/pull/273) +- Dataset creator to contributors [(#304)](https://github.com/OpenEnergyPlatform/oemetadata/pull/304) - Add `mappingRelation` to `isAbout` [(#307)](https://github.com/OpenEnergyPlatform/oemetadata/pull/307) - Add `mappingRelation` to `valueReference` [(#307)](https://github.com/OpenEnergyPlatform/oemetadata/pull/307) +- Tests for example and template to be valid frictionless datapackage [(#305)](https://github.com/OpenEnergyPlatform/oemetadata/pull/305) ### Changed - Update TLDR URL in example sourceLicenses [(#275)](https://github.com/OpenEnergyPlatform/oemetadata/pull/275) diff --git a/REUSE.toml b/REUSE.toml index dd15fbbc..e42c6016 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -118,6 +118,14 @@ SPDX-FileCopyrightText = ["2026 Ludwig Hülk <@Ludee> © Reiner Lemoine Institut "oemetadata "] SPDX-License-Identifier = "MIT" +[[annotations]] +path = "oemetadata/v2/v21/*.csv" +precedence = "override" +SPDX-FileCopyrightText = ["2026 Ludwig Hülk <@Ludee> © Reiner Lemoine Institut", + "2026 Jonas Huber <@jh-RLI> © Reiner Lemoine Institut", + "oemetadata "] +SPDX-License-Identifier = "CC0-1.0" + [[annotations]] path = "oemetadata/v2/v21/build_source/schemas/*.json" precedence = "override" @@ -141,3 +149,19 @@ SPDX-FileCopyrightText = ["2024 Ludwig Hülk <@Ludee> © Reiner Lemoine Institut "2024 Jonas Huber <@jh-RLI> © Reiner Lemoine Institut", "oemetadata "] SPDX-License-Identifier = "MIT" + +[[annotations]] +path = "test/oemetadata/v2/v21/example/*.csv" +precedence = "override" +SPDX-FileCopyrightText = ["2026 Ludwig Hülk <@Ludee> © Reiner Lemoine Institut", + "2026 Jonas Huber <@jh-RLI> © Reiner Lemoine Institut", + "oemetadata "] +SPDX-License-Identifier = "CC0-1.0" + +[[annotations]] +path = "test/oemetadata/v2/v21/example/*.json" +precedence = "override" +SPDX-FileCopyrightText = ["2026 Ludwig Hülk <@Ludee> © Reiner Lemoine Institut", + "2024 Jonas Huber <@jh-RLI> © Reiner Lemoine Institut", + "oemetadata "] +SPDX-License-Identifier = "CC0-1.0" diff --git a/oemetadata/v2/v21/build_source/schemas/fields.json b/oemetadata/v2/v21/build_source/schemas/fields.json index 7a4a758b..743322c0 100644 --- a/oemetadata/v2/v21/build_source/schemas/fields.json +++ b/oemetadata/v2/v21/build_source/schemas/fields.json @@ -25,7 +25,7 @@ "null" ], "examples": [ - "CSV" + "csv" ], "badge": "Gold", "title": "Format", @@ -278,7 +278,6 @@ "null" ], "examples": [ - "id", "version" ], "badge": "Iron", @@ -298,7 +297,7 @@ "null" ], "examples": [ - "model_draft.oep_oemetadata_table_example_version" + "example_version.csv" ], "badge": "Iron", "title": "Foreign Resource" @@ -313,7 +312,6 @@ "null" ], "examples": [ - "id", "version" ], "badge": "Iron", diff --git a/oemetadata/v2/v21/build_source/schemas/general.json b/oemetadata/v2/v21/build_source/schemas/general.json index 6b90b3e2..8b28ebf3 100644 --- a/oemetadata/v2/v21/build_source/schemas/general.json +++ b/oemetadata/v2/v21/build_source/schemas/general.json @@ -23,7 +23,7 @@ "null" ], "examples": [ - "http://openenergyplatform.org/dataedit/view/model_draft/oemetadata_table_template" + "example.csv" ], "badge": "Bronze", "title": "Path", @@ -36,7 +36,7 @@ "null" ], "examples": [ - "oemetadata_table_template" + "example.csv" ], "badge": "Iron", "title": "Name" @@ -48,7 +48,7 @@ "null" ], "examples": [ - "OEMetadata Table Template" + "OEMetadata Table Example" ], "badge": "Silver", "title": "Title" @@ -60,7 +60,7 @@ "null" ], "examples": [ - "Example table used to illustrate the OEMetadata structure and features." + "Example metadata and table used to illustrate the OEMetadata structure and features." ], "badge": "Silver", "title": "Description" diff --git a/oemetadata/v2/v21/build_source/schemas/provenance.json b/oemetadata/v2/v21/build_source/schemas/provenance.json index 57de9746..1333a35a 100644 --- a/oemetadata/v2/v21/build_source/schemas/provenance.json +++ b/oemetadata/v2/v21/build_source/schemas/provenance.json @@ -102,14 +102,12 @@ "title": "Comment" } }, + "required": [ + "title" + ], "badge": "Bronze", "title": "Contributor" - }, - "badge": "Bronze", - "title": "Contributors" + } } - }, - "required": [ - "contributors" - ] + } } diff --git a/oemetadata/v2/v21/build_source/scripts/example/fields.json b/oemetadata/v2/v21/build_source/scripts/example/fields.json index 13817d22..00b325a7 100644 --- a/oemetadata/v2/v21/build_source/scripts/example/fields.json +++ b/oemetadata/v2/v21/build_source/scripts/example/fields.json @@ -2,65 +2,72 @@ { "name": "id", "description": "Unique identifier", - "type": "serial", + "type": "integer", "nullable": false, "unit": null, "isAbout": [ { "name": "identifier", - "@id": "http://purl.obolibrary.org/obo/IAO_0020000" + "@id": "http://purl.obolibrary.org/obo/IAO_0020000", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] }, { "name": "name", "description": "Technology Name", - "type": "text", + "type": "string", "nullable": true, "unit": null, "isAbout": [ { "name": "power generation technology", - "@id": "http://openenergy-platform.org/ontology/oeo/OEO_00010423" + "@id": "http://openenergy-platform.org/ontology/oeo/OEO_00010423", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": "wind", "name": "wind power technology", - "@id": "http://openenergyplatform.org/ontology/oeo/OEO_00010424" + "@id": "http://openenergyplatform.org/ontology/oeo/OEO_00010424", + "mappingRelation": "skos:exactMatch" } ] }, { "name": "type", "description": "Type of wind farm", - "type": "text", + "type": "string", "nullable": true, "unit": null, "isAbout": [ { "name": "wind farm", - "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000447/" + "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000447/", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": "onshore", "name": "onshore wind farm", - "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000311/" + "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000311/", + "mappingRelation": "skos:exactMatch" }, { "value": "offshore", "name": "offshore wind farm", - "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000308/" + "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000308/", + "mappingRelation": "skos:exactMatch" } ] }, @@ -73,34 +80,38 @@ "isAbout": [ { "name": "year", - "@id": "https://openenergyplatform.org/ontology/oeo/UO_0000036/" + "@id": "https://openenergyplatform.org/ontology/oeo/UO_0000036/", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] }, { "name": "value", "description": "Bruttoleistung", - "type": "decimal", + "type": "number", "nullable": true, "unit": "MW", "isAbout": [ { "name": "nameplate capacity", - "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00230003/" + "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00230003/", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] }, @@ -113,54 +124,60 @@ "isAbout": [ { "name": "Operating Mode Status", - "@id": "https://ontology.brickschema.org/brick/Operating_Mode_Status" + "@id": "https://ontology.brickschema.org/brick/Operating_Mode_Status", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] }, { "name": "version", "description": "Version", - "type": "integer", + "type": "string", "nullable": true, "unit": null, "isAbout": [ { "name": "version number", - "@id": "http://purl.obolibrary.org/obo/IAO_0000129" + "@id": "http://purl.obolibrary.org/obo/IAO_0000129", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] }, { "name": "comment", "description": "", - "type": "text", + "type": "string", "nullable": true, "unit": null, "isAbout": [ { "name": "comment", - "@id": "http://semanticscience.org/resource/SIO_001167" + "@id": "http://semanticscience.org/resource/SIO_001167", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] } diff --git a/oemetadata/v2/v21/example.csv b/oemetadata/v2/v21/example.csv new file mode 100644 index 00000000..d66be5d1 --- /dev/null +++ b/oemetadata/v2/v21/example.csv @@ -0,0 +1,5 @@ +"id","name","type","year","value","is_active","version","comment" +1,"wind","onshore",2021,55.93,true,"0.1.0","" +2,"wind","offshore",2021,7.79,true,"0.1.0","" +3,"wind","onshore",2022,58.05,true,"0.1.1","" +4,"wind","offshore",2022,8.13,true,"0.1.1","" diff --git a/oemetadata/v2/v21/example.json b/oemetadata/v2/v21/example.json index 2b56441c..5c80deb9 100644 --- a/oemetadata/v2/v21/example.json +++ b/oemetadata/v2/v21/example.json @@ -88,10 +88,10 @@ "resources": [ { "@id": "https://databus.openenergyplatform.org/oeplatform/supply/wri_global_power_plant_database/2022-11-07/wri_global_power_plant_database_variant=data.csv", - "path": "http://openenergyplatform.org/dataedit/view/model_draft/oemetadata_table_template", - "name": "oemetadata_table_template", - "title": "OEMetadata Table Template", - "description": "Example table used to illustrate the OEMetadata structure and features.", + "path": "example.csv", + "name": "example.csv", + "title": "OEMetadata Table Example", + "description": "Example metadata and table used to illustrate the OEMetadata structure and features.", "publicationDate": "2024-10-15", "subject": [ { @@ -177,72 +177,79 @@ } ], "type": "table", - "format": "CSV", + "format": "csv", "encoding": "UTF-8", "schema": { "fields": [ { "name": "id", "description": "Unique identifier", - "type": "serial", + "type": "integer", "nullable": false, "unit": null, "isAbout": [ { "name": "identifier", - "@id": "http://purl.obolibrary.org/obo/IAO_0020000" + "@id": "http://purl.obolibrary.org/obo/IAO_0020000", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] }, { "name": "name", "description": "Technology Name", - "type": "text", + "type": "string", "nullable": true, "unit": null, "isAbout": [ { "name": "power generation technology", - "@id": "http://openenergy-platform.org/ontology/oeo/OEO_00010423" + "@id": "http://openenergy-platform.org/ontology/oeo/OEO_00010423", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": "wind", "name": "wind power technology", - "@id": "http://openenergyplatform.org/ontology/oeo/OEO_00010424" + "@id": "http://openenergyplatform.org/ontology/oeo/OEO_00010424", + "mappingRelation": "skos:exactMatch" } ] }, { "name": "type", "description": "Type of wind farm", - "type": "text", + "type": "string", "nullable": true, "unit": null, "isAbout": [ { "name": "wind farm", - "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000447/" + "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000447/", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": "onshore", "name": "onshore wind farm", - "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000311/" + "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000311/", + "mappingRelation": "skos:exactMatch" }, { "value": "offshore", "name": "offshore wind farm", - "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000308/" + "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00000308/", + "mappingRelation": "skos:exactMatch" } ] }, @@ -255,34 +262,38 @@ "isAbout": [ { "name": "year", - "@id": "https://openenergyplatform.org/ontology/oeo/UO_0000036/" + "@id": "https://openenergyplatform.org/ontology/oeo/UO_0000036/", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] }, { "name": "value", "description": "Bruttoleistung", - "type": "decimal", + "type": "number", "nullable": true, "unit": "MW", "isAbout": [ { "name": "nameplate capacity", - "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00230003/" + "@id": "https://openenergyplatform.org/ontology/oeo/OEO_00230003/", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] }, @@ -295,54 +306,60 @@ "isAbout": [ { "name": "Operating Mode Status", - "@id": "https://ontology.brickschema.org/brick/Operating_Mode_Status" + "@id": "https://ontology.brickschema.org/brick/Operating_Mode_Status", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] }, { "name": "version", "description": "Version", - "type": "integer", + "type": "string", "nullable": true, "unit": null, "isAbout": [ { "name": "version number", - "@id": "http://purl.obolibrary.org/obo/IAO_0000129" + "@id": "http://purl.obolibrary.org/obo/IAO_0000129", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] }, { "name": "comment", "description": "", - "type": "text", + "type": "string", "nullable": true, "unit": null, "isAbout": [ { "name": "comment", - "@id": "http://semanticscience.org/resource/SIO_001167" + "@id": "http://semanticscience.org/resource/SIO_001167", + "mappingRelation": "skos:exactMatch" } ], "valueReference": [ { "value": null, "name": null, - "@id": null + "@id": null, + "mappingRelation": null } ] } @@ -353,13 +370,11 @@ "foreignKeys": [ { "fields": [ - "id", "version" ], "reference": { - "resource": "model_draft.oep_oemetadata_table_example_version", + "resource": "example_version.csv", "fields": [ - "id", "version" ] } diff --git a/oemetadata/v2/v21/example.py b/oemetadata/v2/v21/example.py index 1be67c59..4410e2f9 100644 --- a/oemetadata/v2/v21/example.py +++ b/oemetadata/v2/v21/example.py @@ -4,8 +4,14 @@ # SPDX-License-Identifier: MIT import json -import os +from pathlib import Path +from frictionless import Package -with open(os.path.join(os.path.dirname(__file__), "example.json"), "rb") as f: - OEMETADATA_V21_EXAMPLE = json.loads(f.read()) + +BASE_PATH = Path(__file__).parent + +with open(BASE_PATH / "example.json", encoding="utf-8") as f: + descriptor = json.load(f) + +OEMETADATA_V21_EXAMPLE = Package(descriptor, basepath=str(BASE_PATH)) diff --git a/oemetadata/v2/v21/schema.json b/oemetadata/v2/v21/schema.json index 394cfac8..239b1a9a 100644 --- a/oemetadata/v2/v21/schema.json +++ b/oemetadata/v2/v21/schema.json @@ -420,11 +420,12 @@ "title": "Comment" } }, + "required": [ + "title" + ], "badge": "Bronze", "title": "Contributor" - }, - "badge": "Bronze", - "title": "Contributors" + } }, "datasetLicenses": { "description": "An array of objects of licenses under which the described data is provided.", @@ -573,7 +574,7 @@ "null" ], "examples": [ - "http://openenergyplatform.org/dataedit/view/model_draft/oemetadata_table_template" + "example.csv" ], "badge": "Bronze", "title": "Path", @@ -586,7 +587,7 @@ "null" ], "examples": [ - "oemetadata_table_template" + "example.csv" ], "badge": "Iron", "title": "Name" @@ -598,7 +599,7 @@ "null" ], "examples": [ - "OEMetadata Table Template" + "OEMetadata Table Example" ], "badge": "Silver", "title": "Title" @@ -610,7 +611,7 @@ "null" ], "examples": [ - "Example table used to illustrate the OEMetadata structure and features." + "Example metadata and table used to illustrate the OEMetadata structure and features." ], "badge": "Silver", "title": "Description" @@ -1266,7 +1267,7 @@ "null" ], "examples": [ - "CSV" + "csv" ], "badge": "Gold", "title": "Format", @@ -1392,6 +1393,18 @@ "badge": "Platinum", "title": "Is About Identifier", "format": "uri" + }, + "mappingRelation": { + "description": "Using SKOS mapping properties to state mapping (alignment).", + "type": [ + "string", + "null" + ], + "examples": [ + "skos:closeMatch" + ], + "badge": "Platinum", + "title": "Is About SKOS Mapping Relation" } }, "badge": "Platinum", @@ -1442,6 +1455,18 @@ "badge": "Platinum", "title": "Value Reference Identifier", "format": "uri" + }, + "mappingRelation": { + "description": "Using SKOS mapping properties to state mapping (alignment).", + "type": [ + "string", + "null" + ], + "examples": [ + "skos:exactMatch" + ], + "badge": "Platinum", + "title": "Value Reference SKOS Mapping Relation" } }, "badge": "Platinum", @@ -1495,7 +1520,6 @@ "null" ], "examples": [ - "id", "version" ], "badge": "Iron", @@ -1515,7 +1539,7 @@ "null" ], "examples": [ - "model_draft.oep_oemetadata_table_example_version" + "example_version.csv" ], "badge": "Iron", "title": "Foreign Resource" @@ -1530,7 +1554,6 @@ "null" ], "examples": [ - "id", "version" ], "badge": "Iron", diff --git a/oemetadata/v2/v21/template.json b/oemetadata/v2/v21/template.json index 8de40a63..1bb82c22 100644 --- a/oemetadata/v2/v21/template.json +++ b/oemetadata/v2/v21/template.json @@ -161,14 +161,16 @@ "isAbout": [ { "name": "", - "@id": "" + "@id": "", + "mappingRelation": "" } ], "valueReference": [ { "value": "", "name": "", - "@id": "" + "@id": "", + "mappingRelation": "" } ] } diff --git a/requirements.txt b/requirements.txt index ee17da02..8e57c952 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ argparse build bump-my-version +frictionless jsonschema mike mkdocs @@ -23,4 +24,4 @@ tox twine uv wheel --e . \ No newline at end of file +-e . diff --git a/test/oemetadata/v2/v21/test_example.py b/test/oemetadata/v2/v21/test_example.py index e2ee69ed..40283264 100644 --- a/test/oemetadata/v2/v21/test_example.py +++ b/test/oemetadata/v2/v21/test_example.py @@ -22,3 +22,13 @@ def test_oemetadata_schema_should_validate_oemetadata_example(): print("OEMetadata Example is valid OEMetadata Schema (v2.1).") except ValidationError as e: print("Cannot validate OEMetadata Example with Schema (v2.1)!", e) + + +def test_oemetadata_example_is_datapackage(): + from frictionless import Package + + from oemetadata.v2.v21.example import OEMETADATA_V21_EXAMPLE + + descriptor = OEMETADATA_V21_EXAMPLE.to_descriptor() + errors = list(Package.metadata_validate(descriptor)) + assert not errors, [str(e) for e in errors] diff --git a/test/oemetadata/v2/v21/test_template.py b/test/oemetadata/v2/v21/test_template.py index 67e2044a..afc1293a 100644 --- a/test/oemetadata/v2/v21/test_template.py +++ b/test/oemetadata/v2/v21/test_template.py @@ -22,3 +22,13 @@ def test_oemetadata_schema_should_validate_oemetadata_template(): print("OEMetadata Template is valid OEMetadata Schema (v2.1).") except ValidationError as e: print("Cannot validate OEMetadata Template with Schema (v2.1)!", e) + + +# Template is not a valid datapackage +# def test_oemetadata_template_is_datapackage(): +# from frictionless import validate +# +# from oemetadata.v2.v21.template import OEMETADATA_V21_TEMPLATE +# +# report = validate(OEMETADATA_V21_TEMPLATE) +# assert report.valid, report.flatten(["message"])