In this tutorial, we will show you how to use Neocortix Cloud Services Scalable Compute to run a distributed batch job using JavaScript and node.js.
First, please follow the steps in the tutorial
Setting Up For Batch Jobs.
After completion of the initial setup, you will have a directory with examples,
~/ncsexamples
.
In the subdirectory
~/ncsexamples/batchMode
you will find the
runBatchJavascript.py command.
This script will create a set of instances running on mobile devices, one instance for each frame to be computed (5 in
the default example provided).
startFrame = 1,
endFrame = 5,
It will command the instances to receive the JavaScript file
helloFrame.js
, then
run it:
workerScriptPath = 'helloFrame.js'
def frameCmd( self, frameNum ):
jsFileName = os.path.basename( self.workerScriptPath )
cmd = 'node %s %d > %s' % \
(jsFileName, frameNum, self.frameOutFileName(frameNum))
return cmd
The output is a text file
frame_<n>.out
containing
"Hello World! From frameNum = n"
These output files will be sent back to the master host, and the master will then terminate the instances.