def run_task_manifest_on_cluster(path): """ Run the Task on the queue (of possible) :param path: :return: """ output_dir = os.path.dirname(path) os.chdir(output_dir) rt = RunnableTask.from_manifest_json(path) # this needs to be updated to have explicit paths to stderr, stdout rcode, err_msg, run_time = run_task_on_cluster(rt, path, output_dir, True) state = TaskStates.from_int(rcode) return state, err_msg, run_time
def run_task_manifest(path): output_dir = os.path.dirname(path) os.chdir(output_dir) stderr = os.path.join(output_dir, 'stderr') stdout = os.path.join(output_dir, 'stdout') try: rt = RunnableTask.from_manifest_json(path) except KeyError: emsg = "Unable to deserialize RunnableTask from manifest {p}".format(p=path) log.error(emsg) raise # blocking call rcode, err_msg, run_time = run_task(rt, output_dir, stdout, stderr, True) state = TaskStates.from_int(rcode) return state, err_msg, run_time
def to_binding_graph_summary(bg): """ General func for getting a summary of BindingGraph instance """ header = "Binding Graph Status Summary" _n = 80 sp = "-" * _n ssp = "*" * _n outs = [] _add = outs.append _add_sp = functools.partial(_add, sp) _add_ssp = functools.partial(_add, ssp) _add_ssp() _add(header) _add_sp() _add("Workflow complete? {c}".format(c=bg.is_workflow_complete())) tn_states = {s: bg.get_tasks_by_state(s) for s in TaskStates.ALL_STATES()} tn_s = " ".join([":".join([k, str(v)]) for k, v in tn_states.iteritems()]) _add_sp() _add("Task Summary {n} tasks ({s})".format(n=len(bg.task_nodes()), s=str(tn_s))) _add_sp() sorted_nodes = nx.topological_sort(bg) _add(" ".join(["resolved inputs".ljust(20), "resolved outputs".ljust(20), "state".ljust(12), "NodeType".ljust(30), "N inputs".ljust(12), "N outputs".ljust(12), "run time".ljust(12), "Id".ljust(60), ])) _add_sp() for tnode in sorted_nodes: if isinstance(tnode, VALID_TASK_NODE_CLASSES): state = bg.node[tnode]['state'] _is_resolved = lambda it: all(bg.node[n][ConstantsNodes.FILE_ATTR_IS_RESOLVED] for n in it) inputs_resolved = _is_resolved(bg.predecessors(tnode)) outputs_resolved = _is_resolved(bg.successors(tnode)) ninputs = len(bg.predecessors(tnode)) noutputs = len(bg.successors(tnode)) run_time = bg.node[tnode]['run_time'] s = str(inputs_resolved).ljust(20), str(outputs_resolved).ljust(20), state.ljust(12), tnode.__class__.__name__.ljust(30), str(ninputs).ljust(12), str(noutputs).ljust(12), str(run_time).ljust(12), str(tnode).ljust(60) _add(" ".join(s)) # File-esque summary def _to_summary(fnode_): # print type(fnode_), fnode_ s = bg.node[fnode_][ConstantsNodes.FILE_ATTR_IS_RESOLVED] p = bg.node[fnode_][ConstantsNodes.FILE_ATTR_PATH] if p is None: ppath = str(None) else: ppath = '... ' + str(p)[-35:] _add(" ".join([str(s).ljust(10), fnode.__class__.__name__.ljust(18), ppath.ljust(40), str(fnode)])) _add("") _add_sp() _add("File Summary ({n}) files".format(n=len(bg.file_nodes()))) _add_sp() _add(" ".join(["resolved".ljust(10), "NodeType".ljust(18), "Path".ljust(40), "Id"])) _add_sp() for fnode in sorted_nodes: if isinstance(fnode, VALID_FILE_NODE_CLASSES): _to_summary(fnode) _add("") _add_sp() _add("Entry Point Node Summary ({n})".format(n=len(bg.entry_point_nodes()))) _add_sp() _add(" ".join(["resolved".ljust(10), "NodeType".ljust(18), "Path".ljust(40), "Id"])) _add_sp() for x in bg.entry_point_nodes(): _to_summary(x) _add_sp() return "\n".join(outs)