Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphtask

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphtask

Graphtask is graph based task runner for complex task orchestration scenarios. It is written in Typescript and available as a commonjs or esm.

  • 0.0.1-0
  • unpublished
  • next
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Graphtask

Graphtask is graph based task runner for complex task orchestration scenarios. It is written in Typescript and available as a commonjs or esm.

Installation

Use the package manager npm to install graph task.

npm install -g graphtask

// or, as a project dependency
npm install graphtask --save-dev

Usage

Graphtask exposes a global function task(), this function is used to build a graph of tasks. The return value of task() can then be used as an input to other tasks, to form a graph. The tool uses a pool of web-workers to process tasks as efficiently as possible.

When the graph is run a task will be executed only if at least one of its inputs has succeeded (or if it has no inputs).

Writing task definitions (flows and actions).

Graphtask requires two files an NAME.flow.js and NAME.actions.js, these files define what is to be done and how it is to be done.

The flow file

The flow file describes what to do. It defines the tasks and their connections to other tasks. The following example defines four nodes. The input field defines connections between the nodes. The params field allows arbitrary data to be passed to each.

const actions = require('./tasks.actions');

const first = task({
  name: 'Wait for some time',   // The title of the task
  action: actions.wait,         // The action to run, must return a promise
  params: { some: 'input' }     // Some arbitrary data to pass in as arguments
});

const error = task({
  name: 'Fail because of error',
  action: actions.errorer,
  input: { 'first': first },    // A labeled input, the result of "first" will be passed in via the argument first
  params: { other: 'data' }
});

task({
  name: 'I dont run because all inputs failed',
  action: actions.wait,
  input: [error]
})

task({
  name: 'I run because some inputs succeeded',
  action: actions.wait,
  input: [error, first],
  params: { some: 'other input' },
})

This example produces the following graph:

simple graph

The actions file

The actions file defines how to do the tasks. These must be named functions that return a Promise.

const { wait } = require('../utils');

module.exports = {
  wait,

  async errorer() {
    throw new Error('BANNNG');
  }
};

CLI

graphtask ./tasks_folder      # Run tasks in folder
graphtask ./tasks_folder -p   # Generate a task plan (dont execute task actions)
graphtask ./tasks_folder -o ./results   # Write the output of the run in .json, .log & .dot format to the ./results folder

graphtask --help          # Display command help

Examples

See ./examples sub-folders

e.g.

./lib/cjs/cli/index.js ./examples/simple -o /tmp
./lib/cjs/cli/index.js ./examples/complex -o /tmp

-- TODO

Tests

-- TODO

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

FAQs

Package last updated on 01 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc