pipelineobject
v1.1.0
Published
Class to instantiate pipelines
Downloads
4
Maintainers
Readme
Pipelineobject
Class to instantiate pipelines. All the documentation here is in TypeScript.
Pre-requisite to understand and use this library : taskobject (GitHub repo, NPM package).
Installation
In your project directory :
npm install pipelineobject
Usage
All examples are related.
Import
import p = require("pipelineobject");
Instantiation - TO COMPLETE
To instantiate a pipeline object, you need :
- a Job Manager object (
JMobject
) given by the functionJMsetup()
(in the./node_modules/pipelineobject/ts/src/test/index.js
) - a list of literals describing the pipeline nodes (see the List of nodes section),
- a list of the links (see the List of links section).
Then you can instantiate your pipeline object :
import testFunc = require("./test/index")
testFunc.JMsetup().on('ready', (JMobject) => {
let myPipeline = new p.Pipeline(JMobject, myNodes, myLinks);
});
Push input
You have to give the content of your input and a reference to the slot (see the Slot reference section) :
let contentInput = fs.readFileSync(myFile, "utf8");
myPipeline.push(contentInput, { taskIndex: 0, slotName: "slot1" });
New task modules
When you want to use a task newly created in a pipeline (myNewTask
), you have to add it to the imports in the ./node_modules/pipelineobject/ts/src/index.ts
script, at its beginning :
let taskModules = {
naccesstask: require('naccesstask').naccesstask,
hextask: require('hextask').hextask,
myNewTask: require('myNewTask').myNewTask // added
}
Then you have to compile the code : go in the ./node_modules/pipelineobject/
directory and use the command :
tsc -p ./tsconfig.json
Warning : do not forget to install your new task module in
./node_modules
!
Note : your task class need to respect the implementation explained in the taskobject documentation (GitHub repo, NPM package).
Data structures
This part helps to understand the data you have to give to your pipeline object and the data it creates. All examples are related.
List of nodes
When you want to instantiate a pipeline, you need to give it a list of nodes (see the Instantiation section).
It's a list of all the tasks composing the pipeline, like for example :
myNodes = [
{ tagtask: "taskA" }, // index = 0
{ tagtask: "taskB" }, // index = 1
{ tagtask: "taskC" } // index = 2
];
Note : the "tagtask" designs the task module name (like "naccesstask" for example GitHub repo, NPM package). This task module must be required in the
./node_modules/pipelineobject/ts/src/index.ts
script (see the New task modules section).
List of links
When you instantiate a pipeline, you have to give it a list of links (see the Instantiation section). A link is described by :
- the index of the source task,
- the index of the task to which the target slot belongs,
- the name of the target slot.
Thus, the list of links must be like :
myLinks = [
{ source: 0, target: 2, slot: "slot1" },
{ source: 1, target: 2, slot: "slot2" }
]
List of tasks
At the instantiation (see the Instantiation section), the pipeline class will create a list of task objects, like :
this.tasks = [
[Object object], // taskA object
[Object object], // taskB object
[Object object] // taskC object
]
Literal of slots
At the instantiation (see the Instantiation section), the pipeline class will create a literal of slots objects, like :
this.slots = [
{ slot1: [Object object] }, // belongs to taskA (index = 0)
{ slot1: [Object object] }, // belongs to taskB (index = 1)
{ slot1: [Object object], slot2: [Object object] } // belong to taskC (index = 2)
]
Note : each element of this list refers to a task (same index). An element is a literal containing all the slots of the task (the key is the name of the slot).
Slot reference
When you want to push an input onto a slot (see the Push Input section), you need to use a reference to this slot. A slot reference is described by :
- the index of the task to which the slot belongs,
- the name of the slot.
For example, the reference to the slot1
of the taskA
is :
let slot1_taskA_ref = {
taskIndex: 0,
slotName: "slot1"
}