@qarnot/sdk
v1.14.7
Published
SDK for Qarnot REST API
Downloads
181
Readme
Qarnot NodeJS SDK
This package allows you to use Qarnot cloud computing service.
Installation
npm install @qarnot/sdk
Links
Usage
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' } });
Run you first task !
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
Create a task with resources
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
*/
Example
You can find examples in the test
directory of the github repository
Contributions
Pull requests and github issues are welcome.
License
Licensed under Apache 2.0