Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OMI omits null values from json during processing #71

Closed
chrwm opened this issue Oct 31, 2022 · 0 comments · Fixed by #72
Closed

OMI omits null values from json during processing #71

chrwm opened this issue Oct 31, 2022 · 0 comments · Fixed by #72
Assignees
Labels
type: enhancement ⚙️ Improvement of an existing feature

Comments

@chrwm
Copy link
Member

chrwm commented Oct 31, 2022

When omi processes json metadata it omits values and metadata that are null.
This is due when omi reads a json into a python dict, null is read in as None. This results in missing metadata fields when compiling with omi.

e.g. missing description field and unit field

input

"schema": {
                "fields": [
                    {
                        "name": "fid",
                        "description": null,
                        "type": "int",
                        "unit": null,
                        "isAbout": [
                            {
                                "name": null,
                                "path": null
                            }
                        ],
                        "valueReference": [
                            {
                                "value": null,
                                "name": null,
                                "path": null
                            }
                        ]
                    }

output

 "schema": {
                "primaryKey": [],
                "foreignKeys": [],
                "fields": [{
                        "name": "fid",
                        "type": "int",
                        "isAbout": [{}
                        ],
                        "valueReference": [{}
                        ]
                    }

This is important as oem2orm throughs an error for some keys when generating tables from metadata for the OEP and they're missing, e.g. description.

ERROR:Could not generate tables from metadatafile:

KeyError                                  Traceback (most recent call last)
<ipython-input-17-7e96dde4dbd2> in <module>
----> 1 tables_orm = oem2orm.collect_tables_from_oem(db, metadata_folder)

~\Miniconda3\envs\p_py38_oep-upload\lib\site-packages\oem2orm\oep_oedialect_oem2orm.py in collect_tables_from_oem(db, oem_folder_path)
    272     for metadata_file in metadata_files:
    273         try:
--> 274             md_tables = create_tables_from_metadata_file(db, metadata_file)
    275             logging.info(md_tables)
    276         except:

~\Miniconda3\envs\p_py38_oep-upload\lib\site-packages\oem2orm\oep_oedialect_oem2orm.py in create_tables_from_metadata_file(db, metadata_file)
    217                     column_type,
    218                     primary_key=field["name"] in primary_keys,
--> 219                     comment=field["description"],
    220                 )
    221             columns.append(column)

KeyError: 'description'

The current status makes automatic metadata processing and upload impracticable.

EDIT

After implementing omit_none=False results

output

"schema": {
                "primaryKey": [],
                "foreignKeys": [],
                "fields": [{
                        "name": "fid",
                        "description": null,
                        "type": "int",
                        "isAbout": [{
                                "name": null,
                                "path": null
                            }
                        ],
                        "valueReference": [{
                                "value": null,
                                "name": null,
                                "path": null
                            }
                        ],
                        "unit": null
                    }
@chrwm chrwm added the type: enhancement ⚙️ Improvement of an existing feature label Oct 31, 2022
@chrwm chrwm self-assigned this Oct 31, 2022
chrwm added a commit that referenced this issue Oct 31, 2022
With changing to False, metadata json keys and values will remain in the metadata as `null` after processing with omi.
jh-RLI added a commit that referenced this issue Jan 19, 2024
…s omit the none value from json because the static test structures used to compare the results also do not include nones / nulls #71
jh-RLI added a commit that referenced this issue Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement ⚙️ Improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant