npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

docloud-api

v0.1.14

Published

Client for IBM Decision Optimization on Cloud (DOcloud)

Downloads

30

Readme

Notice

IBM Decision Optimization on Cloud or DOcloud for short is a service that lets you solve CPLEX and OPL problems on the Cloud. You can access the interactive service called DropSolve or you can use use the API to integrate the service into your application. Here is a quick introduction with useful links. This module provides a wrapper over the REST API using Promises. The command line client for DOcloud is also a good tool and example showing how to use this API.

Example

In this following example, we submit an OPL project made of several files. The execute function takes an object to configure how the job will be created and monitored. This object provides the client with the list of attachments to create (attachments property) and where to get their streams. It also indicates if the live log must be streamed (logstream property) and to which stream. Additional parameters can be declared as well (parameters property). The execute function will create the job, upload the attachments, and monitor the execution asynchronously. It will fire events when the job is created, processed, interrupted, failed, or if an error occurred.

var docloud = require('docloud-api');
var fs = require('fs');
var client = docloud({
	  url : process.env.URL,
	  clientId : process.env.KEY
	})
	
client.execute({
		logstream : process.stdout,
		parameters : { "oaas.TIME_LIMIT" : 3*60*1000},
		attachments : [
	        {name : '.oplproject', 
	    	 stream : fs.createReadStream('test/warehouse-location/.oplproject')},
	        {name : 'warehouse_cloud.dat', 
		     stream : fs.createReadStream('test/warehouse-location/warehouse_cloud.dat')},
		    {name : 'warehouse_cloud.mod', 
			 stream : fs.createReadStream('test/warehouse-location/warehouse_cloud.mod')},
			{name : 'warehouse_data.mod', 
			 stream : fs.createReadStream('test/warehouse-location/warehouse_data.mod')},
	    ]})
	   .on('created', function(jobid){console.log(jobid+" created")})
	   .on('processed', function(jobid){
		   console.log(jobid+" processed");
		   client.downloadAttachment(jobid,'solution.json',fs.createWriteStream('test/warehouse-location/solution.json'))
		         .then(function () {return client.downloadLog(jobid,fs.createWriteStream('test/warehouse-location/solution.log'))})
	   })
	   .on('interrupted', function(jobid){console.log("job was interrupted")})
	   .on('failed', function(jobid){console.log("job failed")})
	   .on('error', function(error){console.log(error)})
	   		

Basic API

The basic API is a simple wrapper of the DOcloud REST API returning Promises. It can be used to perform simple actions and chain them using promises.To know more about the different actions, parameters and returned information, you can refer to the REST API documentation.

client.listJobs()
client.deleteJobs()
client.createJob(data)
  • Creates a new job.
  • @param data the creation parameters
  • @see POST /jobs
client.getJob(jobid)
client.deleteJob(jobid)
client.executeJob(jobid)
client.getJobExecutionStatus(jobid)
client.abortJob(jobid, kill)
client.uploadAttachment(jobid, attid, stream)
  • Upload an attachment, attachment will be compressed automatically.
  • @param jobid the job id
  • @param attid the attachment name
  • @param stream the stream to read from
  • @see PUT /jobs/{id}/attachments/{attid}/blob
client.downloadAttachment(jobid, attid, stream)
client.getLogItems(jobid,start,continuous) 
  • Returns the log items
  • @param jobid the job id
  • @param start the starting index
  • @param continuous continuous mode indicator
  • @see GET /jobs/{id}/log/items
client.downloadLog(jobid, stream)

Event API

The event API let you submit and monitor your jobs in a very simple way.

client.execute(data)
  • Submits and monitor a job execution
  • @param data the data containing attachments, parameters
  • @return the event emitter to attach event callbacks
client.submit(data)
  • Submits but do not monitor the job
  • @param data the data containing attachments, parameters
  • @return the event emitter to attach event callbacks
client.create(data)
  • Creates the job, but do not submit nor monitor it.

  • @param data the data containing attachments, parameters

  • @return the event emitter to attach event callbacks (error and created only)

Status

Under development, module API can change without notice.