0.1.2 • Published 8 months ago

@omotes/sdk v0.1.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

@omotes/sdk

This library exposes functionality to publish and consume jobs on the OMOTES computation engine. Please make sure to follow the steps in that repository to get started running the computation engine locally.

Documentation

OmotesSDK

Main entry point of this SDK. Requires RabbitMQ port, credentials described above.

Example

const sdk = new OmotesSDK({
  rabbitMQUrl: 'localhost',
  rabbitMQUsername: 'foo',
  rabbitMQPassword: 'bar',
  rabbitMQPort: 8088
});

// This is required to setup an AMQP connection.
await sdk.connect();

Submitting a job

If you have an ESDL file ready to file with the OMOTES Computation Engine, you can submit a job like so:

const job = await sdk.submitJob('grow_simulator', 'my-esdl');

This will return an instance of the class Job which can then be used to retrieve different Handlers (ProgressHandler, ResultsHandler, StatusHandler). These handlers all implement a getter method (getProgress(), getResult(), getStatus()). They return an Observable<T> with information on the submitted job.

Handlers

ResultsHandler

Get a ResultsHandler like so:

const job = await sdk.submitJob('grow_optimizer', 'esdl');
const resultsHandler = sdk.getResultsHandler(job.uuid);
resultsHandler.getResults().subscribe((result) => {
  expect(result).toEqual({
    uuid: 'uuid',
    logs: 'logs',
    outputEsdl: Buffer.from('output_esdl').toString('base64'),
    resultType: JobResult.ResultType.SUCCEEDED
  });
});

ProgressHandler

Get a ProgressHandler like so:

const job = await sdk.submitJob('grow_optimizer', 'esdl');
const progressHandler = sdk.getProgressHandler(job.uuid);
progressHandler.getProgress().subscribe((progress) => {
  console.log(progress); // a value between 0 and 1
});

StatusHandler

Get a StatusHandler like so:

const job = sdk.submitJob('grow_optimizer', 'esdl');
const statusHandler = sdk.getStatusHandler(job.uuid);
statusHandler.getStatus().subscribe((status) => {
  console.log(status); // one of 'REGISTERED' | 'ENQUEUED' | 'RUNNING' | 'FINISHED' | 'CANCELLED'
});

Building

Run nx build sdk to build the library.

Running unit tests

Run nx test sdk to execute the unit tests via Jest.

0.1.2

8 months ago

0.1.1

8 months ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.5

1 year ago

0.0.6

1 year ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago