This package allows you to use Qarnot cloud computing service.
npm install @qarnot/sdk
- SDK documentation
- SDK repository
- General documentation
- Qarnot computing portal
- REST API documentation
-
Create a Qarnot account and get your API token: Account.
-
Monitor your tasks and manage your data: Console.
-
SDK initialization
const QarnotSDK = require('@qarnot/sdk'); const Qarnot = new QarnotSDK({ auth:'secret_token' // Retrieve your token from https://account.qarnot.com storage: { accessKeyId: 'email_address_of_user' } });
await Qarnot.tasks.run({
name: 'helloworld',
profile: 'docker-batch',
instanceCount: 4,
constants: [{
key: 'DOCKER_CMD',
value: 'echo hello world from node ${INSTANCE_ID}!'
}]
});
/* Output:
2> hello world from node 2!
1> hello world from node 1!
0> hello world from node 0!
3> hello world from node 3!
*/
NB. This method returns only when the task is completed. For long running task you might want to check the submit method
await Qarnot.buckets.createBucket('my-input-bucket');
await Qarnot.buckets.upload('my-input-bucket', 'input.txt', 'hello world !');
await Qarnot.buckets.createBucket('my-output-bucket');
await Qarnot.tasks.run({
name: 'helloworld-withdata',
profile: 'docker-batch',
instanceCount: 1,
resourceBuckets: [
'my-input-bucket',
],
resultBucket : 'my-output-bucket',
constants: [{
key: 'DOCKER_CMD',
value: 'sh -c "cat input.txt | rev > output.txt"'
}]
});
const result = await Qarnot.buckets.download('my-output-bucket', 'output.txt');
console.log(result.Body.toString());
/* Output:
! dlrow olleh
*/
You can find examples in the test
directory of the github repository
Pull requests and github issues are welcome.
Licensed under Apache 2.0