LOD-GEOSS / databus-snippets

3 stars 1 forks source link

Submitting metadata to MOSS with script currently not possible #22

Closed chrwm closed 1 year ago

chrwm commented 1 year ago

When using the script to register tables on the databus, the submission to MOSS currently fails.

The function below, responsible for registering in MOSS, needs to be checked

https://github.com/LOD-GEOSS/databus-snippets/blob/46cbbeadad56fc528d822b70841753b59f57d59a/moss.py#L12-L20

chrwm commented 1 year ago

Update, this is still the case FYI @christian-rli

yum-yab commented 1 year ago

Hey, I can't reproduce the issue, can you please send a non-working example?

I used:

import requests
from urllib.parse import quote

MOSS_URL = "http://moss.tools.dbpedia.org/annotation-api-demo/submit"

class MossError(Exception):
    """Raised if submitting metadata to MOSS fails"""

def submit_metadata_to_moss(databus_identifier, metadata):
    # generate the URI for the request with the encoded identifier
    api_uri = f"{MOSS_URL}?id={quote(databus_identifier)}"
    response = requests.put(api_uri, headers={"Content-Type": "application/ld+json"}, json=metadata)
    if response.status_code != 200:
        raise MossError(
            f"Could not submit metadata for DI '{databus_identifier}' to MOSS. "
            f"Reason: {response.reason}"
        )

metadata = requests.get("https://openenergy-platform.org/api/v0/schema/scenario/tables/ksz2050_r2_ks80_co2_emissions_industrial_processes/meta/").json()

databus_id = "https://energy.databus.dbpedia.org/denis/OEP/rli_dibt_windzone"

submit_metadata_to_moss(databus_id, metadata)

and it works without problems.

chrwm commented 1 year ago

Sorry this works fine, mistake on my end, respectively on the current script.

This https://github.com/LOD-GEOSS/databus-snippets/blob/2d665eaeb4b8146d366ecc8d9497230c315a9b06/oep_metadata/oep_databus_registration.py#L124

has to be changed to databus_identifier = f"{DATABUS_URI_BASE}/{ACCOUNT_NAME}/{GROUP}/{table_name}"