Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Replace graph code in tracker (#3579)
Browse files Browse the repository at this point in the history
  • Loading branch information
Code0x58 committed Jul 26, 2020
1 parent cfd7c41 commit a3e9ae9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 138 deletions.
1 change: 1 addition & 0 deletions heron/tools/tracker/src/python/BUILD
Expand Up @@ -10,6 +10,7 @@ pex_library(
"protobuf==3.8.0",
"tornado==4.0.2",
"javaobj-py3==0.4.1",
"networkx==2.4",
],
deps = [
"//heron/common/src/python:common-py",
Expand Down
133 changes: 0 additions & 133 deletions heron/tools/tracker/src/python/graph.py

This file was deleted.

41 changes: 36 additions & 5 deletions heron/tools/tracker/src/python/handlers/logicalplanhandler.py
Expand Up @@ -18,15 +18,48 @@
# specific language governing permissions and limitations
# under the License.

""" logicalplanhandler.py """
"""
Logical plan objects have the shape:
{
'spouts': {
spout_name: {
'outputs': [{'stream_name': stream_name}],
}
},
'bolts': {
bolt_name: {
'outputs': [{'stream_name': stream_name}],
'inputs': [{
'stream_name': stream_name,
'component_name': component_name,
'grouping': grouping_type,
}]
}
}
}
"""
import traceback
import tornado.gen
import tornado.web

from heron.common.src.python.utils.log import Log
from heron.tools.tracker.src.python import graph
from heron.tools.tracker.src.python.handlers import BaseHandler

import networkx


def topology_stages(logical_plan):
"""Return the number of stages in a logical plan."""
graph = networkx.DiGraph(
(input_info["component_name"], bolt_name)
for bolt_name, bolt_info in logical_plan.get("bolts", {}).items()
for input_info in bolt_info["inputs"]
)
# this is is the same as "diameter" if treating the topology as an undirected graph
return networkx.dag_longest_path_length(graph)



class LogicalPlanHandler(BaseHandler):
"""
Expand Down Expand Up @@ -75,10 +108,8 @@ def get(self):
outputs=value["outputs"]
)

diameter = graph.TopologyDAG(lplan).diameter()

result = dict(
stages=diameter,
stages=topology_stages(lplan),
spouts=spouts_map,
bolts=bolts_map
)
Expand Down

0 comments on commit a3e9ae9

Please sign in to comment.