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

unhashable type: 'CodeableConcept' when loading programmatically created data file #154

Open
turbomam opened this issue Nov 11, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@turbomam
Copy link
Member

turbomam commented Nov 11, 2021

I don't know if this is a LinkML error or something specific to the CRDC-H model, so I will cross post an issue in linkml/linkml

Run make all from this branch issue-27-codable-concept-notebooks in the example-data repo

make all clears and recreates the somewhat top-heavy piping virtual environment used elsewhere in this repo, so that could take a few minutes.

See gen_diag_with_stage_obs_set.py for the code that creates the problematic YAML data file.

@turbomam turbomam added the bug Something isn't working label Nov 11, 2021
@turbomam
Copy link
Member Author

I see this error under Python 3.9 on an Apple Silicon MacBook and under 3.8 on an Intel Ubuntu 20 system.

@turbomam
Copy link
Member Author

rm -rf gen_diag_with_stage_obs_set.yaml
rm -rf Pipfile.lock
pipenv --rm
Removing virtualenv (/Users/mark/.local/share/virtualenvs/example-data-iClEazcJ)...
pipenv install
Creating a virtualenv for this project...
Pipfile: /Users/mark/gitrepos/example-data/Pipfile
Using /opt/homebrew/bin/python3 (3.9.7) to create virtualenv...
⠹ Creating virtual environment...created virtual environment CPython3.9.7.final.0-64 in 149ms
  creator CPython3Posix(dest=/Users/mark/.local/share/virtualenvs/example-data-iClEazcJ, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/mark/Library/Application Support/virtualenv)
    added seed packages: pip==21.3.1, setuptools==58.3.0, wheel==0.37.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment! 
Virtualenv location: /Users/mark/.local/share/virtualenvs/example-data-iClEazcJ
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success! 
Updated Pipfile.lock (6421a4)!
Installing dependencies from Pipfile.lock (6421a4)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 134/134 — 00:05:08
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
pipenv run pip list
Package                       Version
----------------------------- ---------
alabaster                     0.7.12
antlr4-python3-runtime        4.9.3
appnope                       0.1.2
argon2-cffi                   21.1.0
attrs                         21.2.0
Babel                         2.9.1
backcall                      0.2.0
bleach                        4.1.0
cachetools                    4.2.4
certifi                       2021.10.8
cffi                          1.15.0
CFGraph                       0.2.1
charset-normalizer            2.0.7
click                         7.1.2
crdch-model                   1.1.5
debugpy                       1.5.1
decorator                     5.1.0
defusedxml                    0.7.1
Deprecated                    1.2.13
docutils                      0.17.1
entrypoints                   0.3
et-xmlfile                    1.1.0
frozendict                    2.0.7
graphviz                      0.18
hbreader                      0.9.1
idna                          3.3
imagesize                     1.3.0
iniconfig                     1.1.1
ipykernel                     6.5.0
ipython                       7.29.0
ipython-genutils              0.2.0
ipywidgets                    7.6.5
isodate                       0.6.0
jedi                          0.18.0
Jinja2                        3.0.3
json-flattener                0.1.7
jsonasobj                     1.3.1
jsonasobj2                    1.0.4
jsonpatch                     1.32
jsonpath-ng                   1.5.3
jsonpointer                   2.2
jsonschema                    4.2.1
jupyter                       1.0.0
jupyter-client                7.0.6
jupyter-console               6.4.0
jupyter-core                  4.9.1
jupyterlab-pygments           0.1.2
jupyterlab-widgets            1.0.2
linkml                        1.1.12
linkml-runtime                1.1.6
linkml-runtime-api            0.0.4
lxml                          4.6.4
markdown-it-py                1.1.0
MarkupSafe                    2.0.1
matplotlib-inline             0.1.3
mdit-py-plugins               0.2.8
mistune                       0.8.4
myst-parser                   0.15.2
nbclient                      0.5.5
nbconvert                     6.2.0
nbformat                      5.1.3
nest-asyncio                  1.5.1
notebook                      6.4.5
numpy                         1.21.4
openpyxl                      3.0.9
packaging                     21.2
pandas                        1.3.4
pandocfilters                 1.5.0
parse                         1.19.0
parso                         0.8.2
pexpect                       4.8.0
pickleshare                   0.7.5
pip                           21.3.1
pluggy                        1.0.0
ply                           3.11
prefixcommons                 0.1.9
prologterms                   0.0.6
prometheus-client             0.12.0
prompt-toolkit                3.0.22
ptyprocess                    0.7.0
py                            1.11.0
pycparser                     2.21
pydantic                      1.8.2
Pygments                      2.10.0
PyJSG                         0.11.6
PyLD                          2.0.3
PyLDmod                       2.0.5
pyparsing                     2.4.7
pyrsistent                    0.18.0
PyShEx                        0.7.20
PyShExC                       0.8.3
pytest                        6.2.5
python-dateutil               2.8.2
pytz                          2021.3
PyYAML                        5.4.1
pyzmq                         22.3.0
qtconsole                     5.2.0
QtPy                          1.11.2
rdflib                        5.0.0
rdflib-jsonld                 0.6.1
rdflib-pyldmod-compat         0.1.2
requests                      2.26.0
ruamel.yaml                   0.17.17
ruamel.yaml.clib              0.2.6
Send2Trash                    1.8.0
setuptools                    58.5.3
ShExJSG                       0.7.1
six                           1.16.0
snowballstemmer               2.1.0
sparqlslurper                 0.4.1
SPARQLWrapper                 1.8.5
Sphinx                        4.3.0
sphinx-click                  3.0.2
sphinx-rtd-theme              1.0.0
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.5
SQLAlchemy                    1.4.26
terminado                     0.12.1
testfixtures                  6.18.3
testpath                      0.5.0
toml                          0.10.2
tornado                       6.1
traitlets                     5.1.1
typing-extensions             3.10.0.2
urllib3                       1.26.7
watchdog                      2.1.6
wcwidth                       0.2.5
webencodings                  0.5.1
wheel                         0.37.0
widgetsnbextension            3.5.2
wrapt                         1.13.3
pipenv run python gen_diag_with_stage_obs_set.py
cat gen_diag_with_stage_obs_set.yaml
stage:
- method_type:
  - coding:
    - code: C125738
      system: http://ncithesaurus.nci.nih.gov/
      label: FIGO Stage
      tag:
      - harmonized
  observations:
  - observation_type:
      coding:
      - code: C25605
        system: http://ncithesaurus.nci.nih.gov/
        label: Overall
        tag:
        - harmonized
    value_codeable_concept:
      coding:
      - code: C96258
        system: http://ncithesaurus.nci.nih.gov/
        label: FIGO Stage IIIC
        tag:
        - harmonized
