transportenergy / database

Tools for accessing and maintaining the iTEM model & historical databases
https://transportenergy.rtfd.io
GNU General Public License v3.0
24 stars 8 forks source link

‘Usage’ docs example code is unhelpful; lru_cache calls not py3.7 compatible #41

Closed mfastudillo closed 3 years ago

mfastudillo commented 3 years ago

Hi, thanks for putting this together, it can be very useful.

I tried to follow the instructions to have a look to the database but after cloning the repo and installing it, when I execute data = item.load_model_data(1) I get the following error:

FileNotFoundError: [Errno 2] No such file or directory: '/pathtofolderwithrepos/database/database/1.csv'

Indeed in the database folder there is neiter a subfolder database nor a file called 1.csv .. is it maybe that instructions are outdated ?

best, Miguel

khaeru commented 3 years ago

Thanks for the question!

The key information here is in the README:

To meet the intellectual property concerns of workshop participants, the model database is currently not public, and only available on request; however, the tools used to prepare it are public. These tools are developed periodically, during sequential MIPs.

So there are a couple things to fix:

mfastudillo commented 3 years ago

Hello

1) item template results in a TypeError: Expected maxsize to be an integer or None 2) I understand that everybody has access to the historical database [ref]. It would be great to know how we can access to the harmonized data. This is actually the piece of data I am more interested in for the moment.

best, Miguel

khaeru commented 3 years ago
  1. item template results in a TypeError: Expected maxsize to be an integer or None

Thanks. Please give the details of your system and installation: OS, Python version, package management system, version of this package installed, etc.

  1. I understand that everybody has access to the historical database [ref]. It would be great to know how we can access to the harmonized data.

As it reads on the page:

The 2020-04-15 version of the database is attached to the Zenodo record for DOI 10.5281/zenodo.4121180.

mfastudillo commented 3 years ago

1) OS: ubuntu 20.04; python version 3.7.9, package management system : conda.. I need to check the version of the package, but I installed it using the repository a couple of days ago (although not in editable mode because it is a pain to uninstall).

2) I did check in Zenodo (which is how I arrived to the repository) but I can only see a csv file (iTEM harmonized_dataset.csv) with a few lines, one pointing to this repository and rule book pdf.

khaeru commented 3 years ago
  1. OS: ubuntu 20.04; python version 3.7.9, package management system : conda.. I need to check the version of the package, but I installed it using the repository a couple of days ago (although not in editable mode because it is a pain to uninstall).

Thank you! Can you please provide a full traceback, i.e. showing where the TypeError is raised?

  1. in Zenodo […] I can only see a csv file (iTEM harmonized_dataset.csv) with a few lines, one pointing to this repository and rule book pdf.

Huh. You're right! I hadn't noticed that. @soniayeh were you aware that that particular Zenodo record (https://zenodo.org/record/4121180) has a mostly empty CSV file attached?

mfastudillo commented 3 years ago

ok!

Traceback (most recent call last):
  File "/home/migmig/anaconda3/envs/bwreg/bin/item", line 33, in <module>
    sys.exit(load_entry_point('transport-energy', 'console_scripts', 'item')())
  File "/home/migmig/anaconda3/envs/bwreg/bin/item", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/home/migmig/anaconda3/envs/bwreg/lib/python3.7/site-packages/importlib_metadata/__init__.py", line 105, in load
    module = import_module(match.group('module'))
  File "/home/migmig/anaconda3/envs/bwreg/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/migmig/Documents/repos/database/item/cli.py", line 6, in <module>
    from item.historical.cli import historical
  File "/home/migmig/Documents/repos/database/item/historical/__init__.py", line 13, in <module>
    from .scripts import T000, T001, T003, T009
  File "/home/migmig/Documents/repos/database/item/historical/scripts/T009.py", line 27, in <module>
    @lru_cache
  File "/home/migmig/anaconda3/envs/bwreg/lib/python3.7/functools.py", line 490, in lru_cache
    raise TypeError('Expected maxsize to be an integer or None')
TypeError: Expected maxsize to be an integer or None
khaeru commented 3 years ago

@lru_cache works in Python 3.8+, but not in 3.7: https://docs.python.org/3/whatsnew/3.8.html#functools

So the fix will be to adjust that usage. I should also add CI on Python 3.7 so we catch things like that in the future.

khaeru commented 3 years ago

The “Usage” page should give a different example.

So the fix will be to adjust [the usage of @lru_cache]. I should also add CI on Python 3.7 so we catch things like that in the future.

These are now fixed on master; see the "latest" or "master" version of the docs: https://transportenergy.readthedocs.io/en/latest/usage.html#id1

I will roll another release shortly to include these, but in the meantime you could try installing from source.

khaeru commented 3 years ago
  1. I did check in Zenodo (which is how I arrived to the repository) but I can only see a csv file (iTEM harmonized_dataset.csv) with a few lines, one pointing to this repository and rule book pdf.

@mfastudillo FYI, https://zenodo.org/record/4287423 is a corrected Zenodo record with the complete file. I will make another PR later today to update the links in the documentation.