CABLE-LSM / benchcab

Tool for evaluation of CABLE land surface model
https://benchcab.readthedocs.io/en/latest/
Apache License 2.0
2 stars 4 forks source link

FileNotFoundError when running benchcab v4.0.0 #267

Closed SeanBryan51 closed 8 months ago

SeanBryan51 commented 8 months ago

Running benchcab run with benchcab v4.0.0 fails to load resources from the package data directory and throws a FileNotFoundError:

$ benchcab run
Traceback (most recent call last):
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/bin/benchcab", line 10, in <module>
    sys.exit(main())
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/lib/python3.10/site-packages/benchcab/main.py", line 42, in main
    parse_and_dispatch(parser)
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/lib/python3.10/site-packages/benchcab/main.py", line 32, in parse_and_dispatch
    func(**args)
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/lib/python3.10/site-packages/benchcab/benchcab.py", line 368, in run
    self.checkout(config_path)
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/lib/python3.10/site-packages/benchcab/benchcab.py", line 221, in checkout
    config = self._get_config(config_path)
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/lib/python3.10/site-packages/benchcab/benchcab.py", line 136, in _get_config
    self._config = read_config(config_path)
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/lib/python3.10/site-packages/benchcab/config.py", line 169, in read_config
    validate_config(config)
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/lib/python3.10/site-packages/benchcab/config.py", line 58, in validate_config
    schema = bu.load_package_data("config-schema.yml")
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/lib/python3.10/site-packages/benchcab/utils/__init__.py", line 56, in load_package_data
    raw = pkgutil.get_data("benchcab", os.path.join("data", filename)).decode("utf-8")
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/lib/python3.10/pkgutil.py", line 639, in get_data
    return loader.get_data(resource_name)
  File "<frozen importlib._bootstrap_external>", line 1073, in get_data
FileNotFoundError: [Errno 2] No such file or directory: '/g/data/hh5/public/apps/miniconda3/envs/analysis3-24.01/lib/python3.10/site-packages/benchcab/data/config-schema.yml'

To reproduce:

module load conda/analysis3-unstable
cd /scratch/$PROJECT/$USER
git clone git@github.com:CABLE-LSM/bench_example.git bench_example_tmp
cd bench_example_tmp
benchcab run

I have also reproduced the error in a custom conda environment.

SeanBryan51 commented 8 months ago

The uploaded tarball for benchcab v4.0.0 is missing the site-packages/benchcab/data directory (see https://anaconda.org/accessnri/benchcab/files).

Building the conda package locally on Gadi and installing it seems to include the data directory which is strange. Perhaps something specific to the automated deployment is broken (workflow logs for the deployment are here: https://github.com/CABLE-LSM/benchcab/actions/runs/8182061626/job/22372810738).

SeanBryan51 commented 8 months ago

I've managed to reproduce and fix the error in my personal fork of benchcab by replacing the include_package_data option in setup.cfg with the package_data option.

Hot fix release coming soon.

SeanBryan51 commented 8 months ago

It might be possible that we are not testing the installed version of the package in our CI workflow. This is one of the major disadvantages in using a flat layout. It would be interesting to see if the CI fails to find the data directory when switching to a src layout.

*Edit: switching to src layout and removing the package_data option causes the CI to fail to find the data directory: https://github.com/SeanBryan51/benchcab/actions/runs/8353949217/job/22866490538?pr=2. We should make this change before resolving this issue.