@planqk/planqk-service-sdk 2.6.0 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.fossa.yml +1 -1
- package/notebooks/python-sdk.ipynb +10 -4
- package/package.json +1 -1
- package/planqk/service/_version.py +1 -1
- package/planqk/service/auth.py +6 -1
- package/planqk/service/client.py +1 -3
- package/pyproject.toml +1 -1
- package/requirements-dev.txt +318 -255
- package/requirements.txt +156 -113
- package/uv.lock +327 -263
- package/planqk/__init__.py +0 -0
package/.fossa.yml
CHANGED
|
@@ -55,9 +55,15 @@
|
|
|
55
55
|
"# Create a new PlanqkServiceClient instance\n",
|
|
56
56
|
"client = PlanqkServiceClient(\n",
|
|
57
57
|
" service_endpoint, consumer_key, consumer_secret, token_endpoint\n",
|
|
58
|
-
")
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
")"
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"cell_type": "code",
|
|
63
|
+
"execution_count": null,
|
|
64
|
+
"metadata": {},
|
|
65
|
+
"outputs": [],
|
|
66
|
+
"source": [
|
|
61
67
|
"service_executions = client.get_service_executions()\n",
|
|
62
68
|
"print(f\"Found {len(service_executions)} service executions\")"
|
|
63
69
|
]
|
|
@@ -214,7 +220,7 @@
|
|
|
214
220
|
"name": "python",
|
|
215
221
|
"nbconvert_exporter": "python",
|
|
216
222
|
"pygments_lexer": "ipython3",
|
|
217
|
-
"version": "3.11.
|
|
223
|
+
"version": "3.11.11"
|
|
218
224
|
}
|
|
219
225
|
},
|
|
220
226
|
"nbformat": 4,
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.6.
|
|
1
|
+
__version__ = "2.6.2"
|
package/planqk/service/auth.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
import time
|
|
2
3
|
|
|
3
4
|
from authlib.integrations.httpx_client import OAuth2Client
|
|
@@ -6,6 +7,8 @@ DEFAULT_TOKEN_ENDPOINT = "https://gateway.platform.planqk.de/token"
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class PlanqkServiceAuth:
|
|
10
|
+
_logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
9
12
|
def __init__(self, consumer_key: str, consumer_secret: str, token_endpoint: str = DEFAULT_TOKEN_ENDPOINT):
|
|
10
13
|
self._consumer_key = consumer_key
|
|
11
14
|
self._consumer_secret = consumer_secret
|
|
@@ -17,12 +20,14 @@ class PlanqkServiceAuth:
|
|
|
17
20
|
if self._token is None or self._last_token_fetch is None:
|
|
18
21
|
self._refresh_token()
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
# Refresh token 120 seconds before expiration to prevent race conditions
|
|
24
|
+
if time.time() - self._last_token_fetch >= (self._token["expires_in"] - 120):
|
|
21
25
|
self._refresh_token()
|
|
22
26
|
|
|
23
27
|
return self._token["access_token"]
|
|
24
28
|
|
|
25
29
|
def _refresh_token(self):
|
|
30
|
+
self._logger.debug("Creating new token using client credentials flow")
|
|
26
31
|
with OAuth2Client(self._consumer_key, self._consumer_secret) as client:
|
|
27
32
|
token = client.fetch_token(self._token_endpoint, grant_type='client_credentials')
|
|
28
33
|
|
package/planqk/service/client.py
CHANGED
|
@@ -130,9 +130,7 @@ class PlanqkServiceClient:
|
|
|
130
130
|
)
|
|
131
131
|
self._api = PlanqkServiceApi(base_url=self._service_endpoint, token=self._auth.get_token)
|
|
132
132
|
else:
|
|
133
|
-
random_token = "".join(
|
|
134
|
-
random.choices(string.ascii_letters + string.digits, k=21)
|
|
135
|
-
)
|
|
133
|
+
random_token = "".join(random.choices(string.ascii_letters + string.digits, k=21))
|
|
136
134
|
self._api = PlanqkServiceApi(base_url=self._service_endpoint, token=random_token)
|
|
137
135
|
|
|
138
136
|
@property
|