From ce538ae2b34c55c6f3d0c1df08d740dd63fabffd Mon Sep 17 00:00:00 2001 From: Daniel Huppmann Date: Fri, 3 Nov 2023 09:20:59 +0100 Subject: [PATCH] Raise explicit error message if no connection to IIASA manager service (#796) --- RELEASE_NOTES.md | 2 ++ pyam/iiasa.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4a251fdf3..13fb4cd4e 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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 diff --git a/pyam/iiasa.py b/pyam/iiasa.py index 3edff2f0d..31ae80f02 100644 --- a/pyam/iiasa.py +++ b/pyam/iiasa.py @@ -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 ` in a console instead. auth_url : str, optional Url of the authentication service """ @@ -87,6 +88,7 @@ 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( @@ -94,6 +96,10 @@ def __init__(self, creds: str = None, auth_url: str = _AUTH_URL): 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":