mirror of
https://github.com/wassname/ray.git
synced 2026-08-09 12:20:09 +08:00
Integration of Webui with Ray (#32)
* Initial integration of webui with ray * Re-organized calling of build-webui in setup.py * Fixed Lint comments on js code * Fixed more lint issues * Fixed various issues * Fixed directory in services.py * Small changes. * Changes to match lint
This commit is contained in:
committed by
Robert Nishihara
parent
7babe0d22f
commit
08707f9408
@@ -0,0 +1,68 @@
|
||||
var jb = require('jbinary');
|
||||
var stream = require('stream');
|
||||
|
||||
var task_argument = {
|
||||
'jBinary.littleEndian': true,
|
||||
is_ref: ['enum', 'int8', [true, false]],
|
||||
padding: ['array', 'int8', 7],
|
||||
reference: [
|
||||
'if', 'is_ref',
|
||||
{object_id: ['array', 'uint8', 20], padding: ['array', 'int8', 4]}
|
||||
],
|
||||
value: [
|
||||
'if_not', 'is_ref',
|
||||
{offset: 'int64', length: 'int64', padding: ['array', 'int8', 8]}
|
||||
]
|
||||
};
|
||||
|
||||
var task_spec_header = {
|
||||
'jBinary.littleEndian': true,
|
||||
function_id: ['array', 'uint8', 20],
|
||||
padding: ['array', 'uint8', 4],
|
||||
num_args: ['int64'],
|
||||
arg_index: ['int64'],
|
||||
num_returns: ['int64'],
|
||||
args_value_size: ['int64'],
|
||||
args_value_offset: ['int64'],
|
||||
arguments: ['array', task_argument, 'num_args']
|
||||
};
|
||||
|
||||
var task_instance = {
|
||||
'jBinary.littleEndian': true,
|
||||
task_iid: ['array', 'uint8', 20],
|
||||
state: 'int32',
|
||||
node_id: ['array', 'uint8', 20],
|
||||
padding: ['array', 'uint8', 4],
|
||||
task_spec_header: ['object', task_spec_header],
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Convert string or byte buffer of an object ID to hex string.
|
||||
function id_to_hex(id) {
|
||||
return new Buffer(id).toString('hex');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parse_task_instance: function(buffer) {
|
||||
var binary = new jb(buffer, task_instance);
|
||||
binary.read('padding');
|
||||
var task_spec = binary.read('task_spec_header');
|
||||
var arguments = [];
|
||||
for (var i = 0; i < task_spec['arguments'].length; i++) {
|
||||
var arg = task_spec['arguments'][i];
|
||||
if (arg['is_ref']) {
|
||||
console.log(arg['reference']['object_id']);
|
||||
arguments.push(id_to_hex(arg['reference']['object_id']));
|
||||
} else {
|
||||
arguments.push("value");
|
||||
}
|
||||
}
|
||||
var state = binary.read('state');
|
||||
var node_id = binary.read('node_id');
|
||||
return {
|
||||
state: state, node_id: id_to_hex(node_id),
|
||||
function_id: id_to_hex(task_spec['function_id']), arguments: arguments
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user