Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow task group to be overridden in create_tasks/taskgraph_dec… #611

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/taskgraph/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
testing = False


def create_tasks(graph_config, taskgraph, label_to_taskid, params, decision_task_id):
def create_tasks(
graph_config,
taskgraph,
label_to_taskid,
params,
decision_task_id,
task_group_id=None,
):
taskid_to_label = {t: l for l, t in label_to_taskid.items()}

# when running as an actual decision task, we use the decision task's
Expand All @@ -43,7 +50,7 @@ def create_tasks(graph_config, taskgraph, label_to_taskid, params, decision_task
if not any(t in taskgraph.tasks for t in task_def.get("dependencies", [])):
task_def.setdefault("dependencies", []).append(decision_task_id)

task_def["taskGroupId"] = decision_task_id
task_def["taskGroupId"] = task_group_id or decision_task_id
task_def["schedulerId"] = scheduler_id

# If `testing` is True, then run without parallelization
Expand Down
3 changes: 2 additions & 1 deletion src/taskgraph/decision.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def full_task_graph_to_runnable_tasks(full_task_json):
return runnable_tasks


def taskgraph_decision(options, parameters=None):
def taskgraph_decision(options, parameters=None, task_group_id=None):
"""
Run the decision task. This function implements `mach taskgraph decision`,
and is responsible for
Expand Down Expand Up @@ -152,6 +152,7 @@ def taskgraph_decision(options, parameters=None):
tgg.label_to_taskid,
tgg.parameters,
decision_task_id=decision_task_id,
task_group_id=task_group_id,
)


Expand Down
25 changes: 25 additions & 0 deletions test/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@ def test_create_tasks(self):
continue
self.assertIn(depid, self.created_tasks)

def test_create_tasks_explicit_group_id(self):
tasks = {
"tid-a": Task(
kind="test", label="a", attributes={}, task={"payload": "hello world"}
),
"tid-b": Task(
kind="test", label="b", attributes={}, task={"payload": "hello world"}
),
}
label_to_taskid = {"a": "tid-a", "b": "tid-b"}
graph = Graph(nodes={"tid-a", "tid-b"}, edges={("tid-a", "tid-b", "edge")})
taskgraph = TaskGraph(tasks, graph)

create.create_tasks(
GRAPH_CONFIG,
taskgraph,
label_to_taskid,
{"level": "4"},
decision_task_id="decisiontask",
task_group_id="task_group",
)

for _, task in self.created_tasks.items():
self.assertEqual(task["taskGroupId"], "task_group")

def test_create_task_without_dependencies(self):
"a task with no dependencies depends on the decision task"
tasks = {
Expand Down
Loading