esm-tools / esm_version_checker

GNU General Public License v2.0
0 stars 0 forks source link

KeyError try/except #23

Closed pgierz closed 3 years ago

pgierz commented 3 years ago

Circumvents the weird bug:


Reading:
/mnt/lustre01/pf/a/a270077/conda-envs/mis3/lib/python3.8/site-packages/setup.cfg
Config for esm_runscripts is:
{'DEFAULT': <Section: DEFAULT>}
Traceback (most recent call last):
  File "/pf/a/a270077/conda-envs/mis3/bin/esm_versions", line 8, in <module>
    sys.exit(main())
  File "/pf/a/a270077/conda-envs/mis3/lib/python3.8/site-packages/click/core.py", line 1134, in __call__
    return self.main(*args, **kwargs)
  File "/pf/a/a270077/conda-envs/mis3/lib/python3.8/site-packages/click/core.py", line 1059, in main
    rv = self.invoke(ctx)
  File "/pf/a/a270077/conda-envs/mis3/lib/python3.8/site-packages/click/core.py", line 1665, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/pf/a/a270077/conda-envs/mis3/lib/python3.8/site-packages/click/core.py", line 1401, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/pf/a/a270077/conda-envs/mis3/lib/python3.8/site-packages/click/core.py", line 767, in invoke
    return __callback(*args, **kwargs)
  File "/pf/a/a270077/.local/lib/python3.8/site-packages/esm_version_checker/cli.py", line 266, in check
    attr_dict = get_esm_package_attributes(tool)
  File "/pf/a/a270077/.local/lib/python3.8/site-packages/esm_version_checker/cli.py", line 179, in get_esm_package_attributes
    v2 = config.get('bumpversion', {}).get('current_version')
  File "/pf/a/a270077/conda-envs/mis3/lib/python3.8/configparser.py", line 781, in get
    d = self._unify_values(section, vars)
  File "/pf/a/a270077/conda-envs/mis3/lib/python3.8/configparser.py", line 1149, in _unify_values
    raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'bumpversion'
mandresm commented 3 years ago

Hi Paul, this is an issue we had with Lars, and we figured it out what was going on.

The problem is that ESM-Tools thinks esm-pism is a ESM package, and not a plugging, and it is trying to get its version to print it into the esm_versions check output. I started to work on a fix for that but I could not finish it as other fixes were more urgent (and I am not familiar to the esm_version_checker so I'm slow), but we made a provisional solution for Lars. A git diff in the esm_version_checker of Lars will show you the changes necessary for the provisional fix.

mandresm commented 3 years ago

I see now this is not an issue but a pull request. This solution would also do :)

denizural commented 3 years ago

Another problem that is related to what @mandresm mentioned is that, we are getting the modules programmatically:

esm_tools_modules = [lib.key for lib in installed_packages if lib.key.startswith('esm-')]

clean tool does a similar thing, indeed in the previous version it removed a binary of mine that just contained the substring esm inside it (because it was using globbing). Therefore, my proposal is using a constant list of the esm_tools in the beginning of the code: ALL_ESM_TOOLS = ('esm_tools', esm_master', ...) to avoid any confusions. This will of course make the function get_esm_packages() obsolete.

What do you guys think?

mandresm commented 3 years ago

Another problem that is related to what @mandresm mentioned is that, we are getting the modules programmatically:

esm_tools_modules = [lib.key for lib in installed_packages if lib.key.startswith('esm-')]

clean tool does a similar thing, indeed in the previous version it removed a binary of mine that just contained the substring esm inside it (because it was using globbing). Therefore, my proposal is using a constant list of the esm_tools in the beginning of the code: ALL_ESM_TOOLS = ('esm_tools', esm_master', ...) to avoid any confusions. This will of course make the function get_esm_packages() obsolete.

What do you guys think?

I think this is a nice solution too, the problem is that these packages might change over time forcing us to have to maintain another line. What I was trying to do when trying to fix this issue for Lars was to actually look at the procedence of the esm- packages and if they would come from github.com/esm-tools then consider them as esm_tools packages. The problem is that finding out where packages come from is not particularly easy (or at least I didn't find a clean way of doing it without having to check git for editable installed packages and looking inside the metadata.json in the egg of the default installed packages).