openENTRANCE/openentrance

Problem after renaming of package

HauHe opened this issue · 7 comments

HauHe commented

Hi,

not sure if this is the right place to write. Sorry if not.

After updating the openentrance package from nomenclature to openEntrance I'm facing problems.
I already deleted the environment in which I had installed the package before and also created a new clone.
But I'm still getting this error:
Traceback (most recent call last): File "/Users/cotti/GitHub/OSeMOSYS/osemosys2iamc/resultify.py", line 16, in <module> import openentrance as oe File "/Users/cotti/GitHub/OpenEntrance/openentrance/openentrance/__init__.py", line 3, in <module> from nomenclature import CodeList ImportError: cannot import name 'CodeList' from 'nomenclature' (/Users/cotti/opt/anaconda3/envs/osemosys2iamc/lib/python3.10/site-packages/nomenclature/__init__.py)

Does anyone have an idea what might be the issue?

I guess that you installed the "wrong" nomenclature package, namely https://pypi.org/project/nomenclature/ instead of https://pypi.org/project/nomenclature-iamc/ - sorry for this inconvenience...

Use pip install nomenclature-iamc to install from pypi or
pip install git+git://github.com/iamconsortium/nomenclature - see also the requirements.txt in this repo.

Please confirm if this solves your issue.

HauHe commented

Thanks for the fast answer @danielhuppmann !
I actually did the editable installation as shown in the instructions here https://github.com/openENTRANCE/openentrance/tree/main/openentrance
I ignored that it there still says that the folder in the repo is named nomenclature, but it should probably have told me that the instruction was outdated. I will try your suggestion and come back to you.

HauHe commented

Hi @danielhuppmann,
installation fixed the previous issue. But now I get the following error when running a script in which use the nomenclature package.
/Users/cotti/GitHub/OSeMOSYS/osemosys2iamc/resultify.py:57: UserWarning: This pattern has match groups. To actually get the groups, use str.extract. mask = df['TECHNOLOGY'].str.contains(technologies[t]) /Users/cotti/GitHub/OSeMOSYS/osemosys2iamc/resultify.py:73: UserWarning: This pattern has match groups. To actually get the groups, use str.extract. mask = df['TECHNOLOGY'].str.contains(technologies[t]) Traceback (most recent call last): File "/Users/cotti/GitHub/OSeMOSYS/osemosys2iamc/resultify.py", line 288, in <module> all_data = main(config) File "/Users/cotti/GitHub/OSeMOSYS/osemosys2iamc/resultify.py", line 270, in main all_data.index = all_data.index.set_levels(all_data.index.levels[2].map(nc.iso_mapping), level=2) AttributeError: module 'nomenclature' has no attribute 'iso_mapping'
Perhaps I missunderstood something when you explained the change in packages. Is the iso_mapping not part of the nomenclature package anymore?

Ok, these installation instructions need to updated, thanks for pointing this out!

About the iso_mapping attribute... We followed a "separation of concerns" strategy:

  • the nomenclature package has the utility methods and classes for codelist definitions and region-processing independent of any particular project
  • the openentrance repository has the actual codelists, definitions and configurations for this project

Therefore, the iso_mapping is part of the openentrance package, which can be installed from this repository, because it is a concrete list of values.

If you pip-install-editable from this repository, you should be able to do the following

from openentrance import iso_mapping

See this unit test, which ensures that this feature works as expected: https://github.com/openENTRANCE/openentrance/blob/main/tests/test_core.py

HauHe commented

Great! Thanks a lot @danielhuppmann now it is working.

Hi,
I got the same issue and followed the steps. But still it is not working for me.
There is no validation function anymore in the "openentracne" package?
I included this like shown here:

import openentrance as oe
oe.validate(...)

Correct, the validation function is now a part of the nomenclature-iamc package, to have a clear separation between the Python utility package and the definitions used in a specific project. This makes it a lot easier to reuse the Python utilities across different projects.

You can use the processing-notebook in this repository to run the validation locally, see https://github.com/openENTRANCE/openentrance/blob/main/processing-workflow.ipynb. This performs some additional steps, including the region-processing and formatting from date-time to year+subannual format (if applicable).

Note that you have to install the new package as pip install nomenclature-iamc (or editable from the GitHub repo clone).

I apologize for the inconvenience.