Skip to content

Commit

Permalink
Transfered experimental branch for development of graph (#59)
Browse files Browse the repository at this point in the history
* added a manifest file output within lifecycle

* added a way to create a manifest file with the log of folders and tasks generated

* added more information on the manifest log

* changed the way folder was being reported to full paths

* changed variable from string to object and modified it to NDJSON in output file

* replaced if statement with lodash.get.

* Added a simple hack to output graphson like graph object
  • Loading branch information
tiagofilipe12 committed Jun 27, 2017
1 parent b3e1588 commit 285cc9f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/orchestrators/join.js
Expand Up @@ -8,7 +8,7 @@ const { mergeCtx } = require('../ctx')
const hash = require('../utils/hash.js')
const createTask = require('../task.js')

const join = (dispatch) => {
const join = (dispatch, logger) => {
return function (...tasks) {
let uids = []
let breakOut = false
Expand Down
28 changes: 25 additions & 3 deletions lib/reducers/collection.js
Expand Up @@ -24,25 +24,47 @@ const reducer = (state = defaultState, action) => {
}

const jsonifyGraph = (graph, obj = {}) => {
console.log(obj)
const graphsonObj = {
graph: {
mode: "NORMAL",
vertices: [],
edges: []
}
}
// console.log(graphsonObj)

const addTographSon = (graphsonObj, key, val) => {
graphsonObj.graph.vertices.push({
uid: key,
//taskName: ,
outputs: val
})
return graphsonObj
}

const assignVal = (obj, key, val) => {
if (val === undefined) {
obj[key] = { _value: '' }
} else {
obj[key] = { _value: val }
}
}

for (const [key, val] of graph.sources()) {
console.log(key)
console.log(val)
assignVal(obj, key, val)
addTographSon(graphsonObj, key, val)
}

const travelNode = (node) => {
const obj = {}
for (const [key, val] of graph.verticesFrom(node)) {
assignVal(obj, key, val)
addTographSon(graphsonObj, key, val)
Object.assign(obj[key], travelNode(key))
}

console.log(JSON.stringify(graphsonObj, null, 2))
return obj
}

Expand Down Expand Up @@ -91,7 +113,7 @@ function addOutputHandler (state, action) {
}
}

// console.log('collection as json: ', JSON.stringify(jsonifyGraph(graph), null, 2))
console.log('collection as json: ', JSON.stringify(jsonifyGraph(graph), null, 2))

return graph
}
Expand Down
21 changes: 21 additions & 0 deletions lib/sagas/lifecycle.js
Expand Up @@ -17,6 +17,9 @@ const Promise = require('bluebird')

const { tab } = require('../utils')

// new require
const fs = require('fs')

// Mostly promises
// Ran as async side effects through call() in the middle of start/end/fail sagas
const {
Expand Down Expand Up @@ -56,6 +59,9 @@ const {

const { addOutput } = require('../reducers/collection.js')

// add header to manifest file
fs.writeFile('summary_log.txt', 'Summary of the run...\n\n')

/**
* The task lifecycle.
*
Expand Down Expand Up @@ -108,6 +114,21 @@ function* lifecycle (action) {
logEmitter.emit('log', `=== ${originalTask.name} ===`)
logEmitter.emit('log', `Running task ${miniUid}`)

// Generate the object to be written to the log file
let manifestLog = { folderName: originalTask.dir,
taskName: originalTask.name,
input: originalTask.input,
output: originalTask.output,
params: originalTask.params
}
// Writes this object to the summary file
fs.appendFile('summary_log.txt', JSON.stringify(manifestLog, null, 2) + '\n' , function (err) {
if (err) {
return console.log(err)
}
console.log("Manifest file was saved!")
})

function* orderedLifecycle () {
let next
next = yield* resolveInputSaga()
Expand Down

0 comments on commit 285cc9f

Please sign in to comment.