Relecov schema and schema generation - Patch changes#844
Conversation
| else enum_list | ||
| def resolve_enum_ref(ref: str, enum_defs: dict) -> list[str]: | ||
| property_id = ref.split("/")[-1] | ||
| values = enum_defs[property_id]["enum"] |
There was a problem hiding this comment.
You declare enum_defs = json_schema.get("$defs", {}).get("enums", {}) before, leaving the possibility of this variable to be an empty dict. In that case this line would crash without option to track the original error. I'd suggest adding a try/except clause either here or in the definition of enum_defs
There was a problem hiding this comment.
Good catch! Many thanks :) I've updated it so that this exception is caught by property, so if multiple property enums are missing from defs (maybe in the future we add something that deletes some by accident) it spits the error like this (Example for missing "organism" enums):
...
Enter a note about changes made to the schema: asads
Error finding enum for property 'organism'; not found in $defs
Metadata lab template successfuly created in:
...
Right now it does continue generating the template and finishes somewhat successfully (No enums for those properties, though), I could raise an error and exit or leave it like that. What do you prefer?
PR Checklist
black and flake8).CHANGELOG.mdis updated.README.mdis updated (including new tool citations and authors/contributors).Changes
Described more thoroughly here: #835 . AI below:
build_schema.pymodule so that it fixes typos on the fly.descriptionalways ends in.(Unless finished in a)) and has no spaces at the beginning or the endexamplesare the same type as the fieldbuild_schema.pymodule to reference enums in$defsand move them to the end.identifiers_org_prefixkeyword in options