csdms / babelizer

Transform BMI-wrapped models into Python packages
https://babelizer.readthedocs.io
MIT License
4 stars 3 forks source link

model_metadata can't find model metadata #35

Closed mdpiper closed 3 years ago

mdpiper commented 3 years ago

The model_metadata package can't find the metadata for an installed pymt component rendered through the babelizer.

>>> import pymt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mpiper/anaconda3/envs/gridmet_bmi/lib/python3.9/site-packages/pymt/__init__.py", line 6, in <module>
    MODELS = ModelCollection()
  File "/Users/mpiper/anaconda3/envs/gridmet_bmi/lib/python3.9/site-packages/pymt/model_collection.py", line 23, in __new__
    models.append(ModelCollection.load_entry_point(entry_point))
  File "/Users/mpiper/anaconda3/envs/gridmet_bmi/lib/python3.9/site-packages/pymt/model_collection.py", line 70, in load_entry_point
    Model = bmi_factory(model)
  File "/Users/mpiper/anaconda3/envs/gridmet_bmi/lib/python3.9/site-packages/pymt/framework/bmi_bridge.py", line 772, in bmi_factory
    class BmiWrapper(BmiCap):
  File "/Users/mpiper/anaconda3/envs/gridmet_bmi/lib/python3.9/site-packages/pymt/framework/bmi_bridge.py", line 774, in BmiWrapper
    __doc__ = bmi_docstring(cls)
  File "/Users/mpiper/anaconda3/envs/gridmet_bmi/lib/python3.9/site-packages/pymt/framework/bmi_docstring.py", line 103, in bmi_docstring
    meta = ModelMetadata.from_obj(plugin)
  File "/Users/mpiper/anaconda3/envs/gridmet_bmi/lib/python3.9/site-packages/model_metadata/modelmetadata.py", line 93, in from_obj
    path_to_metadata = ModelMetadata.find(obj)
  File "/Users/mpiper/anaconda3/envs/gridmet_bmi/lib/python3.9/site-packages/model_metadata/modelmetadata.py", line 184, in find
    raise MetadataNotFoundError(str(model))
model_metadata.errors.MetadataNotFoundError: <class 'gridmet_bmi.bmi_gridmet.BmiGridmet'>

A workaround is to change the installed metadata directory name from data to meta. For example, changing

lib/python3.9/site-packages/pymt_gridmet/data

to

lib/python3.9/site-packages/pymt_gridmet/meta

resolves the issue.

mdpiper commented 3 years ago

It looks like the babelizer isn't directing the metadata to be installed in the correct location. I think I have a solution, which I'll submit as a PR, but I wanted to create an issue in case it's not appropriate.