@planqk/planqk-service-sdk 2.11.0 → 2.12.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.
- package/.env.template +2 -2
- package/README-node.md +3 -3
- package/README-python.md +3 -3
- package/README.md +3 -3
- package/dist/auth.d.ts +3 -3
- package/dist/auth.js +7 -7
- package/dist/client.d.ts +1 -1
- package/dist/client.js +3 -3
- package/notebooks/python-sdk.ipynb +4 -6
- package/package.json +1 -1
- package/planqk/service/_version.py +1 -1
- package/planqk/service/auth.py +4 -4
- package/planqk/service/client.py +7 -7
- package/pyproject.toml +1 -1
- package/src/auth.ts +7 -7
- package/src/client.ts +3 -3
- package/src/index.test.ts +5 -7
package/.env.template
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
TOKEN_ENDPOINT=https://gateway.hub.kipu-quantum.com/token
|
|
2
2
|
SERVICE_ENDPOINT=https://gateway.hub.kipu-quantum.com/your-organization/your-service/1.0.0
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
ACCESS_KEY_ID=your-access-key-id
|
|
4
|
+
SECRET_ACCESS_KEY=your-secret-access-key
|
package/README-node.md
CHANGED
|
@@ -12,11 +12,11 @@ npm install @planqk/planqk-service-sdk
|
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
14
|
const serviceEndpoint = "..."
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const accessKeyId = "..."
|
|
16
|
+
const secretAccessKey = "..."
|
|
17
17
|
|
|
18
18
|
// Create a new PlanqkServiceClient instance
|
|
19
|
-
const client = new PlanqkServiceClient(serviceEndpoint,
|
|
19
|
+
const client = new PlanqkServiceClient(serviceEndpoint, accessKeyId, secretAccessKey)
|
|
20
20
|
|
|
21
21
|
// List all service executions
|
|
22
22
|
const serviceExecutions = await client.api().getServiceExecutions()
|
package/README-python.md
CHANGED
|
@@ -14,12 +14,12 @@ pip install --upgrade planqk-service-sdk
|
|
|
14
14
|
import os
|
|
15
15
|
from planqk.service.client import PlanqkServiceClient
|
|
16
16
|
|
|
17
|
-
consumer_key = "..."
|
|
18
|
-
consumer_secret = "..."
|
|
19
17
|
service_endpoint = "..."
|
|
18
|
+
access_key_id = "..."
|
|
19
|
+
secret_access_key = "..."
|
|
20
20
|
|
|
21
21
|
# Create a new PlanqkServiceClient instance
|
|
22
|
-
client = PlanqkServiceClient(service_endpoint,
|
|
22
|
+
client = PlanqkServiceClient(service_endpoint, access_key_id, secret_access_key)
|
|
23
23
|
|
|
24
24
|
# Prepare your input data and parameters
|
|
25
25
|
data = {"values": [2]}
|
package/README.md
CHANGED
|
@@ -12,11 +12,11 @@ npm install @planqk/planqk-service-sdk
|
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
14
|
const serviceEndpoint = "..."
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const accessKeyId = "..."
|
|
16
|
+
const secretAccessKey = "..."
|
|
17
17
|
|
|
18
18
|
// Create a new PlanqkServiceClient instance
|
|
19
|
-
const client = new PlanqkServiceClient(serviceEndpoint,
|
|
19
|
+
const client = new PlanqkServiceClient(serviceEndpoint, accessKeyId, secretAccessKey)
|
|
20
20
|
|
|
21
21
|
// List all service executions
|
|
22
22
|
const serviceExecutions = await client.api().getServiceExecutions()
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare const DEFAULT_TOKEN_ENDPOINT = "https://gateway.hub.kipu-quantum.com/token";
|
|
2
2
|
export declare class PlanqkServiceAuth {
|
|
3
3
|
private accessToken;
|
|
4
|
-
private readonly
|
|
5
|
-
private readonly
|
|
4
|
+
private readonly accessKeyId;
|
|
5
|
+
private readonly secretAccessKey;
|
|
6
6
|
private readonly tokenEndpoint;
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(accessKeyId: string, secretAccessKey: string, tokenEndpoint?: string);
|
|
8
8
|
getAccessToken(): Promise<string>;
|
|
9
9
|
private fetchAccessToken;
|
|
10
10
|
}
|
package/dist/auth.js
CHANGED
|
@@ -5,12 +5,12 @@ const simple_oauth2_1 = require("simple-oauth2");
|
|
|
5
5
|
exports.DEFAULT_TOKEN_ENDPOINT = 'https://gateway.hub.kipu-quantum.com/token';
|
|
6
6
|
class PlanqkServiceAuth {
|
|
7
7
|
accessToken;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
accessKeyId;
|
|
9
|
+
secretAccessKey;
|
|
10
10
|
tokenEndpoint;
|
|
11
|
-
constructor(
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
11
|
+
constructor(accessKeyId, secretAccessKey, tokenEndpoint = exports.DEFAULT_TOKEN_ENDPOINT) {
|
|
12
|
+
this.accessKeyId = accessKeyId;
|
|
13
|
+
this.secretAccessKey = secretAccessKey;
|
|
14
14
|
this.tokenEndpoint = tokenEndpoint;
|
|
15
15
|
}
|
|
16
16
|
async getAccessToken() {
|
|
@@ -29,8 +29,8 @@ class PlanqkServiceAuth {
|
|
|
29
29
|
tokenPath: '/token',
|
|
30
30
|
},
|
|
31
31
|
client: {
|
|
32
|
-
id: this.
|
|
33
|
-
secret: this.
|
|
32
|
+
id: this.accessKeyId,
|
|
33
|
+
secret: this.secretAccessKey,
|
|
34
34
|
},
|
|
35
35
|
options: {
|
|
36
36
|
authorizationMethod: 'body',
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ServiceApi } from "./sdk/api/resources/serviceApi/client/Client";
|
|
2
2
|
export declare class PlanqkServiceClient {
|
|
3
3
|
private _api;
|
|
4
|
-
constructor(serviceEndpoint: string,
|
|
4
|
+
constructor(serviceEndpoint: string, accessKeyId?: string, secretAccessKey?: string, tokenEndpoint?: string);
|
|
5
5
|
api(): ServiceApi;
|
|
6
6
|
}
|
package/dist/client.js
CHANGED
|
@@ -5,9 +5,9 @@ const auth_1 = require("./auth");
|
|
|
5
5
|
const sdk_1 = require("./sdk");
|
|
6
6
|
class PlanqkServiceClient {
|
|
7
7
|
_api;
|
|
8
|
-
constructor(serviceEndpoint,
|
|
9
|
-
if (
|
|
10
|
-
const auth = new auth_1.PlanqkServiceAuth(
|
|
8
|
+
constructor(serviceEndpoint, accessKeyId, secretAccessKey, tokenEndpoint = auth_1.DEFAULT_TOKEN_ENDPOINT) {
|
|
9
|
+
if (accessKeyId && secretAccessKey) {
|
|
10
|
+
const auth = new auth_1.PlanqkServiceAuth(accessKeyId, secretAccessKey, tokenEndpoint);
|
|
11
11
|
this._api = new sdk_1.PlanqkServiceApiClient({
|
|
12
12
|
environment: () => serviceEndpoint,
|
|
13
13
|
token: async () => auth.getAccessToken(),
|
|
@@ -28,13 +28,11 @@
|
|
|
28
28
|
"\n",
|
|
29
29
|
"token_endpoint = os.getenv(\"TOKEN_ENDPOINT\", \"https://gateway.hub.kipu-quantum.com/token\")\n",
|
|
30
30
|
"service_endpoint = os.getenv(\"SERVICE_ENDPOINT\", \"https://gateway.hub.kipu-quantum.com/your-organization/your-service/1.0.0\")\n",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"access_key_id = os.getenv(\"ACCESS_KEY_ID\", None)\n",
|
|
32
|
+
"secret_access_key = os.getenv(\"SECRET_ACCESS_KEY\", None)\n",
|
|
33
33
|
"\n",
|
|
34
34
|
"print(f\"Token endpoint: {token_endpoint}\")\n",
|
|
35
|
-
"print(f\"Service endpoint: {service_endpoint}\")
|
|
36
|
-
"print(f\"Consumer key: {consumer_key}\")\n",
|
|
37
|
-
"print(f\"Consumer secret: {consumer_secret}\")"
|
|
35
|
+
"print(f\"Service endpoint: {service_endpoint}\")"
|
|
38
36
|
]
|
|
39
37
|
},
|
|
40
38
|
{
|
|
@@ -54,7 +52,7 @@
|
|
|
54
52
|
"\n",
|
|
55
53
|
"# Create a new PlanqkServiceClient instance\n",
|
|
56
54
|
"client = PlanqkServiceClient(\n",
|
|
57
|
-
" service_endpoint,
|
|
55
|
+
" service_endpoint, access_key_id, secret_access_key, token_endpoint\n",
|
|
58
56
|
")"
|
|
59
57
|
]
|
|
60
58
|
},
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.
|
|
1
|
+
__version__ = "2.12.0"
|
package/planqk/service/auth.py
CHANGED
|
@@ -9,9 +9,9 @@ DEFAULT_TOKEN_ENDPOINT = "https://gateway.hub.kipu-quantum.com/token"
|
|
|
9
9
|
class PlanqkServiceAuth:
|
|
10
10
|
_logger = logging.getLogger(__name__)
|
|
11
11
|
|
|
12
|
-
def __init__(self,
|
|
13
|
-
self.
|
|
14
|
-
self.
|
|
12
|
+
def __init__(self, access_key_id: str, secret_access_key: str, token_endpoint: str = DEFAULT_TOKEN_ENDPOINT):
|
|
13
|
+
self._access_key_id = access_key_id
|
|
14
|
+
self._secret_access_key = secret_access_key
|
|
15
15
|
self._token_endpoint = token_endpoint
|
|
16
16
|
self._token = None
|
|
17
17
|
self._last_token_fetch = None
|
|
@@ -28,7 +28,7 @@ class PlanqkServiceAuth:
|
|
|
28
28
|
|
|
29
29
|
def _refresh_token(self):
|
|
30
30
|
self._logger.debug("Creating new token using client credentials flow")
|
|
31
|
-
with OAuth2Client(self.
|
|
31
|
+
with OAuth2Client(self._access_key_id, self._secret_access_key) as client:
|
|
32
32
|
token = client.fetch_token(self._token_endpoint, grant_type='client_credentials')
|
|
33
33
|
|
|
34
34
|
self._token = token
|
package/planqk/service/client.py
CHANGED
|
@@ -113,19 +113,19 @@ class PlanqkServiceClient:
|
|
|
113
113
|
def __init__(
|
|
114
114
|
self,
|
|
115
115
|
service_endpoint: str,
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
access_key_id: typing.Union[str, None],
|
|
117
|
+
secret_access_key: typing.Union[str, None],
|
|
118
118
|
token_endpoint: str = DEFAULT_TOKEN_ENDPOINT,
|
|
119
119
|
):
|
|
120
120
|
self._service_endpoint = service_endpoint
|
|
121
|
-
self.
|
|
122
|
-
self.
|
|
121
|
+
self._access_key_id = access_key_id
|
|
122
|
+
self._secret_access_key = secret_access_key
|
|
123
123
|
self._token_endpoint = token_endpoint
|
|
124
124
|
|
|
125
|
-
if (self.
|
|
125
|
+
if (self._access_key_id is not None) or (self._secret_access_key is not None):
|
|
126
126
|
self._auth = PlanqkServiceAuth(
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
access_key_id=self._access_key_id,
|
|
128
|
+
secret_access_key=self._secret_access_key,
|
|
129
129
|
token_endpoint=self._token_endpoint,
|
|
130
130
|
)
|
|
131
131
|
self._api = PlanqkServiceApi(base_url=self._service_endpoint, token=self._auth.get_token)
|
package/pyproject.toml
CHANGED
package/src/auth.ts
CHANGED
|
@@ -4,13 +4,13 @@ export const DEFAULT_TOKEN_ENDPOINT = 'https://gateway.hub.kipu-quantum.com/toke
|
|
|
4
4
|
|
|
5
5
|
export class PlanqkServiceAuth {
|
|
6
6
|
private accessToken: AccessToken | undefined
|
|
7
|
-
private readonly
|
|
8
|
-
private readonly
|
|
7
|
+
private readonly accessKeyId: string
|
|
8
|
+
private readonly secretAccessKey: string
|
|
9
9
|
private readonly tokenEndpoint: string
|
|
10
10
|
|
|
11
|
-
constructor(
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
11
|
+
constructor(accessKeyId: string, secretAccessKey: string, tokenEndpoint: string = DEFAULT_TOKEN_ENDPOINT) {
|
|
12
|
+
this.accessKeyId = accessKeyId
|
|
13
|
+
this.secretAccessKey = secretAccessKey
|
|
14
14
|
this.tokenEndpoint = tokenEndpoint
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -33,8 +33,8 @@ export class PlanqkServiceAuth {
|
|
|
33
33
|
tokenPath: '/token',
|
|
34
34
|
},
|
|
35
35
|
client: {
|
|
36
|
-
id: this.
|
|
37
|
-
secret: this.
|
|
36
|
+
id: this.accessKeyId,
|
|
37
|
+
secret: this.secretAccessKey,
|
|
38
38
|
},
|
|
39
39
|
options: {
|
|
40
40
|
authorizationMethod: 'body',
|
package/src/client.ts
CHANGED
|
@@ -5,9 +5,9 @@ import {ServiceApi} from "./sdk/api/resources/serviceApi/client/Client";
|
|
|
5
5
|
export class PlanqkServiceClient {
|
|
6
6
|
private _api: PlanqkServiceApiClient
|
|
7
7
|
|
|
8
|
-
constructor(serviceEndpoint: string,
|
|
9
|
-
if (
|
|
10
|
-
const auth = new PlanqkServiceAuth(
|
|
8
|
+
constructor(serviceEndpoint: string, accessKeyId?: string, secretAccessKey?: string, tokenEndpoint: string = DEFAULT_TOKEN_ENDPOINT) {
|
|
9
|
+
if (accessKeyId && secretAccessKey) {
|
|
10
|
+
const auth = new PlanqkServiceAuth(accessKeyId, secretAccessKey, tokenEndpoint)
|
|
11
11
|
this._api = new PlanqkServiceApiClient({
|
|
12
12
|
environment: () => serviceEndpoint,
|
|
13
13
|
token: async () => auth.getAccessToken(),
|
package/src/index.test.ts
CHANGED
|
@@ -6,16 +6,14 @@ import {withDataPoolReference} from "./datapool";
|
|
|
6
6
|
|
|
7
7
|
const tokenEndpoint = process.env.TOKEN_ENDPOINT
|
|
8
8
|
const serviceEndpoint = process.env.SERVICE_ENDPOINT
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const accessKeyId = process.env.ACCESS_KEY_ID
|
|
10
|
+
const secretAccessKey = process.env.SECRET_ACCESS_KEY
|
|
11
11
|
|
|
12
12
|
console.log(`Token endpoint: ${tokenEndpoint}`)
|
|
13
13
|
console.log(`Service endpoint: ${serviceEndpoint}`)
|
|
14
|
-
console.log(`Consumer key: ${consumerKey}`)
|
|
15
|
-
console.log(`Consumer secret: ${consumerSecret}`)
|
|
16
14
|
|
|
17
15
|
test.skip('integration test: retrieve logs', {timeout: 5 * 60 * 1000}, async () => {
|
|
18
|
-
const client = new PlanqkServiceClient(serviceEndpoint!,
|
|
16
|
+
const client = new PlanqkServiceClient(serviceEndpoint!, accessKeyId, secretAccessKey, tokenEndpoint);
|
|
19
17
|
|
|
20
18
|
const serviceExecutions = await client.api().getServiceExecutions()
|
|
21
19
|
console.log(serviceExecutions)
|
|
@@ -25,7 +23,7 @@ test.skip('integration test: retrieve logs', {timeout: 5 * 60 * 1000}, async ()
|
|
|
25
23
|
})
|
|
26
24
|
|
|
27
25
|
test.skip('integration test: coin toss', {timeout: 5 * 60 * 1000}, async () => {
|
|
28
|
-
const client = new PlanqkServiceClient(serviceEndpoint!,
|
|
26
|
+
const client = new PlanqkServiceClient(serviceEndpoint!, accessKeyId, secretAccessKey, tokenEndpoint);
|
|
29
27
|
|
|
30
28
|
let serviceExecutions = await client.api().getServiceExecutions()
|
|
31
29
|
console.log(serviceExecutions)
|
|
@@ -62,7 +60,7 @@ test.skip('integration test: coin toss', {timeout: 5 * 60 * 1000}, async () => {
|
|
|
62
60
|
})
|
|
63
61
|
|
|
64
62
|
test.skip('integration test: using data pools', {timeout: 5 * 60 * 1000}, async () => {
|
|
65
|
-
const client = new PlanqkServiceClient(serviceEndpoint!,
|
|
63
|
+
const client = new PlanqkServiceClient(serviceEndpoint!, accessKeyId, secretAccessKey, tokenEndpoint);
|
|
66
64
|
|
|
67
65
|
const data = {file_to_read: "example.txt"}
|
|
68
66
|
const dataset = withDataPoolReference("89ae42e1-9697-4742-adfb-95bf018104c3")
|