@planqk/planqk-service-sdk 2.5.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 ADDED
@@ -0,0 +1,9 @@
1
+ version: 3
2
+ project:
3
+ id: "git@gitlab.com:planqk-foss/planqk-service-sdk.git"
4
+ name: "Platform-Service-SDK"
5
+ labels:
6
+ - "Platform"
7
+ - "Open Source"
8
+ - "SDK"
9
+ - "PLANQK"
package/.gitlab-ci.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  variables:
2
2
  TWINE_USERNAME: __token__
3
- UV_VERSION: 0.6
3
+ UV_VERSION: 0.8
4
4
  PYTHON_VERSION: 3.11
5
5
  BASE_LAYER: bookworm-slim
6
6
  # GitLab CI creates a separate mountpoint for the build directory,
@@ -11,6 +11,8 @@ variables:
11
11
  stages:
12
12
  - commit-test
13
13
  - commit-release-check
14
+ - install
15
+ - compliance
14
16
  - release-package
15
17
 
16
18
  semantic-release:
@@ -21,19 +23,53 @@ semantic-release:
21
23
  - if: '$CI_PIPELINE_SOURCE == "web"'
22
24
  - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
23
25
  variables:
26
+ BASE_LAYER: bookworm
24
27
  ## Use the gitlab user to create the release commit
25
28
  ## https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#git-environment-variables
26
29
  GIT_AUTHOR_NAME: "$GITLAB_USER_NAME"
27
30
  GIT_AUTHOR_EMAIL: "$GITLAB_USER_EMAIL"
28
31
  GIT_COMMITTER_NAME: "$GITLAB_USER_NAME"
29
32
  GIT_COMMITTER_EMAIL: "$GITLAB_USER_EMAIL"
30
- image: node:lts
33
+ image: ghcr.io/astral-sh/uv:$UV_VERSION-python$PYTHON_VERSION-$BASE_LAYER
31
34
  before_script:
32
- - apt-get update && apt-get install -y --no-install-recommends git-core ca-certificates
35
+ - curl -o- https://fnm.vercel.app/install | bash
36
+ - source ~/.bashrc
37
+ - fnm install 22
33
38
  - npm install -g semantic-release @semantic-release/gitlab @semantic-release/git @semantic-release/exec
34
39
  script:
35
40
  - semantic-release
36
41
 
42
+ install:
43
+ stage: install
44
+ rules:
45
+ - if: '$CI_COMMIT_TAG'
46
+ image: ghcr.io/astral-sh/uv:$UV_VERSION-python$PYTHON_VERSION-$BASE_LAYER
47
+ script:
48
+ - uv sync --frozen --no-dev
49
+ - uv export --format requirements-txt --no-dev --no-emit-project > requirements.txt
50
+ - uv export --format requirements-txt --dev --no-emit-project > requirements-dev.txt
51
+ artifacts:
52
+ expire_in: 1 hour
53
+ paths:
54
+ - .venv
55
+ - requirements.txt
56
+ - requirements-dev.txt
57
+
58
+ oss-compliance-check:
59
+ stage: compliance
60
+ rules:
61
+ - if: "$CI_COMMIT_TAG"
62
+ image: ubuntu:latest
63
+ before_script:
64
+ - apt-get update && apt-get install -y --no-install-recommends ca-certificates curl
65
+ - curl https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash
66
+ - source .venv/bin/activate
67
+ script:
68
+ - FOSSA_REVISION=$([ -z $CI_COMMIT_TAG ] && echo $CI_COMMIT_SHA || echo $CI_COMMIT_TAG)
69
+ - FOSSA_BRANCH=$([ -z $CI_COMMIT_BRANCH ] && echo 'main' || echo $CI_COMMIT_BRANCH)
70
+ - fossa analyze -b $FOSSA_BRANCH -r $FOSSA_REVISION .
71
+ - fossa test -r $FOSSA_REVISION
72
+
37
73
  publish-python-sdk:
38
74
  stage: release-package
39
75
  rules:
@@ -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
- ")\n",
59
- "\n",
60
- "# List all service executions\n",
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.9"
223
+ "version": "3.11.11"
218
224
  }
219
225
  },
220
226
  "nbformat": 4,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planqk/planqk-service-sdk",
3
- "version": "2.5.0",
3
+ "version": "2.6.2",
4
4
  "description": "SDK to interact with PLANQK Managed Services.",
5
5
  "author": "Kipu Quantum GmbH",
6
6
  "contributors": [
@@ -1 +1 @@
1
- __version__ = "2.5.0"
1
+ __version__ = "2.6.2"
@@ -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
- if time.time() - self._last_token_fetch > self._token["expires_in"]:
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
 
@@ -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
package/pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "planqk-service-sdk"
3
- version = "2.5.0"
3
+ version = "2.6.2"
4
4
  description = "SDK to interact with PLANQK Managed Services."
5
5
  authors = [
6
6
  { name = "Kipu Quantum GmbH", email = "info@kipu-quantum.com" },