Skip to content

Commit

Permalink
updated the timeseries wizard for sid remove process #633
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Letter committed Oct 7, 2016
1 parent c50f3dc commit f859934
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 57 deletions.
6 changes: 4 additions & 2 deletions packages/slycat/web/server/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ def abspath(path):
dispatcher.connect("post-cancel-job", "/remotes/cancel-job", slycat.web.server.handlers.post_cancel_job, conditions={ "method": ["POST"] })
dispatcher.connect("get-job-output", "/remotes/get-job-output", slycat.web.server.handlers.get_job_output, conditions={ "method": ["POST"] })
dispatcher.connect("post-agent-function", "/remotes/run-agent-function", slycat.web.server.handlers.run_agent_function, conditions={ "method": ["POST"] })
dispatcher.connect("get-user-config", "/remotes/get-user-config", slycat.web.server.handlers.get_user_config, conditions={ "method": ["POST"] })
dispatcher.connect("set-user-config", "/remotes/set-user-config", slycat.web.server.handlers.set_user_config, conditions={ "method": ["POST"] })

dispatcher.connect("get-user-config", "/remotes/:hostname/get-user-config", slycat.web.server.handlers.get_user_config, conditions={ "method": ["GET"] })

dispatcher.connect("set-user-config", "/remotes/:hostname/set-user-config", slycat.web.server.handlers.set_user_config, conditions={ "method": ["POST"] })

dispatcher.connect("post-uploads", "/uploads", slycat.web.server.handlers.post_uploads, conditions={"method" : ["POST"]})
dispatcher.connect("put-upload-file-part", "/uploads/:uid/files/:fid/parts/:pid", slycat.web.server.handlers.put_upload_file_part, conditions={"method" : ["PUT"]})
Expand Down
9 changes: 4 additions & 5 deletions packages/slycat/web/server/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1849,17 +1849,16 @@ def get_job_output():
with slycat.web.server.remote.get_session(sid) as session:
return session.get_job_output(jid, path)

@cherrypy.tools.json_in(on = True)
@cherrypy.tools.json_out(on = True)
def get_user_config():
sid = cherrypy.request.json["sid"]
def get_user_config(hostname):
sid = get_sid(hostname)
with slycat.web.server.remote.get_session(sid) as session:
return session.get_user_config()

@cherrypy.tools.json_in(on = True)
@cherrypy.tools.json_out(on = True)
def set_user_config():
sid = cherrypy.request.json["sid"]
def set_user_config(hostname):
sid = get_sid(hostname)
config = cherrypy.request.json["config"]
with slycat.web.server.remote.get_session(sid) as session:
return session.set_user_config(config)
Expand Down
9 changes: 7 additions & 2 deletions packages/slycat/web/server/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,17 @@ def agent_functions(fn_id, params):
"uid": uid
}
}

cherrypy.log.error("writing msg: %s" % json.dumps(payload))
stdin.write("%s\n" % json.dumps(payload))
stdin.flush()

response = json.loads(stdout.readline())
cherrypy.log.error("response msg: %s" % response)
if not response["ok"]:
cherrypy.response.headers["x-slycat-message"] = response["message"]
cherrypy.log.error("agent response was not OK msg: %s" % response["message"])
slycat.email.send_error("slycat.web.server.remote.py run_agent_function", "cherrypy.HTTPError 400 %s" % response["message"])
raise cherrypy.HTTPError(400)
raise cherrypy.HTTPError(status=400, message="run_agent_function response was not ok")

# parses out the job ID
arr = [int(s) for s in response["output"].split() if s.isdigit()]
Expand Down Expand Up @@ -898,14 +900,17 @@ def create_session(hostname, username, password, agent):

