Skip to content

Commit

Permalink
Handle missing property defs with a warning (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs authored Oct 17, 2023
1 parent e58aefa commit d7fd87a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mc_optimade/mc_optimade/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def _parse_and_assign_properties(
for parser in PROPERTY_PARSERS[file_ext]:
try:
properties = parser(_path)
for id in parser(_path):
for id in properties:
parsed_properties[id].update(properties[id])
all_property_fields |= set(properties[id].keys())
break
Expand Down Expand Up @@ -310,6 +310,9 @@ def _parse_and_assign_properties(
# Loop over all defined properties and assign them to the entry, setting to None if missing
# Also cast types if provided
value = parsed_properties[id].get(property, None)
if property not in property_def_dict:
warnings.warn(f"Missing property definition for {property=}")
continue
if value is not None and property_def_dict[property].type in TYPE_MAP:
value = TYPE_MAP[property_def_dict[property].type](value)

Expand Down

0 comments on commit d7fd87a

Please sign in to comment.