From ce4fd8c8de707a6719b22e0bf0cffc8d71b21d4b Mon Sep 17 00:00:00 2001 From: Dmitry Shulyak Date: Wed, 15 Jul 2015 11:49:44 +0300 Subject: [PATCH] Prepare orchestration plan based on precedence scheduling Use transitive reduction for graph output, to reduce number of edges, and keep graph clean --- solar/solar/cli/orch.py | 7 +++++-- solar/solar/system_log/change.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/solar/solar/cli/orch.py b/solar/solar/cli/orch.py index e809c403..b17a8a33 100644 --- a/solar/solar/cli/orch.py +++ b/solar/solar/cli/orch.py @@ -105,8 +105,11 @@ def dg(uid): for n in plan: color = colors[plan.node[n]['status']] plan.node[n]['color'] = color - nx.write_dot(plan, 'graph.dot') - subprocess.call(['dot', '-Tpng', 'graph.dot', '-o', 'graph.png']) + nx.write_dot(plan, '{name}.dot'.format(name=plan.graph['name'])) + subprocess.call( + 'tred {name}.dot | dot -Tpng -o {name}.png'.format(name=plan.graph['name']), + shell=True) + click.echo('Created {name}.png'.format(name=plan.graph['name'])) @orchestration.command() diff --git a/solar/solar/system_log/change.py b/solar/solar/system_log/change.py index e64d8e79..16588c46 100644 --- a/solar/solar/system_log/change.py +++ b/solar/solar/system_log/change.py @@ -82,7 +82,7 @@ def stage_changes(): return _stage_changes(staged, conn_graph, commited, log) -def send_to_orchestration(execute=False): +def send_to_orchestration(): conn_graph = signals.detailed_connection_graph() dg = nx.DiGraph() staged = {r.name: r.args_show() @@ -100,8 +100,9 @@ def send_to_orchestration(execute=False): res_uid, status='PENDING', errmsg=None, **parameters(res_uid, guess_action(commited_data, staged_data))) + for pred in conn_graph.predecessors(res_uid): + dg.add_edge(pred, res_uid) - dg.add_path(nx.topological_sort(conn_graph)) # what it should be? dg.graph['name'] = 'system_log' return graph.create_plan_from_graph(dg)