Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

Accelerate the speed of parsing blueprint #143

Open
@lin344902118

Description

@lin344902118

dsl_parser/framework/parser.py between line 207 to 242
def _calculate_element_graph(self):
self.element_graph = nx.DiGraph(self._element_tree)
for element_type, _elements in self.element_type_to_elements.items():
requires = element_type.requires
for requirement, requirement_values in requires.items():
requirement_values = [
Requirement(r) if isinstance(r, basestring)
else r for r in requirement_values]
if requirement == 'inputs':
continue
if requirement == 'self':
requirement = element_type
dependencies = self.element_type_to_elements.get(
requirement, [])
predicates = [r.predicate for r in requirement_values
if r.predicate is not None]

            if not predicates:
                dep = _BatchDependency(element_type, requirement)
                for dependency in dependencies:
                    self.element_graph.add_edge(dep, dependency)
                for element in _elements:
                    self.element_graph.add_edge(element, dep)
                continue

            for dependency in dependencies:
                for element in _elements:
                    add_dependency = all([
                        predicate(element, dependency)
                        for predicate in predicates])
                    if add_dependency:
                        self.element_graph.add_edge(element, dependency)
    # we reverse the graph because only netorkx 1.9.1 has the reverse
    # flag in the topological sort function, it is only used by it
    # so this should be good
    self.element_graph.reverse(copy=False)

I think can create a map to cache the element which is most used. This can accelerate the speed of parsing blueprint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions