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

Help with `AttributeError: 'NoneType' object has no attribute 'classes'` #99

Open matentzn opened 1 year ago

matentzn commented 1 year ago

In a fresh (empty) virtual environment am trying:

pip install -U pip
pip install -U schema-automator

Strangely some dependency conflict precludes installation of 1.3.5 linkml.

pip list | grep link
linkml                        1.3.0
linkml-dataops                0.1.0
linkml-runtime                1.3.2

Now when I run (see here):

make target/omop_5.yaml
schemauto generalize-tsvs --schema-name omop_vocabulary local/CONCEPT_RELATIONSHIP_HEAD.csv local/CONCEPT_ANCESTOR.csv local/CONCEPT_CLASS.csv local/CONCEPT_SYNONYM.csv local/CONCEPT.csv local/DOMAIN.csv local/DRUG_STRENGTH.csv local/RELATIONSHIP.csv local/VOCABULARY.csv > target/omop_5.yaml
Traceback (most recent call last):
  File "/Users/matentzn/.pyenv/versions/3.10.4/envs/linkml/bin/schemauto", line 8, in <module>
    sys.exit(main())
  File "/Users/matentzn/.pyenv/versions/3.10.4/envs/linkml/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/matentzn/.pyenv/versions/3.10.4/envs/linkml/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/matentzn/.pyenv/versions/3.10.4/envs/linkml/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/matentzn/.pyenv/versions/3.10.4/envs/linkml/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/matentzn/.pyenv/versions/3.10.4/envs/linkml/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/matentzn/.pyenv/versions/3.10.4/envs/linkml/lib/python3.10/site-packages/schema_automator/cli.py", line 139, in generalize_tsvs
    schema = ie.convert_multiple(tsvfiles, schema_name=schema_name)
  File "/Users/matentzn/.pyenv/versions/3.10.4/envs/linkml/lib/python3.10/site-packages/schema_automator/generalizers/csv_data_generalizer.py", line 218, in convert_multiple
    logging.info(f'Classes={list(s.classes.keys())}')
AttributeError: 'NoneType' object has no attribute 'classes'
make: *** [target/omop_5.yaml] Error 1

I am able to run generalize-tsv on a smaller dataset w/o problems. Any idea what could be wrong?

matentzn commented 1 year ago

I think I found the source of the problem:

While this works in generalize-tsv, generalize-tsvs flakes out if you provide an empty table.

cmungall commented 1 year ago

What's the preferred behavior here:

  1. Throw an informative Error
  2. Ignore the empty table
  3. Create a class with no slots

I favor 1 as default, with an option to do 2

I can't think of a scenario where 3 is desired for generalization

matentzn commented 1 year ago

I agree with your preference. I do think 1 default and 3 is also an option if the table has columns, since you can add slots with string range for these?

matentzn commented 1 year ago

I will reopen this for some tiny reason:

matentzn commented 1 year ago

(Close immediately if it does)

cmungall commented 1 year ago

Thanks for reopening. I agree with your assessment, we can still make a class if column headers are present

On Sun, Nov 20, 2022 at 8:33 AM Nico Matentzoglu @.***> wrote:

I will reopen this for some tiny reason:

  • What if the table has columns, but no rows? Does your judgement above still hold?

— Reply to this email directly, view it on GitHub https://github.com/linkml/schema-automator/issues/99#issuecomment-1321176312, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMMOOVCGIYMECQMPFOPD3WJJHFPANCNFSM6AAAAAAQ257HLI . You are receiving this because you modified the open/close state.Message ID: @.***>