Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conn auth #243

Merged
merged 26 commits into from
Jul 30, 2019
Merged

Conn auth #243

merged 26 commits into from
Jul 30, 2019

Conversation

gidden
Copy link
Member

@gidden gidden commented Jul 8, 2019

Please confirm that this PR has done the following:

  • Tests Added
  • Documentation Added
  • Description in RELEASE_NOTES.md Added

This PR adds the ability to connect to non-public databases by providing a username and password.

TODO:

  • this currently also requires knowledge of an "application" name. For example, for the SR1.5 explorer, the "short name" is iamc15 and the "application name" is IXSE_SR15. We should decide which to go with in the end. To note, utilizing the "short name" will require an additional mapping in the python code (to the best of my knowledge), which was seen as desirable to avoid. In any case, I think we should limit the user to needing to know only one name.
  • decide on how to pass over credentials. Options: 1) leave as is and it is up to the user to store them properly. 2) support reading/writing from a config file. 3) support passing over env variables. 4) both 2 & 3
  • add functionality to check success of requests (likely as a context manager)

@coveralls
Copy link

coveralls commented Jul 8, 2019

Coverage Status

Coverage increased (+0.2%) to 91.083% when pulling a473118 on conn-auth into a134b46 on master.

@gidden
Copy link
Member Author

gidden commented Jul 8, 2019

@byersiiasa if you want to get started working on AR6, you can use this branch to do so. You'll need to coordinate the naming conventions with @zikolach and @fonfon

pyam/iiasa.py Outdated Show resolved Hide resolved
@fonfon
Copy link
Contributor

fonfon commented Jul 8, 2019

For the application names I'd prefer to fetch them from the auth-server and see how that goes. If we hard-code a lookup dict here it will become tedious (or forgotten) to keep it up to date, even if the application names do not change very often.
Users would then have to provide the application name though, like listed on https://data.ene.iiasa.ac.at/auth/#/apps

pyam/iiasa.py Outdated Show resolved Hide resolved
@gidden
Copy link
Member Author

gidden commented Jul 9, 2019

Ok @fonfon, happy to make this more amenable to the existing REST API features. Let's discuss when we're both in the office/on slack.

@gidden
Copy link
Member Author

gidden commented Jul 9, 2019

Here is the example how users can currently interact with the pyam.iiasa.Connection class: https://pyam-iamc.readthedocs.io/en/stable/tutorials/iiasa_dbs.html

@byersiiasa
Copy link
Collaborator

@byers if you want to get started working on AR6, you can use this branch to do so. You'll need to coordinate the naming conventions with @zikolach and @fonfon

thanks I'll try this today - for some reason I didn't get a notification

pyam/iiasa.py Outdated Show resolved Hide resolved
pyam/iiasa.py Outdated Show resolved Hide resolved
@gidden
Copy link
Member Author

gidden commented Jul 9, 2019

Note that this needs iiasa/auth_server#53 to continue further

tests/test_iiasa.py Outdated Show resolved Hide resolved
pyam/iiasa.py Outdated Show resolved Hide resolved
@gidden
Copy link
Member Author

gidden commented Jul 12, 2019

Hi folks, from my perspective this PR is now complete and ready for final review. @fonfon @byersiiasa and/or @danielhuppmann would you mind taking a final look?

Copy link
Member

@danielhuppmann danielhuppmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment on a docstring, otherwise looks good.

But I see the risk with that approach that users will store their credentials in notebooks, maybe even committing those to GitHub by mistake. Any thoughts on that?

More generally, I think it is not ideal that the API uses database-instance-names and not "nice" names like "iamc15", @fonfon @zikolach. Maybe that was the easier implementation for a quick solution, but sub-optimal from a user-experience point-of-view.

pyam/iiasa.py Outdated Show resolved Hide resolved
Copy link
Contributor

@zikolach zikolach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gidden please have a look on comments

pyam/iiasa.py Outdated Show resolved Hide resolved
pyam/iiasa.py Show resolved Hide resolved
@gidden
Copy link
Member Author

gidden commented Jul 15, 2019

@danielhuppmann @zikolach @fonfon (and @khaeru if you're interested)

I have listed a set of TODOs in the PR summary. Could you please provide input/opinions on items 1 and 2?

Namely, for credentials, I see a lot of potential problems here. E.g., if we want to support environment variables explicitly, once they are set, a user can no longer get explicitly to public dbs as "anonymous", because any sort of default/fall-back will always see them. Config files are less problematic, but is it our job in this library to support this? A user can always write their own file and read it in however they wish...

On the naming, I have no super strong opinions and would be happy if y'all could come to a consensus that I can implement.

pyam/iiasa.py Outdated Show resolved Hide resolved
@gidden
Copy link
Member Author

gidden commented Jul 16, 2019

Hi all, in bea472e I have added the ability to pass a credentials file with a warning if a non-file based option is used. I think that should cover the issues here.

@gidden
Copy link
Member Author

gidden commented Jul 16, 2019

Ok all, to my eye this PR is now complete. Please let me know the resolution of point 1 between yourselves.

@byersiiasa
Copy link
Collaborator

Hi
I have just tested (limited) and seems to work well. In particular - tested it that when credentials are supplied, then more instances are available... nice!

# Connection with instance / creds
Connection(creds=('xxxx','XXXXX')).valid_connections

returns
['IXSE_AR6', 'IXSE_SETNAV', 'IXSE_SR15', 'IXSE_SR15_QA', 'IXSE_TEST_PUBLIC']

# Connection without instance / creds
 Connection()

returns
['IXSE_SETNAV', 'IXSE_SR15', 'IXSE_SR15_QA', 'IXSE_TEST_PUBLIC']

Thanks all!

@gidden
Copy link
Member Author

gidden commented Jul 22, 2019

Hi @danielhuppmann @zikolach and @fonfon would be great to try to come to some resolution on the point above so this can be merged. Thanks!

@gidden
Copy link
Member Author

gidden commented Jul 29, 2019

Hi @danielhuppmann @zikolach and @fonfon. This has been an open for ~2 weeks now. It would be great to get a response on point 1 above. If there is no resolution in a reasonable timeframe, I suggest we pull this as-is unless someone wants to object and review!

@zikolach
Copy link
Contributor

@gidden fyi I have no access to mark this PR as accepted despite the fact I included in reviewers list

@gidden
Copy link
Member Author

gidden commented Jul 29, 2019

Just added you as a collaborator!

@zikolach
Copy link
Contributor

Just added you as a collaborator!

@gidden half way there - now I can squash and merge but not accept/reject ;)

@zikolach zikolach self-requested a review July 29, 2019 08:42
Copy link
Contributor

@zikolach zikolach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gidden

@byers
Copy link

byers commented Jul 29, 2019 via email

@danielhuppmann
Copy link
Member

Thanks @gidden and @zikolach for the effort!

Let's use the "application names" and maybe add support for "short names" on the authentication API at a later stage.

@danielhuppmann danielhuppmann merged commit 5c3a1ee into master Jul 30, 2019
@danielhuppmann danielhuppmann deleted the conn-auth branch June 22, 2020 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants