зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1323633 - Ensure that task graphs do not contain duplicate Treeherder symbols, also consider treeherder.collection.keys(); r=dustin
MozReview-Commit-ID: 3F0BHQQmSOg --HG-- extra : rebase_source : 52ba5d93d689e5ca64cee04dd013dcd79919049d
This commit is contained in:
Родитель
892dd1cb42
Коммит
1964df62df
|
@ -12,7 +12,7 @@ from .graph import Graph
|
||||||
from .taskgraph import TaskGraph
|
from .taskgraph import TaskGraph
|
||||||
from .optimize import optimize_task_graph
|
from .optimize import optimize_task_graph
|
||||||
from .util.python_path import find_object
|
from .util.python_path import find_object
|
||||||
from .util.verifydoc import verify_docs
|
from .util.verify import verify_docs, verify_task_graph_symbol
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -217,6 +217,7 @@ class TaskGraphGenerator(object):
|
||||||
target_task_graph = TaskGraph(
|
target_task_graph = TaskGraph(
|
||||||
{l: all_tasks[l] for l in target_graph.nodes},
|
{l: all_tasks[l] for l in target_graph.nodes},
|
||||||
target_graph)
|
target_graph)
|
||||||
|
target_task_graph.for_each_task(verify_task_graph_symbol, scratch_pad={})
|
||||||
yield 'target_task_graph', target_task_graph
|
yield 'target_task_graph', target_task_graph
|
||||||
|
|
||||||
logger.info("Generating optimized task graph")
|
logger.info("Generating optimized task graph")
|
||||||
|
|
|
@ -46,6 +46,11 @@ class TaskGraph(object):
|
||||||
tasks[key] = task_json
|
tasks[key] = task_json
|
||||||
return tasks
|
return tasks
|
||||||
|
|
||||||
|
def for_each_task(self, f, *args, **kwargs):
|
||||||
|
for task_label in self.graph.visit_postorder():
|
||||||
|
task = self.tasks[task_label]
|
||||||
|
f(task, self, *args, **kwargs)
|
||||||
|
|
||||||
def __getitem__(self, label):
|
def __getitem__(self, label):
|
||||||
"Get a task by label"
|
"Get a task by label"
|
||||||
return self.tasks[label]
|
return self.tasks[label]
|
||||||
|
|
|
@ -38,3 +38,30 @@ def verify_docs(filename, identifiers, appearing_as):
|
||||||
"{}: `{}` missing from doc file: `{}`"
|
"{}: `{}` missing from doc file: `{}`"
|
||||||
.format(appearing_as, identifier, filename)
|
.format(appearing_as, identifier, filename)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def verify_task_graph_symbol(task, taskgraph, scratch_pad):
|
||||||
|
"""
|
||||||
|
This function verifies that tuple
|
||||||
|
(collection.keys(), machine.platform, groupSymbol, symbol) is unique
|
||||||
|
for a target task graph.
|
||||||
|
"""
|
||||||
|
task_dict = task.task
|
||||||
|
if "extra" in task_dict:
|
||||||
|
extra = task_dict["extra"]
|
||||||
|
if "treeherder" in extra:
|
||||||
|
treeherder = extra["treeherder"]
|
||||||
|
|
||||||
|
collection_keys = tuple(sorted(treeherder.get('collection', {}).keys()))
|
||||||
|
platform = treeherder.get('machine', {}).get('platform')
|
||||||
|
group_symbol = treeherder.get('groupSymbol')
|
||||||
|
symbol = treeherder.get('symbol')
|
||||||
|
|
||||||
|
key = (collection_keys, platform, group_symbol, symbol)
|
||||||
|
if key in scratch_pad:
|
||||||
|
raise Exception(
|
||||||
|
"conflict between `{}`:`{}` for values `{}`"
|
||||||
|
.format(task.label, scratch_pad[key], key)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
scratch_pad[key] = task.label
|
Загрузка…
Ссылка в новой задаче