linkml / schema-automator

Automated assistance for the schema development lifecycle
https://linkml.io/schema-automator/
BSD 3-Clause "New" or "Revised" License
33 stars 12 forks source link

`convert_dicts` throws a TypeError with nested lists #85

Open ialarmedalien opened 1 year ago

ialarmedalien commented 1 year ago

Describe the bug

convert_dicts throws a TypeError with nested lists

To Reproduce

Create a file containing the following JSON data:

{
    "date-parts": [
        [
            2011,
            9,
            29
        ]
    ]
}

run schemauto generalize-json on the file

behold the stack trace:

Traceback (most recent call last):
  File "/Users/gwg/code/kbase/credit_engine/.venv/bin/schemauto", line 8, in <module>
    sys.exit(main())
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/schema_automator/cli.py", line 218, in generalize_json
    schema = ie.convert(input, format=format, **kwargs)
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/schema_automator/generalizers/json_instance_generalizer.py", line 64, in convert
    schema = csv_engine.convert_dicts(rows_dict, cn, cn)
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/schema_automator/generalizers/csv_data_generalizer.py", line 349, in convert_dicts
    slot_values[k].update(vs)
TypeError: unhashable type: 'list'