Skip to content

Commit

Permalink
Raise explicit error message if no connection to IIASA manager service (
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann authored Nov 3, 2023
1 parent 3eda7e5 commit ce538ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Next Release

- [#796](https://github.com/IAMconsortium/pyam/pull/796] Raise explicit error message if no connection to IIASA manager service
- [#794](https://github.com/IAMconsortium/pyam/pull/794] Fixed wrong color codes for AR6 Illustrative Pathways

# Release v2.0.0
Expand Down
10 changes: 8 additions & 2 deletions pyam/iiasa.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ def _check_response(r, msg="Error connecting to IIASA database", error=RuntimeEr

class SceSeAuth(AuthBase):
def __init__(self, creds: str = None, auth_url: str = _AUTH_URL):
"""Connection to the Scenario Services Manager AAC service.
"""Connection to the Scenario Services manager service for authentication.
Parameters
----------
creds : pathlib.Path or str, optional
Path to a file with authentication credentials
Path to a file with authentication credentials. This feature is deprecated,
please run `ixmp4 login <username>` in a console instead.
auth_url : str, optional
Url of the authentication service
"""
Expand All @@ -87,13 +88,18 @@ def __init__(self, creds: str = None, auth_url: str = _AUTH_URL):
else:
self.auth = ixmp4.conf.settings.default_auth
elif isinstance(creds, Path) or is_str(creds):
deprecation_warning(f"{IXMP4_LOGIN}.", "Using a pyam-credentials file")
self.auth = _read_config(creds)
else:
raise DeprecationWarning(
"Passing credentials as clear-text is not allowed. "
f"{IXMP4_LOGIN} instead."
)

# self.auth is None if connection to manager service cannot be established
if self.auth is None:
raise httpx.ConnectError("No connection to IIASA manager service.")

# explicit token for anonymous login is not necessary for ixmp4 platforms
# but is required for legacy Scenario Explorer databases
if self.auth.user.username == "@anonymous":
Expand Down

0 comments on commit ce538ae

Please sign in to comment.