本文整理汇总了Python中sequencer.dgm.model.RuleSet.get_depgraph方法的典型用法代码示例。如果您正苦于以下问题:Python RuleSet.get_depgraph方法的具体用法?Python RuleSet.get_depgraph怎么用?Python RuleSet.get_depgraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sequencer.dgm.model.RuleSet
的用法示例。
在下文中一共展示了RuleSet.get_depgraph方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple_nodeps_ta_tb_a_b
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_simple_nodeps_ta_tb_a_b(self):
"""
RuleSet: #ta, #tb,
Components: a#ta, b#tb
Expecting: a#ta, b#tb
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Ra",
action="Action for a",
types=["[email protected]"]))
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Rb",
action="Action for b",
types=["[email protected]"]))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("a#[email protected]"),
Component("b#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 2)
self.assertTrue("a#[email protected]" in components)
self.assertTrue("b#[email protected]" in components)
self.assertTrue(depgraph.dag is not None)
self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
self.assertTrue("Ra" in components["a#[email protected]"].actions)
self.assertEquals("Action for a", components["a#[email protected]"].actions["Ra"])
self.assertTrue("Rb" in components["b#[email protected]"].actions)
self.assertEquals("Action for b", components["b#[email protected]"].actions["Rb"])
self.assertNoEdgeBetween(depgraph.dag, "a#[email protected]", "b#[email protected]")
示例2: test_a_nop_b
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_a_nop_b(self):
"""
Check that action NONE are understood correctly.
RuleSet: #root, #dep (filter = ALL),
a#root -> b#dep (a.action=NONE)
Expecting: a#root -> b#dep
But a#root has no attribute in the xml graph.
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Root",
types=["[email protected]"],
action=NONE,
depsfinder=tools.getMockDepsFinderCmd(["b#[email protected]"]),
dependson=['Dep']))
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Dep",
types=["[email protected]"],
action="Dep Action"))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("a#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 2)
self.assertTrue("a#[email protected]" in components)
self.assertTrue("b#[email protected]" in components)
self.assertTrue(depgraph.dag is not None)
self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
self.assertFalse("Root" in components["a#[email protected]"].actions, components)
self.assertTrue("Dep" in components["b#[email protected]"].actions)
attributes = depgraph.dag.node_attributes("a#[email protected]")
self.assertEquals(len(attributes), 0)
attributes = depgraph.dag.node_attributes("b#[email protected]")
self.assertEquals(len(attributes), 1)
示例3: test_simple_deps_ta_tb_b_a_nodepsfinder
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_simple_deps_ta_tb_b_a_nodepsfinder(self):
"""
RuleSet: #ta->#tb,
Components: b#tb, a#ta (reverse than test_simple_deps_ta_tb_a_b_nodepsfinder)
Expecting: a#ta, b#tb (order does not count)
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Ra",
action="Action for a",
types=["[email protected]"],
dependson=["Rb"]))
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Rb",
action="Action for b",
types=["[email protected]"]))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("b#[email protected]"),
Component("a#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 2)
self.assertTrue("a#[email protected]" in components)
self.assertTrue("b#[email protected]" in components)
self.assertTrue(depgraph.dag is not None)
self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
self.assertNoEdgeBetween(depgraph.dag, "a#[email protected]", "b#[email protected]")
示例4: test_multiple_actions_cycle
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_multiple_actions_cycle(self):
"""
Check that a given component can contain multiple actions.
RuleSet: R1:#ta, R2:#ta->R1
Components: a#ta (R1 depsfinder returns itself: a#ta)
Expecting: a#ta with 2 actions and a cycle.
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="R1",
action="Action for a",
types=["[email protected]"]))
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="R2",
action="Action for a",
types=["[email protected]"],
depsfinder=tools.getMockDepsFinderCmd(["a#[email protected]"]),
dependson=["R1"]))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("a#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 1, "Map: %s" % components)
self.assertTrue("a#[email protected]" in components)
self.assertTrue("R1" in components["a#[email protected]"].actions)
self.assertTrue("R2" in components["a#[email protected]"].actions)
self.assertEquals(len(components["a#[email protected]"].actions), 2)
self.assertEquals(len(depgraph.dag.node_attributes("a#[email protected]")), 2)
self.assertTrue(depgraph.dag.has_edge(("a#[email protected]", "a#[email protected]")))
示例5: test_filtered_components
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_filtered_components(self):
"""
Check that filter other than NONE and ALL works as expected.
RuleSet: #root (filter = in.*)
Components: in#root in_foo#root out#root
Expecting: in#root, in_foo#root out#root
(out#root has no action, it has been filtered out)
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="R",
types=["[email protected]"],
action="Root Action",
# WARNING: space is important here!!
filter="%name =~ in.*"))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("in#[email protected]"),
Component("in_foo#[email protected]"),
Component("out#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 3)
self.assertTrue("in#[email protected]" in components)
self.assertTrue("in_foo#[email protected]" in components)
self.assertTrue("out#[email protected]" in components)
self.assertTrue(depgraph.dag is not None)
self.assertTrue(depgraph.dag.has_node("in#[email protected]"))
self.assertTrue(depgraph.dag.has_node("in_foo#[email protected]"))
self.assertTrue(depgraph.dag.has_node("out#[email protected]"))
self.assertTrue("R" in components["in#[email protected]"].actions)
self.assertEquals("Root Action", components["in#[email protected]"].actions["R"])
self.assertTrue("R" in components["in_foo#[email protected]"].actions)
self.assertEquals("Root Action", components["in_foo#[email protected]"].actions["R"])
self.assertTrue("Root Action" not in components["out#[email protected]"].actions)
示例6: test_filtered_none_components_deps
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_filtered_none_components_deps(self):
"""
Check that dependencies are not in the graph when they are filtered out.
RuleSet: #root -> #deps (filter = NONE)
Components: a#root
Component a provides a depfinder that returns b#deps
Expecting: a#root, b#deps (b#deps has no action, it has been filtered out)
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="R-root",
action="Root Action",
types=["[email protected]"],
depsfinder=tools.getMockDepsFinderCmd(["b#[email protected]"]),
dependson=["R-Deps"]))
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="R-Deps",
action="Deps Action",
types=["[email protected]"],
filter=NONE))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("a#ro[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 2)
self.assertTrue(depgraph.dag is not None)
self.assertTrue("a#[email protected]" in components)
self.assertTrue("R-root" in components["a#[email protected]"].actions)
self.assertEquals("Root Action", components["a#[email protected]"].actions["R-root"])
self.assertTrue("b#[email protected]" in components)
self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
self.assertTrue("Deps Action" not in components["b#[email protected]"].actions)
示例7: test_no_root_with_self_cycle_in_graph_rules
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_no_root_with_self_cycle_in_graph_rules(self):
"""
There are no match in the given component list.
RuleSet: #ta->#ta
Components: c#tc
Expecting: c#tc.
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Ra",
action="Action for a",
types=["[email protected]"],
depsfinder=tools.getMockDepsFinderCmd(["foo#[email protected]"]),
dependson=["Ra"]))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("c#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 1, "Map: %s" % components)
self.assertTrue("c#[email protected]" in components)
self.assertTrue(depgraph.dag is not None)
self.assertEquals(len(depgraph.dag.nodes()), 1)
self.assertTrue(depgraph.dag.has_node("c#[email protected]"))
示例8: test_multiple_actions_nodeps
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_multiple_actions_nodeps(self):
"""
Check that a given component can contain multiple actions.
RuleSet: #ta, #ta
Components: a#ta
Expecting: a#ta with 2 actions.
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="R1",
action="Action for a",
types=["[email protected]"]))
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="R2",
action="Action for a",
types=["[email protected]"]))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("a#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 1, "Map: %s" % components)
self.assertTrue("a#[email protected]" in components)
self.assertTrue("R1" in components["a#[email protected]"].actions)
self.assertTrue("R2" in components["a#[email protected]"].actions)
self.assertEquals(len(components["a#[email protected]"].actions), 2)
self.assertEquals(len(depgraph.dag.node_attributes("a#[email protected]")), 2)
示例9: test_root_in_simple_cycle
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_root_in_simple_cycle(self):
"""
The root is in a simple cycle.
RuleSet: #ta->#tb, #tb->#tc, #tc->#ta (triangle)
Components: b#tb
Expecting: b#tb
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Ra",
action="Action for a",
types=["[email protected]"],
dependson=["Rb"]))
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Rb",
action="Action for b",
types=["[email protected]"],
dependson=["Rc"]))
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Rc",
action="Action for c",
dependson=["Ra"],
types=["[email protected]"]))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("b#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 1, "Map: %s" % components)
self.assertTrue("b#[email protected]" in components)
self.assertTrue(depgraph.dag is not None)
self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
示例10: test_simple_deps_ta_tb_b_a_withdepsfinder
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_simple_deps_ta_tb_b_a_withdepsfinder(self):
"""
RuleSet: #ta->#tb,
Components: b#tb, a#ta (reverse)
Component a does provide a depfinder that returns b#tb
Expecting: a#ta -> b#tb
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Ra",
action="Action for a",
types=["[email protected]"],
depsfinder=tools.getMockDepsFinderCmd(["b#[email protected]"]),
dependson=["Rb"]))
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="Rb",
action="Action for b",
types=["[email protected]"]))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("b#[email protected]"),
Component("a#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 2, "Map: %s" % components)
self.assertTrue("a#[email protected]" in components)
self.assertTrue("b#[email protected]" in components)
self.assertTrue(depgraph.dag is not None)
self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
self.assertTrue(depgraph.dag.has_edge(("a#[email protected]", "b#[email protected]")))
示例11: test_only_root_rules_applied
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_only_root_rules_applied(self):
"""
Check that a rule is applied on a parameter only if it is a
potential root.
RuleSet: #t(action1)->#t(action2)
Components: a#t, b#t (a#t depsfinder returns b#t)
Expecting: a#t contains only 1 action while b#t contains two actions.
"""
rules = set()
rules.add(
tools.create_rule(
ruleset=self.__class__.__name__,
name="Ra",
action="Action for a",
types=["[email protected]"],
filter="%name =~ a",
depsfinder=tools.getMockDepsFinderCmd(["b#[email protected]"]),
dependson=["Rdep"],
)
)
rules.add(
tools.create_rule(
ruleset=self.__class__.__name__,
name="Rb",
action="Action for b",
types=["[email protected]"],
filter="%name =~ b",
dependson=["Rdep"],
)
)
rules.add(
tools.create_rule(ruleset=self.__class__.__name__, name="Rdep", action="Action for dep", types=["[email protected]"])
)
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("a#[email protected]"), Component("b#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 2, "Map: %s" % components)
self.assertTrue("a#[email protected]" in components)
self.assertTrue("b#[email protected]" in components)
self.assertEquals(len(components["a#[email protected]"].actions), 1)
self.assertTrue("Ra" in components["a#t[email protected]"].actions)
self.assertEquals(len(components["b#[email protected]"].actions), 2)
self.assertTrue("Rb" in components["b#[email protected]"].actions)
self.assertTrue("Rdep" in components["b#[email protected]"].actions)
self.assertEquals(len(depgraph.dag.node_attributes("a#[email protected]")), 1)
self.assertEquals(len(depgraph.dag.node_attributes("b#[email protected]")), 2)
示例12: test_unknown_component
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_unknown_component(self):
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="test_unknown_component",
types=["[email protected]"]))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("foo#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 1)
self.assertTrue("foo#[email protected]" in components)
self.assertEquals(len(components["foo#[email protected]"].actions), 0)
self.assertTrue(depgraph.dag is not None)
self.assertTrue(depgraph.dag.has_node("foo#[email protected]"))
示例13: test_force_options
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_force_options(self):
"""
Check that force flag is generated correctly.
"""
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="R",
types=["[email protected]"],
action="Test Action"))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("in#[email protected]")], force_rule=['R'])
components = depgraph.components_map
attributes = depgraph.dag.node_attributes("in#[email protected]")
self.assertEquals('R?force=always', attributes[0][0])
self.assertTrue("R?force=always" in components["in#[email protected]"].actions)
self.assertEquals("Test Action", components["in#[email protected]"].actions["R?force=always"])
depgraph = ruleset.get_depgraph([Component("in#[email protected]")],
force_rule=[NOT_FORCE_OP + 'R'])
components = depgraph.components_map
attributes = depgraph.dag.node_attributes("in#[email protected]")
self.assertEquals('R?force=never', attributes[0][0])
self.assertTrue("R?force=never" in components["in#[email protected]"].actions)
self.assertEquals("Test Action", components["in#[email protected]"].actions["R?force=never"])
示例14: test_filtered_all_components
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_filtered_all_components(self):
rules = set()
rules.add(tools.create_rule(ruleset=self.__class__.__name__,
name="test_filtered_all_components",
types=["[email protected]"],
filter=ALL))
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("in#[email protected]"),
Component("out#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 2)
self.assertTrue(depgraph.dag is not None)
self.assertTrue("in#[email protected]" in components)
self.assertTrue("out#[email protected]" in components)
self.assertTrue(depgraph.dag.has_node("in#[email protected]"))
self.assertTrue(depgraph.dag.has_node("out#[email protected]"))
示例15: test_simple_noroot
# 需要导入模块: from sequencer.dgm.model import RuleSet [as 别名]
# 或者: from sequencer.dgm.model.RuleSet import get_depgraph [as 别名]
def test_simple_noroot(self):
"""
There are no root in the given component list.
RuleSet: #ta->#tb, #ta->#tc, #tb->#tc (triangle)
Components: b#tb, a#ta (each depsfinder returns c#tc)
Expecting: a#ta -> b#tb, a#ta -> c#tc
"""
rules = set()
rules.add(
tools.create_rule(
ruleset=self.__class__.__name__,
name="Ra",
action="Action for a",
types=["[email protected]"],
depsfinder=tools.getMockDepsFinderCmd(["c#[email protected]"]),
dependson=["Rb", "Rc"],
)
)
rules.add(
tools.create_rule(
ruleset=self.__class__.__name__,
name="Rb",
action="Action for b",
types=["[email protected]"],
depsfinder=tools.getMockDepsFinderCmd(["c#[email protected]"]),
dependson=["Rc"],
)
)
rules.add(
tools.create_rule(ruleset=self.__class__.__name__, name="Rc", action="Action for c", types=["[email protected]"])
)
ruleset = RuleSet(rules)
depgraph = ruleset.get_depgraph([Component("b#[email protected]"), Component("a#[email protected]")])
components = depgraph.components_map
self.assertTrue(components is not None)
self.assertEquals(len(components), 3, "Map: %s" % components)
self.assertTrue("a#[email protected]" in components)
self.assertTrue("b#[email protected]" in components)
self.assertTrue("c#[email protected]" in components)
self.assertTrue(depgraph.dag is not None)
self.assertTrue(depgraph.dag.has_node("a#[email protected]"))
self.assertTrue(depgraph.dag.has_node("b#[email protected]"))
self.assertTrue(depgraph.dag.has_node("c#[email protected]"))
self.assertTrue(depgraph.dag.has_edge(("a#[email protected]", "c#[email protected]")))
self.assertTrue(depgraph.dag.has_edge(("b#[email protected]", "c#[email protected]")))