Skip to content
Snippets Groups Projects
Commit dd637a40 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

FIX(yaml-model-parser): add datatype and other missing attributes to...

FIX(yaml-model-parser): add datatype and other missing attributes to properties belonging to record types in data model
parent d753df87
No related branches found
No related tags found
2 merge requests!128MNT: Added a warning when column metadata is not configured, and a better...,!115add datatype, unit and description to properties that are part of Records
...@@ -37,18 +37,17 @@ to be a list with the names. Here, NO NEW entities can be defined. ...@@ -37,18 +37,17 @@ to be a list with the names. Here, NO NEW entities can be defined.
""" """
import argparse import argparse
import json import json
import jsonref
import re import re
import sys import sys
import yaml
from typing import List, Optional from typing import List, Optional
from warnings import warn from warnings import warn
import jsonref
import jsonschema import jsonschema
import linkahead as db import linkahead as db
import yaml
from linkahead.common.datatype import get_list_datatype from linkahead.common.datatype import get_list_datatype
from .data_model import LINKAHEAD_INTERNAL_PROPERTIES, DataModel from .data_model import LINKAHEAD_INTERNAL_PROPERTIES, DataModel
# Keywords which are allowed in data model descriptions. # Keywords which are allowed in data model descriptions.
...@@ -341,38 +340,37 @@ debug : bool, optional ...@@ -341,38 +340,37 @@ debug : bool, optional
f"invalid keyword in line {entity['__line__']}:", 1) f"invalid keyword in line {entity['__line__']}:", 1)
raise ValueError(err_str, *err.args[1:]) from err raise ValueError(err_str, *err.args[1:]) from err
# TODO: functionality commented out, to be able to test failing test first. # Update properties that are part of record types:
# Update properties that are part of record types: # e.g. add their datatypes, units etc..
# e.g. add their datatypes, units etc.. # Otherwise comparison of existing models and the parsed model become difficult.
# Otherwise comparison of existing models and the parsed model become difficult. for name, ent in self.model.items():
# for name, ent in self.model.items(): if not isinstance(ent, db.RecordType):
# if not isinstance(ent, db.RecordType): continue
# continue props = ent.get_properties()
# props = ent.get_properties() for prop in props:
# for prop in props: if prop.name in self.model:
# if prop.name in self.model: model_prop = self.model[prop.name]
# model_prop = self.model[prop.name] # The information must be missing, we don't want to overwrite it accidentally:
# # The information must be missing, we don't want to overwrite it accidentally: if prop.datatype is not None and prop.datatype != model_prop.datatype:
# if prop.datatype is not None and prop.datatype != model_prop.datatype: # breakpoint()
# # breakpoint() raise RuntimeError("datatype must not be set, here. This is probably a bug.")
# raise RuntimeError("datatype must not be set, here. This is probably a bug.") if prop.unit is not None and prop.unit != model_prop.unit:
# if prop.unit is not None and prop.unit != model_prop.unit: # continue
# # continue raise RuntimeError("unit must not be set, here. This is probably a bug.")
# raise RuntimeError("unit must not be set, here. This is probably a bug.") if prop.description is not None and prop.description != model_prop.description:
# if prop.description is not None and prop.description != model_prop.description: # continue
# # continue raise RuntimeError("description must not be set, here. This is probably a bug.")
# raise RuntimeError("description must not be set, here. This is probably a bug.")
# # If this property has a more detailed definition in the model,
# # If this property has a more detailed definition in the model, # copy over the information:
# # copy over the information:
# if isinstance(model_prop, db.RecordType):
# if isinstance(model_prop, db.RecordType): # in this case the datatype equals the name of the record type:
# # in this case the datatype equals the name of the record type: prop.datatype = prop.name
# prop.datatype = prop.name else:
# else: prop.datatype = model_prop.datatype
# prop.datatype = model_prop.datatype prop.unit = model_prop.unit
# prop.unit = model_prop.unit prop.description = model_prop.description
# prop.description = model_prop.description
return DataModel(self.model.values()) return DataModel(self.model.values())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment