Skip to content

Commit

Permalink
move show_dag method to sepate plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieucan committed Dec 5, 2017
1 parent e57df2e commit ca2f62d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
11 changes: 0 additions & 11 deletions lb/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,6 @@ def create_edge(block_from, value_from, block_dest, value_dest):
self.vertices = vertices
self.entry_points = entry_points

def show_dag(self):
for v in self.vertices.values():
print(v.fields['name'])
print(' from:')
for prev in v.prev_vertices:
print(' {} -> {}'.format(prev.block_from.fields['name'], prev.value_from))
print(' to:')
for to in v.next_vertices:
print(' {} -> {}'.format(to.block_dest.fields['name'], to.value_dest))
print('____________________')

def _check_yaml(self):
"""
Checks that the YAML file is correctly typed.
Expand Down
32 changes: 32 additions & 0 deletions lb/plugins/show_dag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2017 The Lambda-blocks developers. See AUTHORS for details.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
This plugin allows for a very basic representation of the graph,
showing for each vertice its inner and outer links.
"""

from lb.plugins_manager import before_graph_execution

@before_graph_execution
def show_dag(vertices, entry_points):
for v in vertices.values():
print(v.fields['name'])
print(' from:')
for prev in v.prev_vertices:
print(' {} -> {}'.format(prev.block_from.fields['name'], prev.value_from))
print(' to:')
for to in v.next_vertices:
print(' {} -> {}'.format(to.block_dest.fields['name'], to.value_dest))
print('____________________')

0 comments on commit ca2f62d

Please sign in to comment.