OpenEnergyPlatform / omi

Repository for the Open Metadata Integration (OMI). For metadata definition see metadata repo:
https://github.com/OpenEnergyPlatform/metadata
GNU Affero General Public License v3.0
7 stars 4 forks source link

parser does not raise Exception on missing "resources" #29

Open wingechr opened 4 years ago

wingechr commented 4 years ago

The field "resources" should be mandatory (This is also the specification for datapackages)

SharanyaMohan-30 commented 4 years ago

Hello Christian,

Currently I am looking into this issue need your inputs for the below-mentioned clarifications:

1)When the Resource section is not available in the JSON file: As per my analysis in the existing source code, we are checking for Mandortory fields such as Resource, Spatial, contribution, etc. In the assert_1_3_metastring method: If mandatory fields are not present we are raising the exception with a specific message as shown in the below code snippet. for i in keys: if not i in json_dict.keys(): raise Exception( 'The String did not contain the key "{0}"'.format(i) ) We are catching the exception and we are printing the error message there itself should I need to rethrow the exception to the caller??? except Exception as error: print( "The input String does not conform to metadata string version 1.3 standard" ) print(error)

2)Assuming all the mandatory fields present in the JSON file, while parsing do I need to raise an exception if the content of the resource section is empty? or are there any mandatory values that should be present in the Resource section?

MGlauer commented 4 years ago

@christian-rli could you help with above question?

wingechr commented 4 years ago

Hi @SharanyaMohan-30

1) I am not 100% sure but I think the error should not be rethrown 2) In my opinion, the resources should be a mandatory array containing at least one element of the following structure:

{
    "name": "...",
    "schema": {
        "fields": [
            ...
        ]
    }
}

This is the description of the table name and column names (and types) in accordance with the datapacke specs

MGlauer commented 4 years ago

According to our current JSON-schema spec, there are no mandatory fields in resources (or in the metadata object in general). This is also inconsistent with how OMI works right now because at least id is required. According to documentation json-schema has a property to make fields mandatory - it's just not used yet.