Skip to content

Commit 5ec8bef

Browse files
authored
Merge pull request #695 from FlorentinD/eap-preparation
Prepare session notebook for EAP
2 parents 78269a5 + 8b62977 commit 5ec8bef

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

doc/modules/ROOT/pages/tutorials/gds-sessions.adoc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ listing, and deletion.
2222

2323
== Prerequisites
2424

25-
This notebook requires having an AuraDB instance available. We also need
26-
to have the `graphdatascience` Python library installed, version
27-
`1.11a4` or later.
25+
This notebook requires having an AuraDB instance available and have the
26+
GDS sessions feature enabled for your tenant. Contact your account
27+
manager to get the features enabled.
28+
29+
We also need to have the `graphdatascience` Python library installed,
30+
version `1.11a4` or later.
31+
32+
33+
34+
2835

2936
[source, python, role=no-test]
3037
----
@@ -51,7 +58,9 @@ client_id = os.environ["AURA_API_CLIENT_ID"]
5158
client_secret = os.environ["AURA_API_CLIENT_SECRET"]
5259
5360
# If your account is a member of several tenants, you must also specify the tenant ID to use
54-
sessions = GdsSessions(api_credentials=AuraAPICredentials(client_id, client_secret))
61+
tenant_id = os.environ.get("AURA_API_TENANT_ID", None)
62+
63+
sessions = GdsSessions(api_credentials=AuraAPICredentials(client_id, client_secret, tenant_id=tenant_id))
5564
----
5665

5766
== Creating a new session

examples/gds-sessions.ipynb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,23 @@
4040
"source": [
4141
"## Prerequisites\n",
4242
"\n",
43-
"This notebook requires having an AuraDB instance available.\n",
43+
"This notebook requires having an AuraDB instance available and have the GDS sessions feature enabled for your tenant. \n",
44+
"Contact your account manager to get the features enabled. \n",
45+
"\n",
4446
"We also need to have the `graphdatascience` Python library installed, version `1.11a4` or later.\n",
4547
"\n"
4648
]
4749
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": []
54+
},
55+
{
56+
"cell_type": "markdown",
57+
"metadata": {},
58+
"source": []
59+
},
4860
{
4961
"cell_type": "code",
5062
"execution_count": null,
@@ -84,7 +96,9 @@
8496
"client_secret = os.environ[\"AURA_API_CLIENT_SECRET\"]\n",
8597
"\n",
8698
"# If your account is a member of several tenants, you must also specify the tenant ID to use\n",
87-
"sessions = GdsSessions(api_credentials=AuraAPICredentials(client_id, client_secret))"
99+
"tenant_id = os.environ.get(\"AURA_API_TENANT_ID\", None)\n",
100+
"\n",
101+
"sessions = GdsSessions(api_credentials=AuraAPICredentials(client_id, client_secret, tenant_id=tenant_id))"
88102
]
89103
},
90104
{

graphdatascience/session/aura_api.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ def __init__(self, message: str, status_code: int):
3232

3333
class AuraApi:
3434
def __init__(self, client_id: str, client_secret: str, tenant_id: Optional[str] = None) -> None:
35-
self._dev_env = os.environ.get("AURA_ENV")
35+
self._aura_env = os.environ.get("AURA_ENV")
3636

37-
if not self._dev_env:
37+
if not self._aura_env or self._aura_env == "production":
3838
self._base_uri = "https://api.neo4j.io"
39-
elif self._dev_env == "staging":
39+
elif self._aura_env == "staging":
4040
self._base_uri = "https://api-staging.neo4j.io"
4141
else:
42-
self._base_uri = f"https://api-{self._dev_env}.neo4j-dev.io"
42+
self._base_uri = f"https://api-{self._aura_env}.neo4j-dev.io"
4343

4444
self._auth = AuraApi.Auth(oauth_url=f"{self._base_uri}/oauth/token", credentials=(client_id, client_secret))
4545
self._logger = logging.getLogger()
@@ -268,9 +268,6 @@ def _check_endpoint_expiry(self, resp: requests.Response) -> None:
268268
DeprecationWarning,
269269
)
270270

271-
def _instance_type(self) -> str:
272-
return "enterprise-ds" if not self._dev_env else "professional-ds"
273-
274271
class Auth(requests.auth.AuthBase):
275272
class Token:
276273
access_token: str

graphdatascience/session/gds_sessions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ class AuraAPICredentials:
2222
Attributes:
2323
client_id (str): The client ID for authentication.
2424
client_secret (str): The client secret for authentication.
25-
tenant (Optional[str]): The tenant for authentication. Needed if a client belongs to multiple tenants.
25+
tenant_id (Optional[str]): The tenant ID for authentication. Needed if a client belongs to multiple tenants.
2626
"""
2727

2828
client_id: str
2929
client_secret: str
30-
tenant: Optional[str] = None
30+
tenant_id: Optional[str] = None
3131

3232

3333
class GdsSessions:
@@ -42,8 +42,8 @@ def __init__(self, api_credentials: AuraAPICredentials) -> None:
4242
Args:
4343
api_credentials (AuraAPICredentials): The Aura API credentials used for establishing a connection.
4444
"""
45-
aura_api = AuraApi(api_credentials.client_id, api_credentials.client_secret, api_credentials.tenant)
46-
session_type_flag = os.environ.get("USE_DEDICATED_SESSIONS", "false").lower() == "true"
45+
aura_api = AuraApi(api_credentials.client_id, api_credentials.client_secret, api_credentials.tenant_id)
46+
session_type_flag = os.environ.get("USE_DEDICATED_SESSIONS", "true").lower() == "true"
4747
self._impl: Union[DedicatedSessions, AuraDsSessions] = (
4848
DedicatedSessions(aura_api) if session_type_flag else AuraDsSessions(aura_api)
4949
)

0 commit comments

Comments
 (0)