# clusterpost-lib

> Library implementing the API of clusterpost-server application

Latest version **2.9.1** (published 2021-07-28) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install clusterpost-lib
pnpm add clusterpost-lib
yarn add clusterpost-lib
bun add clusterpost-lib
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.9.1 |
| Published | 2021-07-28 |
| First published | 2016-07-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 34.1 KB |
| Known vulnerabilities | 0 (+6 in 3 direct dependencies) |
| Install scripts | no |
| Author | juanprietob@gmail.com |
| Maintainers | juanprietob |
| Keywords | clusterpost, library, implementation, API |

## Links

- npm: https://www.npmjs.com/package/clusterpost-lib
- Repository: https://github.com/juanprietob/clusterpost
- Homepage: https://github.com/juanprietob/clusterpost#readme
- Issues: https://github.com/juanprietob/clusterpost/issues
- npm.io page: https://npm.io/package/clusterpost-lib

## Dependencies (9)

- [prompt](https://npm.io/package/prompt.md) ^1.0.0
- [request](https://npm.io/package/request.md) ^2.73.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.1
- [@hapi/joi](https://npm.io/package/@hapi/joi.md) ^15.0.3
- [underscore](https://npm.io/package/underscore.md) ^1.8.3
- [extract-zip](https://npm.io/package/extract-zip.md) ^2.0.1
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^7.4.0
- [clusterpost-model](https://npm.io/package/clusterpost-model.md) ^1.15.0
- [hapi-jwt-couch-lib](https://npm.io/package/hapi-jwt-couch-lib.md) ^1.1.3

## Recent versions

- 2.9.1 (latest) — 2021-07-28
- 2.9.0 — 2021-07-14
- 2.8.0 — 2021-04-13
- 2.7.0 — 2021-04-13
- 2.6.1 — 2021-03-22
- 2.6.0 — 2021-03-08
- 2.5.0 — 2020-06-10
- 2.4.2 — 2020-06-04
- 2.4.1 — 2020-06-04
- 2.4.0 — 2019-05-24
- 2.3.0 — 2019-05-22
- 2.2.0 — 2019-05-19
- 2.1.2 — 2019-05-19
- 2.1.1 — 2019-05-19
- 2.1.0 — 2018-10-26
- … 24 more at https://npm.io/package/clusterpost-lib/versions

## README

# clusterpost-lib

It implements the API to submit jobs to [clusterpost-server](https://www.npmjs.com/package/clusterpost-server).
This library is used by [clusterpost-app](https://www.npmjs.com/package/clusterpost-app) which implements
submit and retrieve functionalities from the server. 

## New way to submit jobs: 

---
	var clusterpost = require("clusterpost-lib");

	# The config file is is optional, if not provided. It will store the info in your home folder. 
	var configfile = './conf.jobCreation.json';


	clusterpost.start(configfile)
    .then(function(res){

        return clusterpost.parseCLIFromStringAndSubmit("SomeExpensiveTask --img ./data/gravitational-waves-simulation.jpg --img2 ./data/gravitational-waves-simulation.jpg -out ./data.nii.gz")
        .then(function(id){
            console.log(jobid);
        });
    });
---


## An example to submit a job (The old way):

----
	var clusterpost = require("clusterpost-lib");

	var inputfiles = [];

	inputfiles.push(path.join(inputdir, "/some/path/img.jpg"));
	inputfiles.push(path.join(inputdir, "/some/path/img1.jpg"));
	inputfiles.push(path.join(inputdir, "/some/path/img2.jpg"));


	var job = {
	    "executable": "aVeryExpensiveTask",
	    "parameters": [
	        {
	            "flag": "--img",
	            "name": "img.jpg"
	        },
	        {
	            "flag": "--mask",
	            "name": "img1.jpg"
	        },
	        {
	        	"flag": "-labelValue",
	        	"name": "6"
	        },
	        {
	            "flag": "--labelImg",
	            "name": "pvec.nii.gz"
	        },
	        {
	        	"flag": "--outDir",
	            "name": "./"	
	        }
	    ],
	    "inputs": [
	        {
	            "name": "img.jpg"
	        },
	        {
	            "name": "img1.jpg"
	        },
	        {
	            "name": "img2.jpg"
	        }
	    ],
	    "outputs": [
	        {
	            "type": "tar.gz",
	            "name": "./"
	        },
	        {
	            "type": "file",
	            "name": "stdout.out"
	        },
	        {
	            "type": "file",
	            "name": "stderr.err"
	        }
	    ],
	    "type": "job",
	    "userEmail": "juanprietob@gmail.com"
	};

	var agentoptions = {
		rejectUnauthorized: false //You can also read a certificate here if you want to use https connection and remove this
	}
	clusterpost.setAgentOptions(agentoptions);

	clusterpost.start()
	.then(function(res){
		return clusterpost.getExecutionServers();
	})
	.then(function(res){
		job.executionserver = res[0].name; //Or select the computing grid where you want to submit your job.
		return clusterpost.createAndSubmitJob(job, inputfiles)
	})
	.then(function(jobid){
		console.log(jobid);//Job id of the task submitted
	})
	.catch(console.error)
----


Once your job is submitted, you can retrieve the results with the following script

----
	var clusterpost = require("clusterpost-lib");

	clusterpost.setClusterPostServer("https://localhost:8180");

	var agentoptions = {
		rejectUnauthorized: false
	}

	clusterpost.setAgentOptions(agentoptions);

	clusterpost.userLogin({
		"email": "your@email.com",
		"password": "passwd"
		})
	.then(function(res){
	    return clusterpost.getJobs("aVeryExpensiveTask");
	})
	.then(function(res){
	    console.log(res);
	})
	.catch(console.error)
----

---
_Source: https://npm.io/package/clusterpost-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
