IAMconsortium / pyam

Analysis & visualization of energy & climate scenarios
https://pyam-iamc.readthedocs.io/
Apache License 2.0
221 stars 115 forks source link

Refactor to use ixmp4 #766

Closed danielhuppmann closed 10 months ago

danielhuppmann commented 10 months ago

Please confirm that this PR has done the following:

Description of PR

This PR refactors the ScSeAuth class to not retrieve the token for connecting to a Scenario-Explorer database directly but instead use the default-auth from the ixmp4 package.

Because ixmp4 0.2.0 only supports python 3.10, older Python versions are remove and 3.11-tests are currently disabled.

There are two issues that make this new dependency a bit more elaborate than necessary:

codecov[bot] commented 10 months ago

Codecov Report

Merging #766 (5772adc) into main (e70a0b7) will increase coverage by 0.2%. The diff coverage is 70.9%.

@@           Coverage Diff           @@
##            main    #766     +/-   ##
=======================================
+ Coverage   94.4%   94.6%   +0.2%     
=======================================
  Files         62      62             
  Lines       6132    6107     -25     
=======================================
- Hits        5789    5779     -10     
+ Misses       343     328     -15     
Files Changed Coverage Δ
pyam/iiasa.py 89.8% <65.3%> (+2.6%) :arrow_up:
pyam/logging.py 65.0% <100.0%> (+0.8%) :arrow_up:
tests/test_iiasa.py 99.4% <100.0%> (+1.5%) :arrow_up:
tests/test_io.py 100.0% <100.0%> (+1.4%) :arrow_up:
phackstock commented 10 months ago

Quick question about future logins for non-ixmp4 projects. Say I need to read some data from the private NGFS phase 4 internal scenario Explorer after this change is live on pyam. Can I do that then?

danielhuppmann commented 10 months ago

Quick question about future logins for non-ixmp4 projects. Say I need to read some data from the private NGFS phase 4 internal scenario Explorer after this change is live on pyam. Can I do that then?

Good question, and please suggest how to make this clearer in the docs (if you think it's necessary).

Setting your credentials using ixmp4 login <username> (in a console) will work for Scenario-Explorer and ixmp4 Platform instances.

If you have already set your credentials via pyam v1.x and simply pull the latest version of pyam (and install ixmp4) and do nothing else, doing pyam.iiasa.Connection(...) will work, but you will get the following warning:

DeprecationWarning: Using a pyam-credentials file is deprecated and will be removed in future versions. 
Please run `ixmp4 login <username>` in a console and manually delete
the file '<your-home-directory>/.local/pyam/iiasa.yaml'.
phackstock commented 10 months ago

Setting your credentials using ixmp4 login (in a console) will work for Scenario-Explorer and ixmp4 Platform instances.

Ah ok I see that's good to know. I'll suggest an update to the docs then.

danielhuppmann commented 10 months ago

Is there an explicit test for authentication using ixmp4?

@meksor added several tests in ixmp4.