gantian127 / pymt_era5

PyMT plugin for ERA5 dataset
MIT License
0 stars 1 forks source link

python 3.12 breaks pymt_era5 #1

Open Timothy-W-Hilton opened 10 months ago

Timothy-W-Hilton commented 10 months ago

First and foremost, thanks for this great tool and the example of wrapping a data product in the BMI.

I'm finding that the installation instructions do not produce a working pymt_Era5 installation for me. The culprit seems to be Python 3.12, which conda create -n pymt python=3 now defaults to. The install instructions work for me if I pin Python to 3.11.

Minimal working example:

mamba create --yes -n pymt311 python=3.11 pymt pymt_era5
mamba activate pymt311
python --version
python -c "from pymt.models import Era5;print(Era5.__name__)"

results in success:

Python 3.11.7
Era5

But allowing the default Python3 (currently 3.12.1) results in a failure to locate some package directories:

mamba create --yes  -n pymt3xx python=3 pymt pymt_era5
mamba activate pymt3xx
python --version
python -c "from pymt.models import Era5;print(Era5.__name__)"

results in:

Python 3.12.1
Traceback (most recent call last):
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/model_metadata/find.py", line 51, in find_metadata_files
    with as_cwd(datadir, create=False):
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/model_metadata/scripting.py", line 14, in as_cwd
    os.chdir(path)
FileNotFoundError: [Errno 2] No such file or directory: '/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/bmi_era5/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/pymt_era5/data/Era5'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/pymt/models.py", line 40, in <module>
    for model in _load_models():
                 ^^^^^^^^^^^^^^
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/pymt/models.py", line 23, in _load_models
    model = bmi_factory(model)
            ^^^^^^^^^^^^^^^^^^
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/pymt/framework/bmi_bridge.py", line 575, in bmi_factory
    class BmiWrapper(BmiCap):
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/pymt/framework/bmi_bridge.py", line 577, in BmiWrapper
    __doc__ = bmi_docstring(cls)
              ^^^^^^^^^^^^^^^^^^
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/pymt/framework/bmi_docstring.py", line 102, in bmi_docstring
    meta = PluginMetadata(plugin)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/pymt/framework/bmi_metadata.py", line 101, in __init__
    ModelMetadata.__init__(self, path_to_mmd)
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/model_metadata/modelmetadata.py", line 64, in __init__
    self._files = find_metadata_files(self._path)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/model_metadata/find.py", line 55, in find_metadata_files
    raise MetadataNotFoundError(datadir)
model_metadata.errors.MetadataNotFoundError: /home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/bmi_era5/home/timh/mambaforge/envs/pymt3xx/lib/python3.12/site-packages/pymt_era5/data/Era5
gantian127 commented 10 months ago

@Timothy-W-Hilton Thank you for posting the issue. I will look into it and try to find a solution for this.