From d24ee8339e6ca137157f084c3f4810bf6157934d Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Fri, 7 Dec 2018 16:05:24 -0600 Subject: [PATCH] Further change the task GUI to have buttons for task ids #154 --- src/sos_notebook/kernel.js | 88 ++++++++++++++++---------------------- src/sos_notebook/kernel.py | 10 ----- src/sos_notebook/magics.py | 34 +++++++++++---- 3 files changed, 62 insertions(+), 70 deletions(-) diff --git a/src/sos_notebook/kernel.js b/src/sos_notebook/kernel.js index 44a517c..073c00d 100644 --- a/src/sos_notebook/kernel.js +++ b/src/sos_notebook/kernel.js @@ -653,7 +653,7 @@ define([ cell.output_area.append_output(data); } return; - } + } // if there is an existing status table, try to retrieve its information // the new data does not have it let timer_text = ''; @@ -672,16 +672,6 @@ define([ } } - let action_class = { - 'pending': 'fa-stop', - 'submitted': 'fa-stop', - 'running': 'fa-stop', - 'completed': 'fa-play', - 'failed': 'fa-play', - 'aborted': 'fa-play', - 'missing': 'fa-question', - } - let status_class = { 'pending': 'fa-square-o', 'submitted': 'fa-spinner', @@ -692,20 +682,15 @@ define([ 'missing': 'fa-question', } - let action_func = { - 'pending': 'kill', - 'submitted': 'kill', - 'running': 'kill', - 'completed': 'resume', - 'failed': 'resume', - 'aborted': 'resume', - 'missing': '', - } - // look for status etc and update them. - let onmouseover = `onmouseover="this.classList='fa fa-2x fa-fw ${action_class[info.status]}'"`; - let onmouseleave = `onmouseleave="this.classList='fa fa-2x fa-fw ${status_class[info.status]}'"`; - let onclick = `onclick="task_action({action: '${action_func[info.status]}', task: '${info.task_id}', queue:'${info.queue}'});"`; + let id_elems = `
${info.task_id}` +
+      `
` + + `` + + `` + + `` + + `` + + `
`; + let tags = info.tags.split(/\s+/g); let tags_elems = '' for (let ti=0; ti < tags.length; ++ti) { @@ -730,13 +715,10 @@ define([
- + -
-
${info.task_id}
-
+
${id_elems}
${tags_elems}
@@ -2023,18 +2005,6 @@ table.task_table { border: 0px; } -.task_tag_actions { - display: none; -} - -.task_tag_actions .fa:hover { - color: blue; -} - -.task_tags:hover .task_tag_actions { - display: flex; - flex-direction: row; -} table.workflow_table i, table.task_table i { @@ -2059,6 +2029,18 @@ td.task_id text-align: left; } +td.task_tags +{ + text-align: left; + max-width: 33em; +} + +td.task_id +{ + text-align: left; +} + +td.task_id span, td.task_tags span { display: inline-flex; } @@ -2071,10 +2053,20 @@ td.task_tags i { margin-right: 0px; } -.task_id pre:hover -{ - cursor: pointer; - text-decoration: underline; +.task_id_actions, +.task_tag_actions { + display: none; +} + +.task_id_actions .fa:hover, +.task_tag_actions .fa:hover { + color: blue; +} + +.task_id:hover .task_id_actions, +.task_tags:hover .task_tag_actions { + display: flex; + flex-direction: row; } td.workflow_index @@ -2103,12 +2095,6 @@ td.task_timer pre } -td.task_tags -{ - text-align: left; - max-width: 33em; -} - td.task_icon { font-size: 0.75em; } diff --git a/src/sos_notebook/kernel.py b/src/sos_notebook/kernel.py index a046417..b203862 100644 --- a/src/sos_notebook/kernel.py +++ b/src/sos_notebook/kernel.py @@ -502,16 +502,6 @@ def handle_frontend_msg(msg): elif k == 'execute-workflow': from .workflow_executor import execute_pending_workflow execute_pending_workflow(v, self) - elif k == 'resume-task': - # kill specified task - from sos.hosts import Host - Host(v[1])._task_engine.resume_task(v[0]) - self.send_frontend_msg('task_status', - { - 'task_id': v[0], - 'queue': v[1], - 'status': 'pending' - }) elif k == 'update-task-status': if not isinstance(v, list): continue diff --git a/src/sos_notebook/magics.py b/src/sos_notebook/magics.py index 409d0d9..204c4e0 100644 --- a/src/sos_notebook/magics.py +++ b/src/sos_notebook/magics.py @@ -1933,20 +1933,25 @@ def get_parser(self): help=argparse.SUPPRESS) status.set_defaults(func=self.status) - resume = subparsers.add_parser('resume', help='task status') - resume.add_argument('tasks', nargs='*', help='''ID of the tasks to be removed. + execute = subparsers.add_parser('execute', help='execute task') + execute.add_argument('tasks', nargs='*', help='''ID of the tasks to be removed. There is no need to specify compelete task IDs because SoS will match specified name with tasks starting with these names. If no task ID is specified, all tasks related to specified workflows (option -w) will be removed.''') - resume.add_argument('-q', '--queue', + execute.add_argument('-q', '--queue', help='''Remove tasks on specified tasks queue or remote host if the tasks . The queue can be defined in global or local sos configuration file, or a file specified by option --config. A host is assumed to be a remote machine with process type if no configuration is found. ''') - resume.set_defaults(func=self.resume) + execute.add_argument('-c', '--config', help='''A configuration file with host + definitions, in case the definitions are not defined in global sos config.yml files.''') + execute.add_argument('-v', dest='verbosity', type=int, choices=range(5), default=2, + help='''Output error (0), warning (1), info (2), debug (3) and trace (4) + information to standard output (default to 2).''') + execute.set_defaults(func=self.execute) - kill = subparsers.add_parser('kill', help='task status') + kill = subparsers.add_parser('kill', help='kill single task or tasks with the same tags') kill.add_argument('tasks', nargs='*', help='''IDs of the tasks that will be killed. There is no need to specify compelete task IDs because SoS will match specified name with tasks starting with these names.''') @@ -1967,7 +1972,7 @@ def get_parser(self): information to standard output (default to 2).''') kill.set_defaults(func=self.kill) - purge = subparsers.add_parser('purge', help='task status') + purge = subparsers.add_parser('purge', help='kill and purge task') purge.add_argument('tasks', nargs='*', help='''ID of the tasks to be removed. There is no need to specify compelete task IDs because SoS will match specified name with tasks starting with these names. If no task ID is specified, @@ -2051,9 +2056,20 @@ def status(self, args): env.logger.warning( f'Unrecognized response "{line}" ({e.__class__.__name__}): {e}') - def resume(self, args): - self.sos_kernel.warn(args) - return + def execute(self, args): + from sos.hosts import Host + host = Host(args.queue) + + for task in args.tasks: + result = host._task_engine.submit_task(task) + self.sos_kernel.send_frontend_msg('task_status', + { + 'update_only': True, + 'queue': args.queue, + 'task_id': task, + 'status': 'pening', + } + ) def kill(self, args): # kill specified task