cherrypy.log.error("Starting agent executable for %s@%s with command: %s" % (username, hostname, remote_hosts[hostname]["agent"]["command"]))
stdin, stdout, stderr = ssh.exec_command(remote_hosts[hostname]["agent"]["command"])
cherrypy.log.error("Started agent")
# Handle catastrophic startup failures (the agent process failed to start).
try:
startup = json.loads(stdout.readline())
except Exception as e:
cherrypy.log.error("500 agent startup failed for host %s: %s." % (hostname, str(e)))
slycat.email.send_error("slycat.web.server.remote.py create_session", "cherrypy.HTTPError 500 agent startup failed for host %s: %s." % (hostname, str(e)))
raise cherrypy.HTTPError("500 Agent startup failed: %s" % str(e))
# Handle clean startup failures (the agent process started, but reported an error).
if not startup["ok"]:
cherrypy.log.error("500 agent startup failed for host %s: %s." % (hostname, startup["message"]))
slycat.email.send_error("slycat.web.server.remote.py create_session", "cherrypy.HTTPError 500 agent startup failed for host %s: %s." % (hostname, startup["message"]))
raise cherrypy.HTTPError("500 Agent startup failed: %s" % startup["message"])
agent = (stdin, stdout, stderr)
Expand Down
56 changes: 35 additions & 21 deletions web-server/js/slycat-job-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define('slycat-job-checker', ['knockout', 'knockout-mapping', 'slycat-server-roo
ko.components.register('slycat-job-checker', {
viewModel: function(params) {
var vm = this;
vm.remote = mapping.fromJS({ hostname: null, username: null, password: null, status: null, status_type: null, enable: true, focus: false, sid: null });
vm.remote = mapping.fromJS({ hostname: null, username: null, password: null, status: null, status_type: null, enable: true, focus: false, sid: null, session_exists: false });
vm.remote.focus.extend({ notify: 'always' });
vm.jid = ko.observable(-1);
vm.output = ko.observable('Output for the current job will be posted here...');
Expand All @@ -13,25 +13,39 @@ define('slycat-job-checker', ['knockout', 'knockout-mapping', 'slycat-server-roo
vm.remote.enable(false);
vm.remote.status_type('info');
vm.remote.status('Connecting...');

client.post_remotes({
hostname: vm.remote.hostname(),
username: vm.remote.username(),
password: vm.remote.password(),
success: function(sid) {
vm.remote.sid(sid);
$('#slycat-job-checker-connect-modal').modal('hide');
$('#slycat-job-checker-cancel').removeAttr('disabled');
vm.checkjob();
},
error: function(request, status, reason_phrase) {
$('#slycat-job-checker-cancel').attr('disabled');
vm.remote.enable(true);
vm.remote.status_type('danger');
vm.remote.status(reason_phrase);
vm.remote.focus('password');
}
});
if(vm.remote.session_exists())
{
vm.remote.enable(true);
vm.remote.status_type(null);
vm.remote.status(null);
$('#slycat-job-checker-connect-modal').modal('hide');
$('#slycat-job-checker-cancel').removeAttr('disabled');
vm.checkjob();
}
else{
client.post_remotes({
hostname: vm.remote.hostname(),
username: vm.remote.username(),
password: vm.remote.password(),
success: function(sid) {
vm.remote.session_exists(true);
vm.remote.sid(sid);
vm.remote.enable(true);
vm.remote.status_type(null);
vm.remote.status(null);
$('#slycat-job-checker-connect-modal').modal('hide');
$('#slycat-job-checker-cancel').removeAttr('disabled');
vm.checkjob();
},
error: function(request, status, reason_phrase) {
$('#slycat-job-checker-cancel').attr('disabled');
vm.remote.enable(true);
vm.remote.status_type('danger');
vm.remote.status(reason_phrase);
vm.remote.focus('password');
}
});
}
};

vm.cancel = function() {
Expand Down Expand Up @@ -61,7 +75,7 @@ define('slycat-job-checker', ['knockout', 'knockout-mapping', 'slycat-server-roo
};

var routine = function(jid) {
client.post_checkjob({
client.post_checkjob({
sid: vm.remote.sid(),
jid: vm.jid(),
success: function(results) {
Expand Down
7 changes: 2 additions & 5 deletions web-server/js/slycat-web-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -944,11 +944,8 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se
module.get_user_config = function(params) {
$.ajax({
contentType: 'application/json',
data: JSON.stringify({
sid: params.sid
}),
type: 'POST',
url: server_root + 'remotes/get-user-config',
type: 'GET',
url: server_root + 'remotes/'+params.hostname+'/get-user-config',
success: function(result) {
if (params.success)
params.success(result);
Expand Down
82 changes: 60 additions & 22 deletions web-server/plugins/slycat-timeseries-model/wizard-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ define(['slycat-server-root', 'slycat-web-client', 'slycat-dialog', 'slycat-mark
component.project = params.projects()[0];
component.model = mapping.fromJS({ _id: null, name: 'New Timeseries Model', description: '', marking: markings.preselected() });
component.timeseries_type = ko.observable('csv');
component.remote = mapping.fromJS({hostname: null, username: null, password: null, status: null, status_type: null, enable: ko.computed(function(){return true;}), focus: false, sid: null, session_exists: false});
component.remote = mapping.fromJS({hostname: null, username: null, password: null, status: null, status_type: null, enable: true, focus: false, sid: null, session_exists: false});
component.remote.focus.extend({notify: 'always'});
component.browser = mapping.fromJS({path:null, selection: []});
component.to_hdf5 = ko.observable(true);
Expand All @@ -17,7 +17,7 @@ define(['slycat-server-root', 'slycat-web-client', 'slycat-dialog', 'slycat-mark
component.inputs_file_delimiter = ko.observable(',');
component.xyce_timeseries_file = ko.observable('');
component.timeseries_name = ko.observable('');
component.cluster_sample_count = ko.observable(500);
component.cluster_sample_count = ko.observable(500);
component.cluster_sample_type = ko.observableArray(['uniform-paa', 'uniform-pla']);
component.cluster_type = ko.observableArray(['average', 'single', 'complete', 'weighted']);
component.cluster_metric = ko.observableArray(['euclidean']);
Expand Down Expand Up @@ -73,9 +73,6 @@ define(['slycat-server-root', 'slycat-web-client', 'slycat-dialog', 'slycat-mark
component.create_model();

component.cancel = function() {
if (component.remote.sid())
client.delete_remote({ sid: component.remote.sid() });

if (component.model._id())
client.delete_model({ mid: component.model._id() });
};
Expand All @@ -87,16 +84,13 @@ define(['slycat-server-root', 'slycat-web-client', 'slycat-dialog', 'slycat-mark
component.connect = function() {
component.remote.status_type('info');
component.remote.status('Connecting...');
client.post_remotes({
hostname: component.remote.hostname(),
username: component.remote.username(),
password: component.remote.password(),
success: function(sid) {
$('.modal-dialog').addClass('modal-lg');
component.remote.sid(sid);

client.get_user_config({
sid: component.remote.sid(),
if(component.remote.session_exists())
{
component.remote.enable(true);
component.remote.status_type(null);
component.remote.status(null);
client.get_user_config({
hostname: component.remote.hostname(),
success: function(response) {
if (response.errors.length > 0) {
component.tab(2);
Expand Down Expand Up @@ -125,13 +119,57 @@ define(['slycat-server-root', 'slycat-web-client', 'slycat-dialog', 'slycat-mark
component.tab(2);
}
});
},
error: function(request, status, reason_phrase) {
component.remote.status_type('danger');
component.remote.status(reason_phrase);
component.remote.focus('password');
}
});
}else{
client.post_remotes({
hostname: component.remote.hostname(),
username: component.remote.username(),
password: component.remote.password(),
success: function(sid) {
$('.modal-dialog').addClass('modal-lg');
component.remote.session_exists(true);
component.remote.sid(sid);
component.remote.enable(true);
component.remote.status_type(null);
component.remote.status(null);
client.get_user_config({
hostname: component.remote.hostname(),
success: function(response) {
if (response.errors.length > 0) {
component.tab(2);
return void 0;
}

if (response.config['timeseries-wizard']) {
response.config['timeseries-wizard']['persistent-output'] ? component.output_directory(response.config['timeseries-wizard']['persistent-output']) : null;
response.config['timeseries-wizard']['timeseries-name'] ? component.timeseries_name(response.config['timeseries-wizard']['timeseries-name']) : null;
response.config['timeseries-wizard']['id-column'] ? component.id_column(response.config['timeseries-wizard']['id-column']) : null;
response.config['timeseries-wizard']['inputs-file-delimiter'] ? component.inputs_file_delimiter(response.config['timeseries-wizard']['inputs-file-delimiter']) : null;
}

if (response.config.slurm) {
response.config.slurm.wcid ? component.wckey(response.config.slurm.wcid) : null;
response.config.slurm.partition ? component.partition(response.config.slurm.partition) : null;
response.config.slurm.workdir ? component.workdir(response.config.slurm.workdir) : null;
response.config.slurm.nnodes ? component.nnodes(response.config.slurm.nnodes) : null;
response.config.slurm['ntasks-per-node'] ? component.ntasks_per_node(response.config.slurm['ntasks-per-node']) : null;
response.config.slurm['time-hours'] ? component.time_hours(response.config.slurm['time-hours']) : null;
response.config.slurm['time-minutes'] ? component.time_minutes(response.config.slurm['time-minutes']) : null;
response.config.slurm['time-seconds'] ? component.time_seconds(response.config.slurm['time-seconds']) : null;
}

component.user_config = response.config;
component.tab(2);
}
});
},
error: function(request, status, reason_phrase) {
component.remote.enable(true);
component.remote.status_type('danger');
component.remote.status(reason_phrase);
component.remote.focus('password');
}
})
};
};

component.select_input_file = function() {
Expand Down

0 comments on commit f859934

Please sign in to comment.