Skip to content

KeyError: 'millimeter_Hg' from unit_conversion.py #88

@caufieldjh

Description

@caufieldjh

With a fresh install of either linkml-map 0.3.8 or 0.3.9-rc1, I get a KeyError when doing anything with the module (in this case, running through Poetry and Python 3.12.3):

$ poetry run linkml-map --help
Traceback (most recent call last):
  File "/home/harry/.cache/pypoetry/virtualenvs/brc-schema-ab5IJ14Z-py3.12/bin/linkml-map", line 5, in <module>
    from linkml_map.cli.cli import main
  File "/home/harry/.cache/pypoetry/virtualenvs/brc-schema-ab5IJ14Z-py3.12/lib/python3.12/site-packages/linkml_map/__init__.py", line 1, in <module>
    from linkml_map.transformer.object_transformer import ObjectTransformer
  File "/home/harry/.cache/pypoetry/virtualenvs/brc-schema-ab5IJ14Z-py3.12/lib/python3.12/site-packages/linkml_map/transformer/object_transformer.py", line 19, in <module>
    from linkml_map.functions.unit_conversion import UnitSystem, convert_units
  File "/home/harry/.cache/pypoetry/virtualenvs/brc-schema-ab5IJ14Z-py3.12/lib/python3.12/site-packages/linkml_map/functions/unit_conversion.py", line 28, in <module>
    UnitSystem.UCUM: PintUcumRegistry(),
                     ^^^^^^^^^^^^^^^^^^
  File "/home/harry/.cache/pypoetry/virtualenvs/brc-schema-ab5IJ14Z-py3.12/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 158, in __call__
    obj._after_init()
  File "/home/harry/.cache/pypoetry/virtualenvs/brc-schema-ab5IJ14Z-py3.12/lib/python3.12/site-packages/ucumvert/ucum_pint.py", line 351, in _after_init
    loaded_files = self.load_definitions(
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/harry/.cache/pypoetry/virtualenvs/brc-schema-ab5IJ14Z-py3.12/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 604, in load_definitions
    self._helper_dispatch_adder(definition)
  File "/home/harry/.cache/pypoetry/virtualenvs/brc-schema-ab5IJ14Z-py3.12/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 502, in _helper_dispatch_adder
    adder_func(definition)
  File "/home/harry/.cache/pypoetry/virtualenvs/brc-schema-ab5IJ14Z-py3.12/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 556, in _add_alias
    unit = unit_dict[definition.name]
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/collections/__init__.py", line 1015, in __getitem__
    return self.__missing__(key)            # support subclasses that define __missing__
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/collections/__init__.py", line 1007, in __missing__
    raise KeyError(key)
KeyError: 'millimeter_Hg'

Looks like the issue is upstream in pint and/or somewhere else.
I'll open a quick-fix PR but I'm guessing there's something else going on with unit conversions. Just need a new release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions