OpenEnergyPlatform / oemetadata

Repository for the Open Energy Family metadata. Contains metadata templates, examples and schemas. For metadata conversion see https://github.com/OpenEnergyPlatform/omi
https://openenergyplatform.github.io/oemetadata/
MIT License
21 stars 3 forks source link

Enhancement to improve linking between databus, MOSS and OEMetadata #139

Open carstenhoyerklick opened 5 months ago

carstenhoyerklick commented 5 months ago

Description of the issue

we just had a discussion on how to improve the link between databus und OEMetadata. It needs a few addtional header fields in OEMetadata 2.0.

Ideas of solution

Describe possible ideas for solution and evaluate advantages and disadvantages.

Workflow checklist

holycrab13 commented 5 months ago

@holycrab13 @kurzum @JonathanJustavino

kurzum commented 4 months ago

Update: @JonathanJustavino implemented an upload prototype here: https://github.com/JonathanJustavino/databus-upload .env (https://github.com/JonathanJustavino/databus-upload?tab=readme-ov-file#credentials) and jsonld (https://github.com/JonathanJustavino/databus-upload/blob/master/example-upload/metadata.json) needs to be configured in advance

Insights and Issues:

jh-RLI commented 4 months ago

@kurzum Regarding the oep http api usage:

We have this tutorial that demonstrates the usage using python: https://openenergyplatform.github.io/academy/tutorials/01_api/02_api_upload/

In general the endpoints are:

get your api token & inlcude in all requests

image

# do something like
auth_headers = {"Authorization": "Token %s" % token}

Create new table:

topic_name can be "model_draft" or "sandbox" (only for testing)

PUT request to https://openenergy-platform.org/v0/schema/<topic_name>/tables/<table_name>/

The Requests must include the table definition --> use the "query" field {"query": table_schema}

# NOTE: first column should be numerical column named `id`.
{
    "columns": [
        {"name": "id", "data_type": "bigserial", "primary_key": True},
        {"name": "name", "data_type": "varchar(18)", "is_nullable": False},
        {"name": "is_active", "data_type": "boolean"},
        {"name": "capacity_mw", "data_type": "float"},
        {"name": "installation_datetime_utc", "data_type": "datetime"},
    ]
}

Upload data

POST request to https://openenergy-platform.org/v0/schema/<topic_name>/tables/<table_name>/rows/new

Add data to the request: {"query": table_data }

table_data = {
    "name": "test",
    "is_active": "true",
    "capacity_mw": "12.12",
    "installation_datetime_utc": "2023-12-12",
}

Update data

POST request to https://openenergy-platform.org/v0/schema/<topic_name>/tables/<table_name>/rows/<row_id>

include data

Upload metadata

POST request to https://openenergy-platform.org/v0/schema/<topic_name>/tables/<table_name>/meta/

add metadata json

Delete Table

DELETE request to https://openenergy-platform.org/v0/schema/<topic_name>/tables/<table_name>/