@planqk/planqk-service-sdk 1.9.0 → 2.1.0

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.
Files changed (221) hide show
  1. package/.devcontainer/devcontainer.json +32 -0
  2. package/.devcontainer/post-create.sh +7 -0
  3. package/.env.template +4 -0
  4. package/.gitlab-ci.yml +103 -0
  5. package/.python-version +1 -0
  6. package/.releaserc.json +45 -0
  7. package/LICENSE +201 -0
  8. package/README-node.md +41 -0
  9. package/README-python.md +52 -0
  10. package/README.md +42 -21
  11. package/dist/auth.js +12 -19
  12. package/dist/client.d.ts +2 -12
  13. package/dist/client.js +5 -76
  14. package/dist/sdk/Client.d.ts +4 -3
  15. package/dist/sdk/Client.js +4 -8
  16. package/dist/sdk/api/errors/BadRequestError.d.ts +1 -1
  17. package/dist/sdk/api/errors/BadRequestError.js +18 -8
  18. package/dist/sdk/api/errors/ForbiddenError.d.ts +1 -1
  19. package/dist/sdk/api/errors/ForbiddenError.js +18 -8
  20. package/dist/sdk/api/errors/InternalServerError.d.ts +1 -1
  21. package/dist/sdk/api/errors/InternalServerError.js +18 -8
  22. package/dist/sdk/api/errors/NotFoundError.d.ts +1 -1
  23. package/dist/sdk/api/errors/NotFoundError.js +18 -8
  24. package/dist/sdk/api/errors/UnauthorizedError.d.ts +1 -1
  25. package/dist/sdk/api/errors/UnauthorizedError.js +18 -8
  26. package/dist/sdk/api/resources/index.d.ts +0 -3
  27. package/dist/sdk/api/resources/index.js +18 -11
  28. package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +65 -12
  29. package/dist/sdk/api/resources/serviceApi/client/Client.js +405 -261
  30. package/dist/sdk/api/resources/serviceApi/client/index.d.ts +1 -1
  31. package/dist/sdk/api/resources/serviceApi/client/index.js +0 -15
  32. package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +4 -1
  33. package/dist/sdk/api/resources/serviceApi/types/{GetInterimResultsResponse.d.ts → GetResultResponseEmbedded.d.ts} +3 -1
  34. package/dist/sdk/api/resources/serviceApi/types/GetResultResponseLinks.d.ts +7 -0
  35. package/dist/sdk/api/resources/{statusApi → serviceApi}/types/HealthCheckResponse.d.ts +1 -0
  36. package/dist/sdk/api/resources/serviceApi/types/index.d.ts +3 -1
  37. package/dist/sdk/api/resources/serviceApi/types/index.js +3 -1
  38. package/dist/sdk/api/types/HalLink.d.ts +21 -0
  39. package/dist/sdk/api/types/InputData.d.ts +1 -1
  40. package/dist/sdk/api/types/{InputRef.d.ts → InputDataRef.d.ts} +1 -1
  41. package/dist/sdk/api/types/InputParams.d.ts +1 -1
  42. package/dist/sdk/api/types/{Job.d.ts → ServiceExecution.d.ts} +2 -2
  43. package/dist/sdk/api/types/{JobStatus.d.ts → ServiceExecutionStatus.d.ts} +2 -2
  44. package/dist/sdk/api/types/{JobStatus.js → ServiceExecutionStatus.js} +2 -2
  45. package/dist/sdk/api/types/index.d.ts +4 -8
  46. package/dist/sdk/api/types/index.js +4 -8
  47. package/dist/sdk/core/fetcher/APIResponse.d.ts +1 -0
  48. package/dist/sdk/core/fetcher/Fetcher.d.ts +6 -5
  49. package/dist/sdk/core/fetcher/Fetcher.js +68 -112
  50. package/dist/sdk/core/fetcher/Supplier.js +2 -11
  51. package/dist/sdk/core/fetcher/createRequestUrl.d.ts +1 -0
  52. package/dist/sdk/core/fetcher/createRequestUrl.js +12 -0
  53. package/dist/sdk/core/fetcher/getFetchFn.d.ts +4 -0
  54. package/dist/sdk/core/fetcher/getFetchFn.js +57 -0
  55. package/dist/sdk/core/fetcher/getHeader.d.ts +1 -0
  56. package/dist/sdk/core/fetcher/getHeader.js +11 -0
  57. package/dist/sdk/core/fetcher/getRequestBody.d.ts +7 -0
  58. package/dist/sdk/core/fetcher/getRequestBody.js +11 -0
  59. package/dist/sdk/core/fetcher/getResponseBody.d.ts +1 -0
  60. package/dist/sdk/core/fetcher/getResponseBody.js +40 -0
  61. package/dist/sdk/core/fetcher/index.d.ts +1 -0
  62. package/dist/sdk/core/fetcher/index.js +3 -1
  63. package/dist/sdk/core/fetcher/makeRequest.d.ts +1 -0
  64. package/dist/sdk/core/fetcher/makeRequest.js +33 -0
  65. package/dist/sdk/core/fetcher/requestWithRetries.d.ts +1 -0
  66. package/dist/sdk/core/fetcher/requestWithRetries.js +20 -0
  67. package/dist/sdk/core/fetcher/signals.d.ts +11 -0
  68. package/dist/sdk/core/fetcher/signals.js +36 -0
  69. package/dist/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  70. package/dist/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +232 -0
  71. package/dist/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
  72. package/dist/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +91 -0
  73. package/dist/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
  74. package/dist/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +214 -0
  75. package/dist/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
  76. package/dist/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.js +48 -0
  77. package/dist/sdk/core/index.d.ts +1 -0
  78. package/dist/sdk/core/index.js +1 -0
  79. package/dist/sdk/core/runtime/index.d.ts +1 -0
  80. package/dist/sdk/core/runtime/index.js +5 -0
  81. package/dist/sdk/core/runtime/runtime.d.ts +9 -0
  82. package/dist/sdk/core/runtime/runtime.js +92 -0
  83. package/dist/sdk/errors/PlanqkServiceApiError.js +2 -0
  84. package/dist/sdk/index.js +17 -7
  85. package/eslint.config.mjs +11 -0
  86. package/fern/fern.config.json +4 -0
  87. package/fern/generators.yml +25 -0
  88. package/fern/openapi/openapi.yml +342 -0
  89. package/notebooks/python-sdk.ipynb +280 -0
  90. package/package.json +27 -28
  91. package/planqk/__init__.py +0 -0
  92. package/planqk/service/__init__.py +1 -0
  93. package/planqk/service/_version.py +1 -0
  94. package/planqk/service/auth.py +30 -0
  95. package/planqk/service/client.py +151 -0
  96. package/planqk/service/sdk/__init__.py +48 -0
  97. package/planqk/service/sdk/client.py +152 -0
  98. package/planqk/service/sdk/core/__init__.py +47 -0
  99. package/planqk/service/sdk/core/api_error.py +17 -0
  100. package/planqk/service/sdk/core/client_wrapper.py +74 -0
  101. package/planqk/service/sdk/core/datetime_utils.py +30 -0
  102. package/planqk/service/sdk/core/file.py +70 -0
  103. package/planqk/service/sdk/core/http_client.py +575 -0
  104. package/planqk/service/sdk/core/jsonable_encoder.py +103 -0
  105. package/planqk/service/sdk/core/pydantic_utilities.py +323 -0
  106. package/planqk/service/sdk/core/query_encoder.py +60 -0
  107. package/planqk/service/sdk/core/remove_none_from_dict.py +11 -0
  108. package/planqk/service/sdk/core/request_options.py +35 -0
  109. package/planqk/service/sdk/core/serialization.py +276 -0
  110. package/planqk/service/sdk/environment.py +7 -0
  111. package/planqk/service/sdk/errors/__init__.py +15 -0
  112. package/planqk/service/sdk/errors/bad_request_error.py +9 -0
  113. package/planqk/service/sdk/errors/forbidden_error.py +9 -0
  114. package/planqk/service/sdk/errors/internal_server_error.py +9 -0
  115. package/planqk/service/sdk/errors/not_found_error.py +9 -0
  116. package/planqk/service/sdk/errors/unauthorized_error.py +9 -0
  117. package/planqk/service/sdk/service_api/__init__.py +15 -0
  118. package/planqk/service/sdk/service_api/client.py +1257 -0
  119. package/planqk/service/sdk/service_api/types/__init__.py +13 -0
  120. package/planqk/service/sdk/service_api/types/get_result_response.py +30 -0
  121. package/planqk/service/sdk/service_api/types/get_result_response_embedded.py +22 -0
  122. package/planqk/service/sdk/service_api/types/get_result_response_links.py +22 -0
  123. package/planqk/service/sdk/service_api/types/health_check_response.py +24 -0
  124. package/planqk/service/sdk/types/__init__.py +17 -0
  125. package/planqk/service/sdk/types/hal_link.py +59 -0
  126. package/planqk/service/sdk/types/input_data.py +5 -0
  127. package/planqk/service/sdk/types/input_data_ref.py +27 -0
  128. package/planqk/service/sdk/types/input_params.py +5 -0
  129. package/planqk/service/sdk/types/service_execution.py +34 -0
  130. package/planqk/service/sdk/types/service_execution_status.py +8 -0
  131. package/pyproject.toml +51 -0
  132. package/scripts/update-version.sh +6 -0
  133. package/src/client.ts +4 -78
  134. package/src/index.test.ts +43 -0
  135. package/src/sdk/Client.ts +4 -7
  136. package/src/sdk/api/errors/BadRequestError.ts +1 -1
  137. package/src/sdk/api/errors/ForbiddenError.ts +1 -1
  138. package/src/sdk/api/errors/InternalServerError.ts +1 -1
  139. package/src/sdk/api/errors/NotFoundError.ts +1 -1
  140. package/src/sdk/api/errors/UnauthorizedError.ts +1 -1
  141. package/src/sdk/api/resources/index.ts +0 -3
  142. package/src/sdk/api/resources/serviceApi/client/Client.ts +205 -32
  143. package/src/sdk/api/resources/serviceApi/client/index.ts +1 -1
  144. package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +4 -5
  145. package/src/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.ts +9 -0
  146. package/src/sdk/api/resources/serviceApi/types/GetResultResponseLinks.ts +9 -0
  147. package/src/sdk/api/resources/{statusApi → serviceApi}/types/HealthCheckResponse.ts +1 -0
  148. package/src/sdk/api/resources/serviceApi/types/index.ts +3 -1
  149. package/src/sdk/api/types/HalLink.ts +22 -0
  150. package/src/sdk/api/types/InputData.ts +1 -1
  151. package/src/sdk/api/types/{InputRef.ts → InputDataRef.ts} +1 -1
  152. package/src/sdk/api/types/InputParams.ts +1 -1
  153. package/src/sdk/api/types/{Job.ts → ServiceExecution.ts} +2 -2
  154. package/src/sdk/api/types/{JobStatus.ts → ServiceExecutionStatus.ts} +2 -2
  155. package/src/sdk/api/types/index.ts +4 -8
  156. package/src/sdk/core/fetcher/APIResponse.ts +1 -0
  157. package/src/sdk/core/fetcher/Fetcher.ts +55 -72
  158. package/src/sdk/core/fetcher/createRequestUrl.ts +10 -0
  159. package/src/sdk/core/fetcher/getFetchFn.ts +25 -0
  160. package/src/sdk/core/fetcher/getHeader.ts +8 -0
  161. package/src/sdk/core/fetcher/getRequestBody.ts +14 -0
  162. package/src/sdk/core/fetcher/getResponseBody.ts +32 -0
  163. package/src/sdk/core/fetcher/index.ts +1 -0
  164. package/src/sdk/core/fetcher/makeRequest.ts +44 -0
  165. package/src/sdk/core/fetcher/requestWithRetries.ts +21 -0
  166. package/src/sdk/core/fetcher/signals.ts +38 -0
  167. package/src/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts +252 -0
  168. package/src/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts +106 -0
  169. package/src/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts +239 -0
  170. package/src/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.ts +33 -0
  171. package/src/sdk/core/index.ts +1 -0
  172. package/src/sdk/core/runtime/index.ts +1 -0
  173. package/src/sdk/core/runtime/runtime.ts +126 -0
  174. package/tsconfig.json +15 -107
  175. package/uv.lock +1109 -0
  176. package/.eslintignore +0 -3
  177. package/.eslintrc +0 -7
  178. package/dist/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.d.ts +0 -9
  179. package/dist/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.d.ts +0 -13
  180. package/dist/sdk/api/resources/serviceApi/client/requests/index.d.ts +0 -2
  181. package/dist/sdk/api/resources/serviceApi/client/requests/index.js +0 -2
  182. package/dist/sdk/api/resources/statusApi/client/Client.d.ts +0 -28
  183. package/dist/sdk/api/resources/statusApi/client/Client.js +0 -97
  184. package/dist/sdk/api/resources/statusApi/client/index.d.ts +0 -1
  185. package/dist/sdk/api/resources/statusApi/client/index.js +0 -2
  186. package/dist/sdk/api/resources/statusApi/index.d.ts +0 -2
  187. package/dist/sdk/api/resources/statusApi/index.js +0 -18
  188. package/dist/sdk/api/resources/statusApi/types/index.d.ts +0 -1
  189. package/dist/sdk/api/resources/statusApi/types/index.js +0 -17
  190. package/dist/sdk/api/types/ArrayResponse.d.ts +0 -4
  191. package/dist/sdk/api/types/InterimResultResponse.d.ts +0 -4
  192. package/dist/sdk/api/types/InterimResultResponse.js +0 -5
  193. package/dist/sdk/api/types/Job.js +0 -5
  194. package/dist/sdk/api/types/NumberResponse.d.ts +0 -4
  195. package/dist/sdk/api/types/NumberResponse.js +0 -5
  196. package/dist/sdk/api/types/ObjectResponse.d.ts +0 -4
  197. package/dist/sdk/api/types/ObjectResponse.js +0 -5
  198. package/dist/sdk/api/types/StringResponse.d.ts +0 -4
  199. package/dist/sdk/api/types/StringResponse.js +0 -5
  200. package/jest.config.js +0 -12
  201. package/src/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.ts +0 -10
  202. package/src/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.ts +0 -15
  203. package/src/sdk/api/resources/serviceApi/client/requests/index.ts +0 -2
  204. package/src/sdk/api/resources/serviceApi/types/GetInterimResultsResponse.ts +0 -9
  205. package/src/sdk/api/resources/statusApi/client/Client.ts +0 -75
  206. package/src/sdk/api/resources/statusApi/client/index.ts +0 -1
  207. package/src/sdk/api/resources/statusApi/index.ts +0 -2
  208. package/src/sdk/api/resources/statusApi/types/index.ts +0 -1
  209. package/src/sdk/api/types/ArrayResponse.ts +0 -5
  210. package/src/sdk/api/types/InterimResultResponse.ts +0 -5
  211. package/src/sdk/api/types/NumberResponse.ts +0 -5
  212. package/src/sdk/api/types/ObjectResponse.ts +0 -5
  213. package/src/sdk/api/types/StringResponse.ts +0 -5
  214. package/tests/fixtures/complex-input.ts +0 -477
  215. package/tests/integration.test.ts +0 -92
  216. /package/dist/sdk/api/resources/serviceApi/{client/requests/GetInterimResultsRequest.js → types/GetResultResponseEmbedded.js} +0 -0
  217. /package/dist/sdk/api/resources/serviceApi/{client/requests/StartExecutionRequest.js → types/GetResultResponseLinks.js} +0 -0
  218. /package/dist/sdk/api/resources/{statusApi → serviceApi}/types/HealthCheckResponse.js +0 -0
  219. /package/dist/sdk/api/{resources/serviceApi/types/GetInterimResultsResponse.js → types/HalLink.js} +0 -0
  220. /package/dist/sdk/api/types/{ArrayResponse.js → InputDataRef.js} +0 -0
  221. /package/dist/sdk/api/types/{InputRef.js → ServiceExecution.js} +0 -0
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "planqk-service-sdk",
3
+ "image": "mcr.microsoft.com/devcontainers/python:3.11",
4
+ "features": {
5
+ "ghcr.io/va-h/devcontainers-features/uv:1": {},
6
+ "ghcr.io/devcontainers/features/node:1": {
7
+ "version": "lts",
8
+ "nvmVersion": "latest"
9
+ },
10
+ "ghcr.io/devcontainers/features/docker-in-docker:2": {},
11
+ "ghcr.io/devcontainers-community/features/deno:1": {}
12
+ },
13
+ "postCreateCommand": ["bash", "-i", "./.devcontainer/post-create.sh"],
14
+ "customizations": {
15
+ "vscode": {
16
+ "extensions": [
17
+ "ms-toolsai.jupyter",
18
+ "ms-python.python",
19
+ "ms-python.black-formatter",
20
+ "ms-python.isort",
21
+ "ms-python.vscode-pylance",
22
+ "esbenp.prettier-vscode",
23
+ "denoland.vscode-deno"
24
+ ],
25
+ "settings": {
26
+ "[python]": {
27
+ "editor.defaultFormatter": "ms-python.black-formatter"
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+
3
+ echo "Installing Fern tooling..."
4
+ npm install -g fern-api
5
+
6
+ echo "Enabling Deno Kernel for Jupyter..."
7
+ deno jupyter --unstable --install
package/.env.template ADDED
@@ -0,0 +1,4 @@
1
+ TOKEN_ENDPOINT=https://gateway.platform.planqk.de/token
2
+ SERVICE_ENDPOINT=https://gateway.platform.planqk.de/your-organization/your-service/1.0.0
3
+ CONSUMER_KEY=your-consumer-key
4
+ CONSUMER_SECRET=your-consumer-secret
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,103 @@
1
+ variables:
2
+ TWINE_USERNAME: __token__
3
+ DATADOG_STATIC_ANALYZER_URL: "https://github.com/DataDog/datadog-static-analyzer/releases/latest/download/datadog-static-analyzer-x86_64-unknown-linux-gnu.zip"
4
+ DATADOG_OSV_SCANNER_URL: "https://github.com/DataDog/osv-scanner/releases/latest/download/osv-scanner_linux_amd64.zip"
5
+ DATADOG_ENV: "ci"
6
+ DATADOG_SERVICE: "planqk-service-sdk"
7
+ UV_VERSION: 0.5
8
+ PYTHON_VERSION: 3.11
9
+ BASE_LAYER: bookworm-slim
10
+ # GitLab CI creates a separate mountpoint for the build directory,
11
+ # so we need to copy instead of using hard links.
12
+ UV_LINK_MODE: copy
13
+ UV_CACHE_DIR: .uv-cache
14
+
15
+ stages:
16
+ - commit-test
17
+ - commit-release-check
18
+ - release-package
19
+
20
+ datadog-static-analyzer:
21
+ stage: commit-test
22
+ rules:
23
+ - if: '$CI_COMMIT_MESSAGE =~ /^chore\(release\):/'
24
+ when: never
25
+ - if: '$CI_PIPELINE_SOURCE == "web"'
26
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
27
+ image: node:lts
28
+ before_script:
29
+ - npm install -g @datadog/datadog-ci
30
+ - curl -L $DATADOG_STATIC_ANALYZER_URL > /tmp/datadog-static-analyzer.zip
31
+ - unzip /tmp/datadog-static-analyzer.zip -d /tmp
32
+ - mv /tmp/datadog-static-analyzer /usr/local/datadog-static-analyzer
33
+ script:
34
+ - /usr/local/datadog-static-analyzer -i . -o /tmp/report.sarif -f sarif
35
+ - datadog-ci sarif upload /tmp/report.sarif --service "$DATADOG_SERVICE" --env "$DATADOG_ENV"
36
+
37
+ datadog-sbom-analyzer:
38
+ stage: commit-test
39
+ rules:
40
+ - if: '$CI_COMMIT_MESSAGE =~ /^chore\(release\):/'
41
+ when: never
42
+ - if: '$CI_PIPELINE_SOURCE == "web"'
43
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
44
+ image: node:lts
45
+ before_script:
46
+ - npm install -g @datadog/datadog-ci
47
+ - mkdir /osv-scanner
48
+ - curl -L -o /osv-scanner/osv-scanner.zip $DATADOG_OSV_SCANNER_URL
49
+ - unzip /osv-scanner/osv-scanner.zip -d /osv-scanner
50
+ - chmod 755 /osv-scanner/osv-scanner
51
+ script:
52
+ - /osv-scanner/osv-scanner --skip-git -r --experimental-only-packages --format=cyclonedx-1-5 --paths-relative-to-scan-dir --output=/tmp/sbom.json .
53
+ - datadog-ci sbom upload --service "$DATADOG_SERVICE" --env "$DATADOG_ENV" /tmp/sbom.json
54
+
55
+ semantic-release:
56
+ stage: commit-release-check
57
+ rules:
58
+ - if: '$CI_COMMIT_MESSAGE =~ /^chore\(release\):/'
59
+ when: never
60
+ - if: '$CI_PIPELINE_SOURCE == "web"'
61
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
62
+ image: node:lts
63
+ before_script:
64
+ - apt-get update && apt-get install -y --no-install-recommends git-core ca-certificates
65
+ - npm install -g semantic-release @semantic-release/gitlab @semantic-release/git @semantic-release/exec
66
+ script:
67
+ - semantic-release
68
+
69
+ publish-python-sdk:
70
+ stage: release-package
71
+ rules:
72
+ - if: '$CI_COMMIT_TAG'
73
+ image: ghcr.io/astral-sh/uv:$UV_VERSION-python$PYTHON_VERSION-$BASE_LAYER
74
+ before_script:
75
+ - uv venv
76
+ - uv sync --frozen
77
+ - source .venv/bin/activate
78
+ - uv pip install twine
79
+ script:
80
+ - uv build
81
+ - twine upload dist/*
82
+ cache:
83
+ - key:
84
+ files:
85
+ - uv.lock
86
+ paths:
87
+ - $UV_CACHE_DIR
88
+
89
+ publish-node-sdk:
90
+ stage: release-package
91
+ rules:
92
+ - if: '$CI_COMMIT_TAG'
93
+ image: node:lts
94
+ before_script:
95
+ - npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
96
+ script:
97
+ - npm ci
98
+ - npm run build
99
+ - npm publish
100
+ cache:
101
+ key: $CI_JOB_NAME
102
+ paths:
103
+ - node_modules
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,45 @@
1
+ {
2
+ "plugins": [
3
+ "@semantic-release/commit-analyzer",
4
+ "@semantic-release/release-notes-generator",
5
+ "@semantic-release/gitlab",
6
+ [
7
+ "@semantic-release/npm",
8
+ {
9
+ "npmPublish": false
10
+ }
11
+ ],
12
+ [
13
+ "@semantic-release/git",
14
+ {
15
+ "assets": [
16
+ "planqk/service/_version.py",
17
+ "pyproject.toml",
18
+ "package.json",
19
+ "package-lock.json"
20
+ ],
21
+ "message": "chore(release): v${nextRelease.version}\n\n${nextRelease.notes}"
22
+ }
23
+ ],
24
+ [
25
+ "@semantic-release/exec",
26
+ {
27
+ "generateNotesCmd": "sh ./scripts/update-version.sh ${nextRelease.version}"
28
+ }
29
+ ]
30
+ ],
31
+ "branches": [
32
+ "+([0-9])?(.{+([0-9]),x}).x",
33
+ "main",
34
+ "next",
35
+ "next-major",
36
+ {
37
+ "name": "beta",
38
+ "prerelease": true
39
+ },
40
+ {
41
+ "name": "alpha",
42
+ "prerelease": true
43
+ }
44
+ ]
45
+ }
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2023 Michael Wurster
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README-node.md ADDED
@@ -0,0 +1,41 @@
1
+ # PLANQK Service SDK
2
+
3
+ ## Installation
4
+
5
+ The package can be installed using `npm`:
6
+
7
+ ```bash
8
+ npm install @planqk/planqk-service-sdk
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ const serviceEndpoint = "..."
15
+ const consumerKey = "..."
16
+ const consumerSecret = "..."
17
+
18
+ const client = new PlanqkServiceClient(serviceEndpoint, consumerKey, consumerSecret)
19
+
20
+ // prepare your input data and parameters
21
+ const data = {input: {a: 1, b: 2}};
22
+ const params = {param1: "value1", param2: "value2"};
23
+
24
+ // execute the service
25
+ let serviceExecution = await client.api().execute({data, params})
26
+
27
+ // retrieve the status of a service execution
28
+ serviceExecution = await client.api().getStatus(serviceExecution.id!);
29
+
30
+ // wait for the service execution to finish
31
+ const finalStates = ["SUCCEEDED", "CANCELLED", "FAILED"];
32
+ while (!finalStates.includes(serviceExecution.status!)) {
33
+ serviceExecution = await client.api().getStatus(serviceExecution.id!);
34
+ }
35
+
36
+ // retrieve the result
37
+ const result = await client.api().getResult(serviceExecution.id!)
38
+
39
+ // retrieve the logs
40
+ const logs = await client.api().getLogs(serviceExecution.id!)
41
+ ```
@@ -0,0 +1,52 @@
1
+ # PLANQK Service SDK
2
+
3
+ ## Installation
4
+
5
+ The package is published on PyPI and can be installed via `pip`:
6
+
7
+ ```bash
8
+ pip install --upgrade planqk-service-sdk
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ import os
15
+ from planqk.service.client import PlanqkServiceClient
16
+
17
+ consumer_key = "..."
18
+ consumer_secret = "..."
19
+ service_endpoint = "..."
20
+
21
+ # Create a client
22
+ client = PlanqkServiceClient(service_endpoint, consumer_key, consumer_secret)
23
+
24
+ # Prepare your input data and parameters
25
+ data = {"input": {"a": 1, "b": 2}}
26
+ params = {"param1": "value1", "param2": "value2"}
27
+
28
+ # Start a service execution
29
+ service_execution = client.run(request={"data": data, "params": params})
30
+
31
+ # Wait for the service execution to finish (blocking)
32
+ service_execution.wait_for_final_state()
33
+
34
+ status = service_execution.status
35
+ ended_at = service_execution.ended_at
36
+ print(f"Service execution finished at '{ended_at}' with status '{status}'")
37
+
38
+ # Use the client to retrieve a service execution by its id
39
+ service_execution = client.get_service_execution("0030737b-35cb-46a8-88c2-f59d4885484d")
40
+
41
+ # Retrieve the result
42
+ result = service_execution.result()
43
+
44
+ # Retrieve service execution logs
45
+ logs = service_execution.logs()
46
+
47
+ # List the result files
48
+ files = service_execution.result_files()
49
+
50
+ # Download a result file
51
+ service_execution.download_result_file(files[0], os.getcwd())
52
+ ```
package/README.md CHANGED
@@ -1,35 +1,56 @@
1
- # PlanQK Service SDK
1
+ # planqk-service-sdk
2
2
 
3
- ## Installation
3
+ This repository contains the SDK clients to execute PLANQK Managed Services.
4
+ The clients are generated from a very general [OpenAPI](https://swagger.io/specification) description using [Fern](https://buildwithfern.com).
5
+ The generated clients are a baseline, and the idea is to adapt and extend them to our specific needs.
4
6
 
5
- The package can be installed using `npm`:
7
+ ## Generate the SDK clients with Fern
8
+
9
+ > <https://buildwithfern.com/docs/getting-started>
6
10
 
7
11
  ```bash
8
- npm install @planqk/planqk-service-sdk
12
+ npm install -g fern-api
13
+ fern upgrade
14
+ fern generate
9
15
  ```
10
16
 
11
- ## Usage
17
+ ## Python Setup
12
18
 
13
- ```typescript
14
- const serviceEndpoint = "..."
15
- const consumerKey = "..."
16
- const consumerSecret = "..."
19
+ To create a new virtual environment and install the dependencies, run:
17
20
 
18
- const client = new PlanqkServiceClient(serviceEndpoint, consumerKey, consumerSecret)
21
+ ```bash
22
+ uv venv
23
+ source .venv/bin/activate
19
24
 
20
- // prepare your input data and parameters
21
- const data = {"input": {"a": 1, "b": 2}}
22
- const params = {"param1": "value1", "param2": "value2"}
25
+ uv sync
26
+ ```
23
27
 
24
- // start the execution
25
- let job = await client.startExecution({data, params})
28
+ Update dependencies and lock files:
26
29
 
27
- // wait for the result
28
- const result = await client.getResult(job.id!)
30
+ ```bash
31
+ uv sync -U
29
32
  ```
30
33
 
31
- ## Run Tests
34
+ ## How to update the Python client?
32
35
 
33
- ```sh
34
- SERVICE_ENDPOINT=<endpoint-url> CONSUMER_KEY=<consumer-key> CONSUMER_SECRET=<consumer-secret> npm run test
35
- ```
36
+ After generating the SDK clients with Fern, the Python client needs to be copied manually.
37
+
38
+ Copy the content of `./generated/python` to `./planqk/service/sdk`.
39
+ Make sure you overwrite any existing files.
40
+ It is recommended to remove the old files first.
41
+
42
+ Next, check by executing `pytest` if the changes are compatible with our wrapper.
43
+
44
+ ## How to update the TypeScript client?
45
+
46
+ After generating the SDK clients with Fern, the TypeScript client needs to be copied manually.
47
+
48
+ Copy the content of `./generated/typescript` to `./typescript/src/sdk`.
49
+ Make sure you overwrite any existing files.
50
+ It is recommended to remove the old files first.
51
+
52
+ Next, check by executing `npm test` if the changes are compatible with our wrapper.
53
+
54
+ ## License
55
+
56
+ Apache-2.0 | Copyright 2023-2024 Kipu Quantum GmbH
package/dist/auth.js CHANGED
@@ -1,33 +1,26 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.PlanqkServiceAuth = exports.DEFAULT_TOKEN_ENDPOINT = void 0;
13
4
  const simple_oauth2_1 = require("simple-oauth2");
14
5
  exports.DEFAULT_TOKEN_ENDPOINT = 'https://gateway.platform.planqk.de';
15
6
  class PlanqkServiceAuth {
7
+ accessToken;
8
+ consumerKey;
9
+ consumerSecret;
10
+ tokenEndpoint;
16
11
  constructor(consumerKey, consumerSecret, tokenEndpoint = exports.DEFAULT_TOKEN_ENDPOINT) {
17
12
  this.consumerKey = consumerKey;
18
13
  this.consumerSecret = consumerSecret;
19
14
  this.tokenEndpoint = tokenEndpoint;
20
15
  }
21
- getAccessToken() {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!this.accessToken) {
24
- this.accessToken = yield this.fetchAccessToken();
25
- }
26
- if (this.accessToken.expired()) {
27
- this.accessToken = yield this.accessToken.refresh();
28
- }
29
- return this.accessToken.token.access_token;
30
- });
16
+ async getAccessToken() {
17
+ if (!this.accessToken) {
18
+ this.accessToken = await this.fetchAccessToken();
19
+ }
20
+ if (this.accessToken.expired()) {
21
+ this.accessToken = await this.accessToken.refresh();
22
+ }
23
+ return this.accessToken.token.access_token;
31
24
  }
32
25
  fetchAccessToken() {
33
26
  const client = new simple_oauth2_1.ClientCredentials({
package/dist/client.d.ts CHANGED
@@ -1,16 +1,6 @@
1
- import { GetInterimResultsRequest, GetInterimResultsResponse, GetResultResponse, HealthCheckResponse, Job, StartExecutionRequest } from './sdk/api';
2
- import { ServiceApi } from './sdk/api/resources/serviceApi/client/Client';
1
+ import { ServiceApi } from "./sdk/api/resources/serviceApi/client/Client";
3
2
  export declare class PlanqkServiceClient {
4
3
  private _api;
5
4
  constructor(serviceEndpoint: string, consumerKey?: string, consumerSecret?: string, tokenEndpoint?: string);
6
- cancelExecution(jobId: string, requestOptions?: ServiceApi.RequestOptions): Promise<Job>;
7
- getInterimResults(jobId: string, request?: GetInterimResultsRequest, requestOptions?: ServiceApi.RequestOptions): Promise<GetInterimResultsResponse>;
8
- getResult(jobId: string, requestOptions?: ServiceApi.RequestOptions): Promise<GetResultResponse>;
9
- getStatus(jobId: string, requestOptions?: ServiceApi.RequestOptions): Promise<Job>;
10
- healthCheck(requestOptions?: ServiceApi.RequestOptions): Promise<HealthCheckResponse>;
11
- startExecution(request?: StartExecutionRequest, requestOptions?: ServiceApi.RequestOptions): Promise<Job>;
12
- private doGetResultWithRetries;
13
- private doWaitForFinalState;
14
- private jobHasFinished;
15
- private waitForFinalState;
5
+ api(): ServiceApi;
16
6
  }