pipenv run python instantiate_diag_with_stage_obs_set.py
Traceback (most recent call last):
  File "/Users/mark/gitrepos/example-data/instantiate_diag_with_stage_obs_set.py", line 6, in <module>
    diag = yaml_loader.load(diagnosis_fn, Diagnosis)
  File "/Users/mark/.local/share/virtualenvs/example-data-iClEazcJ/lib/python3.9/site-packages/linkml_runtime/loaders/yaml_loader.py", line 22, in load
    return self.load_source(source, loader, target_class, accept_header="text/yaml, application/yaml;q=0.9",
  File "/Users/mark/.local/share/virtualenvs/example-data-iClEazcJ/lib/python3.9/site-packages/linkml_runtime/loaders/loader_root.py", line 62, in load_source
    target_class(**as_dict(data_as_dict)) if data_as_dict is not None else None
  File "<string>", line 20, in __init__
  File "/Users/mark/.local/share/virtualenvs/example-data-iClEazcJ/lib/python3.9/site-packages/crdch_model.py", line 579, in __post_init__
    self.stage = [v if isinstance(v, CancerStageObservationSet) else CancerStageObservationSet(**as_dict(v)) for v in self.stage]
  File "/Users/mark/.local/share/virtualenvs/example-data-iClEazcJ/lib/python3.9/site-packages/crdch_model.py", line 579, in <listcomp>
    self.stage = [v if isinstance(v, CancerStageObservationSet) else CancerStageObservationSet(**as_dict(v)) for v in self.stage]
  File "<string>", line 10, in __init__
  File "/Users/mark/.local/share/virtualenvs/example-data-iClEazcJ/lib/python3.9/site-packages/crdch_model.py", line 443, in __post_init__
    self._normalize_inlined_as_list(slot_name="observations", slot_type=CancerStageObservation, key_name="observation_type", keyed=False)
  File "/Users/mark/.local/share/virtualenvs/example-data-iClEazcJ/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py", line 97, in _normalize_inlined_as_list
    self._normalize_inlined(slot_name, slot_type, key_name, keyed, True)
  File "/Users/mark/.local/share/virtualenvs/example-data-iClEazcJ/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py", line 181, in _normalize_inlined
    order_up(cooked_obj[key_name], cooked_obj)
  File "/Users/mark/.local/share/virtualenvs/example-data-iClEazcJ/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py", line 132, in order_up
    cooked_keys.add(key)
TypeError: unhashable type: 'CodeableConcept'
make: *** [instantiate] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant