@veritone/node-red-contrib-aiware
Advanced tools
Comparing version 2.0.0-alpha.8 to 2.0.0-alpha.9
@@ -189,3 +189,4 @@ const lib = require('../lib'); | ||
let jobParams = { | ||
context: ctx, node, jobId, waitTime, categoryName, originalInputUrl: task.inputUrl, currentJobStatus: jobStatus, engineId: task.engineId | ||
context: ctx, node, jobId, waitTime, categoryName, originalInputUrl: task.inputUrl, currentJobStatus: jobStatus, | ||
engineId: task.engineId, realControllerBaseUrl: config.controllerBaseUrl | ||
}; | ||
@@ -205,2 +206,7 @@ | ||
// process time < 1 hour and every 5 minutes | ||
if (waitTime < pollingTimeout && (waitTime % 300000 == 0)) { | ||
lib.edge.extendNodeRedLifetime(jobParams.realControllerBaseUrl); | ||
} | ||
let queryResult = await Utils.getJobInfo(context, jobId); | ||
@@ -207,0 +213,0 @@ const redStatuses = ["failed", "aborted", "rejected"]; |
@@ -55,3 +55,3 @@ const lib = require('../lib'); | ||
const pollingTimeMillisecond = 1000; // polling result every 1s | ||
const pollingTimeout = 6 * 60 * 60 * 1000; // timeout in 1h | ||
const pollingTimeout = 1 * 60 * 60 * 1000; // timeout in 1h | ||
@@ -192,3 +192,4 @@ async function onInput(node, msg, config) { | ||
let jobParams = { | ||
jobId: internalJobId, controllerBaseUrl, controllerAPIToken, engineId: task.engineId, categoryName, originalInputUrl: task.inputUrl | ||
jobId: internalJobId, controllerBaseUrl, controllerAPIToken, engineId: task.engineId, categoryName, | ||
originalInputUrl: task.inputUrl, realControllerBaseUrl: config.controllerBaseUrl | ||
}; | ||
@@ -268,2 +269,7 @@ | ||
waitTime += pollingTimeMillisecond; | ||
// process time < 1 hour and every 5 minutes | ||
if (waitTime < pollingTimeout && (waitTime % 300000 == 0)) { | ||
lib.edge.extendNodeRedLifetime(jobParams.realControllerBaseUrl); | ||
} | ||
@@ -729,2 +735,5 @@ jobObj = await getJobStatusInfo(node, jobId, jobStatus, controllerBaseUrl, controllerAPIToken); | ||
node.status({ fill: 'green', shape: 'dot', text: 'aiware.success' }); | ||
if (!msg.payload.aiware) { | ||
msg.payload = {}; | ||
} | ||
if (msg.payload.aiware) { | ||
@@ -731,0 +740,0 @@ Object.assign(msg.payload.aiware, data.aiware); |
@@ -6,2 +6,4 @@ const bodyParser = require('body-parser'); | ||
const Env = require('../share/env'); | ||
const Flow = require('../share/flow'); | ||
const engineId = Env.ENGINE_ID; | ||
@@ -111,2 +113,3 @@ | ||
const msg = { req: { _req: req }, res: wrapper, payload }; | ||
Flow.InitExecution(msg); | ||
node.receive(msg); | ||
@@ -178,4 +181,10 @@ } catch (e) { | ||
} | ||
const flowMetadata = Flow.GetFlowMetadata(msg); | ||
const ctx = lib.gql.NewContext(msg); | ||
if (code === 0 || code === 200) { | ||
if (typeof output === 'object') { | ||
Object.assign(output, flowMetadata); | ||
} | ||
res.done(200, output); | ||
Flow.SaveExecution(ctx, RED, output); | ||
return; | ||
@@ -185,3 +194,7 @@ } | ||
const failureMsg = config.failureMsg; | ||
res.done(200, { failureReason, failureMsg }); | ||
const errOutput = { | ||
failureReason, failureMsg, ...flowMetadata | ||
}; | ||
res.done(200, errOutput); | ||
Flow.SaveExecution(ctx, RED, errOutput); | ||
}); | ||
@@ -265,5 +278,3 @@ } | ||
} | ||
const payload = { aiwareChunk }; | ||
let globalContext = node.context().global; | ||
@@ -303,4 +314,12 @@ let aiwareChunkPayload = aiwareChunk.payload ? aiwareChunk.payload : '{}'; | ||
node.status({ fill: 'green', shape: 'dot', text: 'aiware.success' }); | ||
const done = (status, payload) => { | ||
for (const cb of callbacks) { | ||
cb(status, payload); | ||
} | ||
} | ||
const wrapper = { done, _res: res }; | ||
const msg = { req: { _req: req }, res: wrapper, payload }; | ||
Flow.InitExecution(msg); | ||
// sync by default; set sync=false to make it async | ||
const syncMode = req.body.sync !== 'false'; | ||
const syncMode = req.body.FlowConfigWaitForResult; | ||
if (syncMode) { | ||
@@ -311,13 +330,5 @@ callbacks.push((status, payload) => { | ||
} else { | ||
res.status(200).send(); | ||
res.status(200).json(Flow.GetFlowMetadata(msg)); | ||
} | ||
const done = (status, payload) => { | ||
for (const cb of callbacks) { | ||
cb(status, payload); | ||
} | ||
} | ||
const wrapper = { done, _res: res }; | ||
const msg = { req: { _req: req }, res: wrapper, payload }; | ||
node.receive(msg); | ||
} catch (err) { | ||
@@ -324,0 +335,0 @@ let text = 'Inject tdo failed. See debug panel for details.'; |
@@ -38,3 +38,3 @@ | ||
if (categoryName === simpleResultCategory.SENTIMENT && engineResult.sentiment) { | ||
return engineResult.sentiment.positiveValue; | ||
return engineResult.sentiment.positiveValue.toString(); | ||
} | ||
@@ -41,0 +41,0 @@ if (categoryName === simpleResultCategory.TRANSLATE && engineResult.series) { |
@@ -103,2 +103,7 @@ const { fetch } = require('./http'); | ||
async function extendNodeRedLifetime(controllerBaseUrl) { | ||
const coreToken = process.env.VERITONE_API_TOKEN; | ||
sendToController(controllerBaseUrl, coreToken, "/flowaction/nrcontainer/update?action=keep", "", "GET"); | ||
} | ||
module.exports = { | ||
@@ -108,2 +113,3 @@ GetConfig, | ||
sendToController, | ||
extendNodeRedLifetime | ||
} |
@@ -8,3 +8,3 @@ | ||
if (r.status > 200) { | ||
const message = await releaseEvents.text(); | ||
const message = await r.text(); | ||
throw new Error(message); | ||
@@ -11,0 +11,0 @@ } |
{ | ||
"name": "@veritone/node-red-contrib-aiware", | ||
"version": "2.0.0-alpha.8", | ||
"version": "2.0.0-alpha.9", | ||
"description": "veritone aiware nodes for node-red community", | ||
@@ -19,19 +19,20 @@ "main": "index.js", | ||
"nodes": { | ||
"aiware": "aiware/1-graphql.js", | ||
"aiware-jobs": "aiware/2-my-jobs.js", | ||
"structured-data": "aiware/5-structured-data.js", | ||
"me": "aiware/6-me.js", | ||
"vtn-standard-validate": "aiware/7-vtn-std-validate.js", | ||
"aiware-chart": "aiware/8-aiware-chart.js", | ||
"aiware-common-hidden": "aiware/0-common.js", | ||
"aiware-in": "aiware/9-in-out.js", | ||
"aiware-config": "aiware/10-config.js", | ||
"create-job-rest": "aiware/20-create-job-rest.js", | ||
"create-job-graphql": "aiware/11-create-job-graphql.js", | ||
"vtn-search": "aiware/12-search.js", | ||
"aiware.email": "aiware/13-email.js", | ||
"tdo": "aiware/15-tdo.js", | ||
"sdo": "aiware/16-sdo.js", | ||
"aiware-jobs": "aiware/2-my-jobs.js", | ||
"vtn-search": "aiware/12-search.js", | ||
"aiware.data-transform-csv": "aiware/18-data-transform-csv.js", | ||
"aiware.correlate": "aiware/17-correlation.js", | ||
"aiware.data-transform-csv": "aiware/18-data-transform-csv.js", | ||
"aiware.analysis": "aiware/19-analysis.js", | ||
"create-job-rest": "aiware/20-create-job-rest.js" | ||
"aiware": "aiware/1-graphql.js", | ||
"aiware-config": "aiware/10-config.js", | ||
"me": "aiware/6-me.js", | ||
"vtn-standard-validate": "aiware/7-vtn-std-validate.js", | ||
"aiware-chart": "aiware/8-aiware-chart.js", | ||
"structured-data": "aiware/5-structured-data.js" | ||
} | ||
@@ -38,0 +39,0 @@ }, |
@@ -15,2 +15,3 @@ | ||
const HOST_ID = process.env.HOST_ID; | ||
const ENGINE_BUILD_ID = process.env.BUILD_ID; | ||
@@ -26,2 +27,3 @@ module.exports = { | ||
ENGINE_ID, | ||
ENGINE_BUILD_ID, | ||
CONTROLLER_PROXY_URL, | ||
@@ -28,0 +30,0 @@ VERSION, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1357912
91
28921
11