@qbraid-core/compute 0.4.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/README.md +34 -0
- package/dist/src/client.d.ts +13 -0
- package/dist/src/client.js +63 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +11 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +78 -0
- package/dist/src/types.js +5 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<img align="right" width="100" alt="qbraid" src="https://qbraid-static.s3.amazonaws.com/logos/qbraid.png">
|
|
2
|
+
|
|
3
|
+
# [@qbraid-core/compute](https://qbraid.github.io/qbraid-core-js/modules/compute.html)
|
|
4
|
+
|
|
5
|
+
[![Stable][preview-stability]](https://qbraid.github.io/qbraid-core-js/#launch-stages)
|
|
6
|
+
[](https://npm.im/@qbraid-core/compute)
|
|
7
|
+
|
|
8
|
+
Client for the qBraid Compute Manager.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @qbraid-core/compute
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage Example
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { ComputeManagerClient } from '@qbraid-core/compute';
|
|
20
|
+
|
|
21
|
+
const client = new ComputeManagerClient();
|
|
22
|
+
|
|
23
|
+
const computeProfiles = await client.getComputeManagerAsync('<<your-email>>');
|
|
24
|
+
|
|
25
|
+
computeProfiles.forEach(profile => console.log(`${profile.slug} - ${profile.description}`));
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
This software is proprietary and subject to the terms of the [qBraid Commercial Software License](https://qbraid.github.io/qbraid-core-js/#license).
|
|
31
|
+
|
|
32
|
+
[stable-stability]: https://img.shields.io/badge/stability-stable-green
|
|
33
|
+
[preview-stability]: https://img.shields.io/badge/stability-preview-orange
|
|
34
|
+
[deprecated-stability]: https://img.shields.io/badge/stability-deprecated-red
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { QbraidClient, QbraidSession } from '@qbraid-core/base';
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
3
|
+
import { ComputeProfile, UserServerStatus } from './types';
|
|
4
|
+
export declare class ComputeManagerClient extends QbraidClient {
|
|
5
|
+
private qBraidURLs;
|
|
6
|
+
constructor(session?: QbraidSession, hubURL?: string, labURL?: string);
|
|
7
|
+
getComputeManager(userEmail: string): Promise<ComputeProfile[]>;
|
|
8
|
+
getUserLabToken(userApiKey: string): Promise<string>;
|
|
9
|
+
startServer(labToken: string, profileSlug?: string): Promise<AxiosResponse>;
|
|
10
|
+
stopServer(labToken: string, labUserName: string): Promise<AxiosResponse>;
|
|
11
|
+
statusServer(labToken: string, labUserName: string): Promise<UserServerStatus>;
|
|
12
|
+
getProfilePrice(profileSlug: string): Promise<number>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2025, qBraid Development Team
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ComputeManagerClient = void 0;
|
|
9
|
+
const base_1 = require("@qbraid-core/base");
|
|
10
|
+
const context_1 = require("@qbraid-core/base/src/context");
|
|
11
|
+
const axios_1 = __importDefault(require("axios"));
|
|
12
|
+
class ComputeManagerClient extends base_1.QbraidClient {
|
|
13
|
+
qBraidURLs;
|
|
14
|
+
constructor(session, hubURL = context_1.DEFAULT_HUB_URL, labURL = context_1.DEFAULT_LAB_URL) {
|
|
15
|
+
super(session);
|
|
16
|
+
this.qBraidURLs = {
|
|
17
|
+
hub: hubURL,
|
|
18
|
+
lab: labURL,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async getComputeManager(userEmail) {
|
|
22
|
+
const response = await this.session.client.get(`/api/lab/compute/get-profiles/${userEmail}`);
|
|
23
|
+
return response.data;
|
|
24
|
+
}
|
|
25
|
+
async getUserLabToken(userApiKey) {
|
|
26
|
+
const response = await this.session.client.get('/api/lab/compute/tokens', {
|
|
27
|
+
headers: {
|
|
28
|
+
'api-key': userApiKey,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const data = response.data;
|
|
32
|
+
const tokenData = data.token;
|
|
33
|
+
return tokenData.token;
|
|
34
|
+
}
|
|
35
|
+
async startServer(labToken, profileSlug = '2vCPU_4GB') {
|
|
36
|
+
const response = await this.session.client.post('/api/lab/compute/start/server', {
|
|
37
|
+
labToken: labToken,
|
|
38
|
+
labURL: this.qBraidURLs['lab'],
|
|
39
|
+
slug: profileSlug,
|
|
40
|
+
});
|
|
41
|
+
return response;
|
|
42
|
+
}
|
|
43
|
+
async stopServer(labToken, labUserName) {
|
|
44
|
+
const response = await axios_1.default.delete(`${this.qBraidURLs['hub']}/hub/api/users/${labUserName}/server`, { headers: { Authorization: `token ${labToken}` } });
|
|
45
|
+
return response;
|
|
46
|
+
}
|
|
47
|
+
async statusServer(labToken, labUserName) {
|
|
48
|
+
const response = await axios_1.default.get(`${this.qBraidURLs['hub']}/hub/api/users/${labUserName}`, {
|
|
49
|
+
headers: {
|
|
50
|
+
Authorization: `token ${labToken}`,
|
|
51
|
+
Accept: '*/*',
|
|
52
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
return response.data;
|
|
56
|
+
}
|
|
57
|
+
async getProfilePrice(profileSlug) {
|
|
58
|
+
const response = await this.session.client.get(`/api/lab/compute/get-profile-price/${profileSlug}`);
|
|
59
|
+
return response.data;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ComputeManagerClient = ComputeManagerClient;
|
|
63
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";AAAA,8CAA8C;AAC9C,uBAAuB;;;;;;AAEvB,4CAAgE;AAChE,2DAAiF;AACjF,kDAA6C;AAI7C,MAAa,oBAAqB,SAAQ,mBAAY;IAC5C,UAAU,CAA4B;IAE9C,YACE,OAAuB,EACvB,SAAiB,yBAAe,EAChC,SAAiB,yBAAe;QAEhC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,GAAG;YAChB,GAAG,EAAE,MAAM;YACX,GAAG,EAAE,MAAM;SACZ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,SAAiB;QACvC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAC5C,iCAAiC,SAAS,EAAE,CAC7C,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,UAAkB;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAmB,yBAAyB,EAAE;YAC1F,OAAO,EAAE;gBACP,SAAS,EAAE,UAAU;aACtB;SACF,CAAC,CAAC;QAEH,MAAM,IAAI,GAAqB,QAAQ,CAAC,IAAI,CAAC;QAC7C,MAAM,SAAS,GAAa,IAAI,CAAC,KAAK,CAAC;QACvC,OAAO,SAAS,CAAC,KAAK,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAAgB,EAAE,cAAsB,WAAW;QACnE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,+BAA+B,EAAE;YAC/E,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;YAC9B,IAAI,EAAE,WAAW;SAClB,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAAgB,EAAE,WAAmB;QACpD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,MAAM,CACjC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,kBAAkB,WAAW,SAAS,EAC/D,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,SAAS,QAAQ,EAAE,EAAE,EAAE,CACpD,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,WAAmB;QACtD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,kBAAkB,WAAW,EAAE,EAAE;YACzF,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,QAAQ,EAAE;gBAClC,MAAM,EAAE,KAAK;gBACb,cAAc,EAAE,iCAAiC;aAClD;SACF,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,WAAmB;QACvC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAC5C,sCAAsC,WAAW,EAAE,CACpD,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AApED,oDAoEC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2025, qBraid Development Team
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.ComputeManagerClient = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* @module compute
|
|
8
|
+
*/
|
|
9
|
+
var client_1 = require("./client");
|
|
10
|
+
Object.defineProperty(exports, "ComputeManagerClient", { enumerable: true, get: function () { return client_1.ComputeManagerClient; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,8CAA8C;AAC9C,uBAAuB;;;AAEvB;;GAEG;AACH,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export interface ComputeProfile {
|
|
2
|
+
slug: string;
|
|
3
|
+
display_name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
plan: string;
|
|
6
|
+
node_env: string;
|
|
7
|
+
machineInternalName: string;
|
|
8
|
+
documentationDetails: string;
|
|
9
|
+
rateDollar: number;
|
|
10
|
+
rateTimeFrame: string;
|
|
11
|
+
rateRatioOffered: number;
|
|
12
|
+
visibility: string;
|
|
13
|
+
lastRefreshDateTime?: Date;
|
|
14
|
+
kubespawner_override: {
|
|
15
|
+
image: string;
|
|
16
|
+
cpu_guarantee: number;
|
|
17
|
+
cpu_limit: number;
|
|
18
|
+
mem_limit: string;
|
|
19
|
+
mem_guarantee: string;
|
|
20
|
+
start_timeout?: number;
|
|
21
|
+
node_selector?: {
|
|
22
|
+
'cloud.google.com/gke-accelerator'?: string;
|
|
23
|
+
};
|
|
24
|
+
tolerations?: Array<{
|
|
25
|
+
key?: string;
|
|
26
|
+
operator?: string;
|
|
27
|
+
value?: string;
|
|
28
|
+
effect?: string;
|
|
29
|
+
}>;
|
|
30
|
+
extra_resource_limits?: {
|
|
31
|
+
'nvidia.com/gpu'?: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface ServerDetails {
|
|
36
|
+
name: string;
|
|
37
|
+
ready: boolean;
|
|
38
|
+
stopped: boolean;
|
|
39
|
+
pending: string;
|
|
40
|
+
url: string;
|
|
41
|
+
progress_url: string;
|
|
42
|
+
started: string;
|
|
43
|
+
last_activity: string;
|
|
44
|
+
user_options: Record<string, unknown>;
|
|
45
|
+
full_url?: string;
|
|
46
|
+
full_progress_url?: string;
|
|
47
|
+
state?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
export interface UserServerStatus {
|
|
50
|
+
name: string;
|
|
51
|
+
admin: boolean;
|
|
52
|
+
roles: string[];
|
|
53
|
+
groups: string[];
|
|
54
|
+
server: string;
|
|
55
|
+
pending: string;
|
|
56
|
+
last_activity: string;
|
|
57
|
+
servers: Record<string, ServerDetails>;
|
|
58
|
+
auth_state?: Record<string, unknown>;
|
|
59
|
+
session_id?: string;
|
|
60
|
+
scopes?: string[];
|
|
61
|
+
}
|
|
62
|
+
export interface LabToken {
|
|
63
|
+
token: string;
|
|
64
|
+
user: string;
|
|
65
|
+
id: string;
|
|
66
|
+
kind: string;
|
|
67
|
+
roles: string[];
|
|
68
|
+
scopes: string[];
|
|
69
|
+
created: string;
|
|
70
|
+
last_activity: string;
|
|
71
|
+
expires_at: string;
|
|
72
|
+
note: string;
|
|
73
|
+
session_id: string;
|
|
74
|
+
oauth_client: string;
|
|
75
|
+
}
|
|
76
|
+
export interface LabTokenResponse {
|
|
77
|
+
token: LabToken;
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA,8CAA8C;AAC9C,uBAAuB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qbraid-core/compute",
|
|
3
|
+
"description": "Client for the qBraid Compute service.",
|
|
4
|
+
"version": "0.4.0",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"author": "qBraid Development Team",
|
|
8
|
+
"license": "Proprietary",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/src"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"qbraid",
|
|
14
|
+
"qbraid-core",
|
|
15
|
+
"qbraid-core-js",
|
|
16
|
+
"qbraid compute",
|
|
17
|
+
"qbraid cloud",
|
|
18
|
+
"qbraid api",
|
|
19
|
+
"qbraid apis",
|
|
20
|
+
"cloud",
|
|
21
|
+
"quantum",
|
|
22
|
+
"quantum computing"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"directory": "packages/compute",
|
|
27
|
+
"url": "git+https://github.com/qBraid/qbraid-core-js.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://qbraid.github.io/qbraid-core-js/modules/compute.html",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@qbraid-core/base": "0.4.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo src/*.d.ts src/*.js",
|
|
35
|
+
"lint": "eslint src",
|
|
36
|
+
"lint:fix": "eslint src --fix",
|
|
37
|
+
"format": "prettier --write \"src/**/*.{ts,json}\"",
|
|
38
|
+
"format:check": "prettier --check \"src/**/*.{ts,json}\"",
|
|
39
|
+
"docs": "typedoc"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=20"
|
|
43
|
+
}
|
|
44
|
+
}
|