File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
skore-hub-project/src/skore_hub_project/authentication Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 55from tempfile import gettempdir
66from typing import Final
77
8- DEFAULT : Final [str ] = "https://api.skore.probabl.ai"
9- ENVARNAME : Final [str ] = "SKORE_HUB_URI"
8+ URI_DEFAULT : Final [str ] = "https://api.skore.probabl.ai"
9+ URI_ENVARNAME : Final [str ] = "SKORE_HUB_URI"
10+ API_KEY_ENVARNAME : Final [str ] = "SKORE_HUB_API_KEY"
1011
1112
1213class URIError (RuntimeError ):
@@ -26,8 +27,12 @@ def persist(uri: str) -> None:
2627def URI () -> str :
2728 """URI used for ``skore hub`` authentication."""
2829 filepath = Filepath ()
30+ uri_from_environment = environ .get (URI_ENVARNAME )
31+
32+ if environ .get (API_KEY_ENVARNAME ):
33+ return uri_from_environment or URI_DEFAULT
34+
2935 uri_from_persistence = filepath .read_text () if filepath .exists () else None
30- uri_from_environment = environ .get (ENVARNAME )
3136
3237 if (
3338 uri_from_persistence
@@ -37,8 +42,8 @@ def URI() -> str:
3742 raise URIError (
3843 f"\n Bad condition: the persisted URI is conflicting with the environment:\n "
3944 f"\t From { filepath } : '{ uri_from_persistence } '\n "
40- f"\t From ${ ENVARNAME } : '{ uri_from_environment } '\n "
45+ f"\t From ${ URI_ENVARNAME } : '{ uri_from_environment } '\n "
4146 f"\n Please run `skore-hub-logout`."
4247 )
4348
44- return uri_from_persistence or uri_from_environment or DEFAULT
49+ return uri_from_persistence or uri_from_environment or URI_DEFAULT
You can’t perform that action at this time.
0 commit comments