mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 14:25:49 +00:00
Bug 1748510 - [taskgraph] Use taskgraph.py from vendored Taskgraph, r=taskgraph-reviewers,aki
The files are identical so this is just a matter of updating the references. Depends on D140755 Differential Revision: https://phabricator.services.mozilla.com/D140756
This commit is contained in:
parent
deab40aaac
commit
5c60693de8
@ -7,12 +7,12 @@ import logging
|
||||
|
||||
import requests
|
||||
from requests.exceptions import HTTPError
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
from taskgraph.util.taskcluster import get_artifact_from_index, get_task_definition
|
||||
|
||||
from .registry import register_callback_action
|
||||
from .util import create_tasks, combine_task_graph_files
|
||||
from gecko_taskgraph.util.taskgraph import find_decision_task
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
|
||||
PUSHLOG_TMPL = "{}/json-pushes?version=2&startID={}&endID={}"
|
||||
INDEX_TMPL = "gecko.v2.{}.pushlog-id.{}.decision"
|
||||
|
@ -7,6 +7,7 @@ import json
|
||||
import os
|
||||
|
||||
from taskgraph.parameters import Parameters
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
from taskgraph.util.taskcluster import get_artifact
|
||||
|
||||
from gecko_taskgraph.actions.registry import register_callback_action
|
||||
@ -21,7 +22,6 @@ from gecko_taskgraph.util.partners import (
|
||||
get_partner_url_config,
|
||||
get_token,
|
||||
)
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
from gecko_taskgraph.decision import taskgraph_decision
|
||||
from gecko_taskgraph.util.attributes import RELEASE_PROMOTION_PROJECTS, release_level
|
||||
|
||||
|
@ -14,6 +14,7 @@ import jsone
|
||||
import requests
|
||||
from requests.exceptions import HTTPError
|
||||
from slugid import nice as slugid
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
from taskgraph.util.taskcluster import (
|
||||
find_task_id,
|
||||
get_artifact,
|
||||
@ -26,7 +27,6 @@ from taskgraph.util.taskcluster import (
|
||||
|
||||
from gecko_taskgraph import create
|
||||
from gecko_taskgraph.decision import read_artifact, write_artifact, rename_artifact
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
from gecko_taskgraph.optimize import optimize_task_graph
|
||||
from gecko_taskgraph.util.taskcluster import trigger_hook
|
||||
from gecko_taskgraph.util.taskgraph import find_decision_task
|
||||
|
@ -13,6 +13,7 @@ from collections import defaultdict
|
||||
import yaml
|
||||
from redo import retry
|
||||
from taskgraph.parameters import Parameters
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
from taskgraph.util.taskcluster import get_artifact
|
||||
from taskgraph.util.yaml import load_yaml
|
||||
from voluptuous import Required, Optional, Any
|
||||
@ -22,7 +23,6 @@ from .actions import render_actions_json
|
||||
from .create import create_tasks
|
||||
from .generator import TaskGraphGenerator
|
||||
from .parameters import get_version, get_app_version
|
||||
from .taskgraph import TaskGraph
|
||||
from .try_option_syntax import parse_message
|
||||
from .util.backstop import is_backstop, BACKSTOP_INDEX
|
||||
from .util.bugbug import push_schedules
|
||||
|
@ -11,12 +11,12 @@ from taskgraph.config import GraphConfig
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.parameters import parameters_loader
|
||||
from taskgraph.task import Task
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
from taskgraph.util.yaml import load_yaml
|
||||
|
||||
from . import filter_tasks
|
||||
from .morph import morph
|
||||
from .optimize import optimize_task_graph
|
||||
from .taskgraph import TaskGraph
|
||||
from .transforms.base import TransformSequence, TransformConfig
|
||||
from .util.python_path import find_object
|
||||
from .util.verify import (
|
||||
|
@ -67,7 +67,7 @@ def get_filtered_taskgraph(taskgraph, tasksregex):
|
||||
and returns a new TaskGraph object
|
||||
"""
|
||||
from taskgraph.graph import Graph
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
# return original taskgraph if no regular expression is passed
|
||||
if not tasksregex:
|
||||
|
@ -27,8 +27,8 @@ import re
|
||||
from slugid import nice as slugid
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.task import Task
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
from .taskgraph import TaskGraph
|
||||
from .util.attributes import release_level
|
||||
from .util.workertypes import get_worker_type
|
||||
|
||||
|
@ -19,12 +19,12 @@ from collections import defaultdict
|
||||
|
||||
from slugid import nice as slugid
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
from taskgraph.util.parameterization import (
|
||||
resolve_task_references,
|
||||
resolve_timestamps,
|
||||
)
|
||||
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
from gecko_taskgraph.util.python_path import import_sibling_modules
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -1,71 +0,0 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.task import Task
|
||||
|
||||
import attr
|
||||
|
||||
|
||||
@attr.s(frozen=True)
|
||||
class TaskGraph:
|
||||
"""
|
||||
Representation of a task graph.
|
||||
|
||||
A task graph is a combination of a Graph and a dictionary of tasks indexed
|
||||
by label. TaskGraph instances should be treated as immutable.
|
||||
|
||||
In the graph, tasks are said to "link to" their dependencies. Whereas
|
||||
tasks are "linked from" their dependents.
|
||||
"""
|
||||
|
||||
tasks = attr.ib()
|
||||
graph = attr.ib()
|
||||
|
||||
def __attrs_post_init__(self):
|
||||
assert set(self.tasks) == self.graph.nodes
|
||||
|
||||
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):
|
||||
"Get a task by label"
|
||||
return self.tasks[label]
|
||||
|
||||
def __contains__(self, label):
|
||||
return label in self.tasks
|
||||
|
||||
def __iter__(self):
|
||||
"Iterate over tasks in undefined order"
|
||||
return iter(self.tasks.values())
|
||||
|
||||
def to_json(self):
|
||||
"Return a JSON-able object representing the task graph, as documented"
|
||||
named_links_dict = self.graph.named_links_dict()
|
||||
# this dictionary may be keyed by label or by taskid, so let's just call it 'key'
|
||||
tasks = {}
|
||||
for key in self.graph.visit_postorder():
|
||||
tasks[key] = self.tasks[key].to_json()
|
||||
# overwrite dependencies with the information in the taskgraph's edges.
|
||||
tasks[key]["dependencies"] = named_links_dict.get(key, {})
|
||||
return tasks
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, tasks_dict):
|
||||
"""
|
||||
This code is used to generate the a TaskGraph using a dictionary
|
||||
which is representative of the TaskGraph.
|
||||
"""
|
||||
tasks = {}
|
||||
edges = set()
|
||||
for key, value in tasks_dict.items():
|
||||
tasks[key] = Task.from_json(value)
|
||||
if "task_id" in value:
|
||||
tasks[key].task_id = value["task_id"]
|
||||
for depname, dep in value["dependencies"].items():
|
||||
edges.add((key, dep, depname))
|
||||
task_graph = cls(tasks, Graph(set(tasks), edges))
|
||||
return tasks, task_graph
|
@ -11,7 +11,6 @@ subsuite = taskgraph
|
||||
[test_optimize.py]
|
||||
[test_optimize_strategies.py]
|
||||
[test_target_tasks.py]
|
||||
[test_taskgraph.py]
|
||||
[test_taskcluster_yml.py]
|
||||
[test_transforms_base.py]
|
||||
[test_transforms_job.py]
|
||||
|
@ -8,10 +8,10 @@ import unittest
|
||||
from taskgraph.config import GraphConfig
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.task import Task
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
from unittest import mock
|
||||
|
||||
from gecko_taskgraph import create
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
|
||||
from mozunit import main
|
||||
|
||||
|
@ -7,9 +7,9 @@ import pytest
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.parameters import Parameters
|
||||
from taskgraph.task import Task
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
from gecko_taskgraph import morph
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
|
||||
from mozunit import main
|
||||
|
||||
|
@ -10,10 +10,10 @@ import pytest
|
||||
from mozunit import main
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.task import Task
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
from gecko_taskgraph import optimize
|
||||
from gecko_taskgraph.optimize import OptimizationStrategy, All, Any, Not
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
|
||||
|
||||
class Remove(OptimizationStrategy):
|
||||
|
@ -11,10 +11,10 @@ import pytest
|
||||
from mozunit import main
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.task import Task
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
from gecko_taskgraph import target_tasks
|
||||
from gecko_taskgraph import try_option_syntax
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
|
||||
|
||||
class FakeTryOptionSyntax:
|
||||
|
@ -1,127 +0,0 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.task import Task
|
||||
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
from mozunit import main
|
||||
|
||||
|
||||
class TestTaskGraph(unittest.TestCase):
|
||||
|
||||
maxDiff = None
|
||||
|
||||
def test_taskgraph_to_json(self):
|
||||
tasks = {
|
||||
"a": Task(
|
||||
kind="test",
|
||||
label="a",
|
||||
description="Task A",
|
||||
attributes={"attr": "a-task"},
|
||||
task={"taskdef": True},
|
||||
),
|
||||
"b": Task(
|
||||
kind="test",
|
||||
label="b",
|
||||
attributes={},
|
||||
task={"task": "def"},
|
||||
optimization={"skip-unless-has-relevant-tests": None},
|
||||
# note that this dep is ignored, superseded by that
|
||||
# from the taskgraph's edges
|
||||
dependencies={"first": "a"},
|
||||
),
|
||||
}
|
||||
graph = Graph(nodes=set("ab"), edges={("a", "b", "edgelabel")})
|
||||
taskgraph = TaskGraph(tasks, graph)
|
||||
|
||||
res = taskgraph.to_json()
|
||||
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"a": {
|
||||
"kind": "test",
|
||||
"label": "a",
|
||||
"description": "Task A",
|
||||
"attributes": {"attr": "a-task", "kind": "test"},
|
||||
"task": {"taskdef": True},
|
||||
"dependencies": {"edgelabel": "b"},
|
||||
"soft_dependencies": [],
|
||||
"if_dependencies": [],
|
||||
"optimization": None,
|
||||
},
|
||||
"b": {
|
||||
"kind": "test",
|
||||
"label": "b",
|
||||
"description": "",
|
||||
"attributes": {"kind": "test"},
|
||||
"task": {"task": "def"},
|
||||
"dependencies": {},
|
||||
"soft_dependencies": [],
|
||||
"if_dependencies": [],
|
||||
"optimization": {"skip-unless-has-relevant-tests": None},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
def test_round_trip(self):
|
||||
graph = TaskGraph(
|
||||
tasks={
|
||||
"a": Task(
|
||||
kind="fancy",
|
||||
label="a",
|
||||
description="Task A",
|
||||
attributes={},
|
||||
dependencies={"prereq": "b"}, # must match edges, below
|
||||
optimization={"skip-unless-has-relevant-tests": None},
|
||||
task={"task": "def"},
|
||||
),
|
||||
"b": Task(
|
||||
kind="pre",
|
||||
label="b",
|
||||
attributes={},
|
||||
dependencies={},
|
||||
optimization={"skip-unless-has-relevant-tests": None},
|
||||
task={"task": "def2"},
|
||||
),
|
||||
},
|
||||
graph=Graph(nodes={"a", "b"}, edges={("a", "b", "prereq")}),
|
||||
)
|
||||
|
||||
tasks, new_graph = TaskGraph.from_json(graph.to_json())
|
||||
self.assertEqual(graph, new_graph)
|
||||
|
||||
simple_graph = TaskGraph(
|
||||
tasks={
|
||||
"a": Task(
|
||||
kind="fancy",
|
||||
label="a",
|
||||
attributes={},
|
||||
dependencies={"prereq": "b"}, # must match edges, below
|
||||
optimization={"skip-unless-has-relevant-tests": None},
|
||||
task={"task": "def"},
|
||||
),
|
||||
"b": Task(
|
||||
kind="pre",
|
||||
label="b",
|
||||
attributes={},
|
||||
dependencies={},
|
||||
optimization={"skip-unless-has-relevant-tests": None},
|
||||
task={"task": "def2"},
|
||||
),
|
||||
},
|
||||
graph=Graph(nodes={"a", "b"}, edges={("a", "b", "prereq")}),
|
||||
)
|
||||
|
||||
def test_contains(self):
|
||||
assert "a" in self.simple_graph
|
||||
assert "c" not in self.simple_graph
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -8,9 +8,9 @@ import unittest
|
||||
from mozunit import main
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.task import Task
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
from gecko_taskgraph.try_option_syntax import TryOptionSyntax, parse_message
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
|
||||
|
||||
def unittest_task(n, tp, bt="opt"):
|
||||
|
@ -8,9 +8,9 @@ import unittest
|
||||
from mozunit import main
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.task import Task
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
from gecko_taskgraph.decision import full_task_graph_to_runnable_jobs
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
|
||||
|
||||
class TestRunnableJobs(unittest.TestCase):
|
||||
|
@ -4,9 +4,9 @@ import subprocess
|
||||
|
||||
import pytest
|
||||
from mozunit import main
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
from gecko_taskgraph import GECKO
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
|
||||
pytestmark = pytest.mark.slow
|
||||
PARAMS_DIR = os.path.join(GECKO, "taskcluster", "test", "params")
|
||||
|
@ -15,10 +15,10 @@ from mozbuild.base import MozbuildObject
|
||||
from mozpack.files import FileFinder
|
||||
from moztest.resolve import TestResolver, TestManifestLoader, get_suite_definition
|
||||
from taskgraph.parameters import ParameterMismatch, parameters_loader
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
import gecko_taskgraph
|
||||
from gecko_taskgraph.generator import TaskGraphGenerator
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
build = MozbuildObject.from_environment(cwd=here)
|
||||
|
@ -10,9 +10,9 @@ import pytest
|
||||
import yaml
|
||||
from unittest.mock import MagicMock
|
||||
from moztest.resolve import TestResolver
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
from taskgraph.graph import Graph
|
||||
from taskgraph.task import Task
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
from tryselect import push
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user