Skip to content

Commit 549adac

Browse files
Merge branch 'main' into issue-221
2 parents 8025e1b + 74ffa0d commit 549adac

File tree

9 files changed

+48
-24
lines changed

9 files changed

+48
-24
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## [15.1.2] - 2025-09-04
4+
5+
### Fixed
6+
7+
- make `task_context` transforms really work without a `task-context` (#761)
8+
- set continuation token correctly in `find_task_id_batched` (#760)
9+
310
## [15.1.1] - 2025-09-02
411

512
### Fixed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### Project
22
[project]
33
name = "taskcluster-taskgraph"
4-
version = "15.1.1"
4+
version = "15.1.2"
55
description = "Build taskcluster taskgraphs"
66
readme = "README.rst"
77
authors = [

src/taskgraph/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ def register(self):
148148
sys.path.insert(0, self.root_dir)
149149
register_path = self["taskgraph"].get("register")
150150
if register_path:
151-
find_object(register_path)(self)
151+
register = find_object(register_path)
152+
assert callable(register)
153+
register(self)
152154

153155
@property
154156
def vcs_root(self):

src/taskgraph/decision.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ def get_decision_parameters(graph_config, options):
263263
parameters["optimize_target_tasks"] = options["optimize_target_tasks"]
264264

265265
if "decision-parameters" in graph_config["taskgraph"]:
266-
find_object(graph_config["taskgraph"]["decision-parameters"])(
267-
graph_config, parameters
268-
)
266+
decision_params = find_object(graph_config["taskgraph"]["decision-parameters"])
267+
assert callable(decision_params)
268+
decision_params(graph_config, parameters)
269269

270270
if options.get("try_task_config_file"):
271271
task_config_file = os.path.abspath(options.get("try_task_config_file"))

src/taskgraph/generator.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ class Kind:
3737
config: Dict
3838
graph_config: GraphConfig
3939

40-
def _get_loader(self):
40+
def _get_loader(self) -> Callable:
4141
try:
42-
loader = self.config["loader"]
42+
loader_path = self.config["loader"]
4343
except KeyError:
44-
loader = "taskgraph.loader.default:loader"
45-
return find_object(loader)
44+
loader_path = "taskgraph.loader.default:loader"
45+
loader = find_object(loader_path)
46+
assert callable(loader)
47+
return loader
4648

4749
def load_tasks(self, parameters, loaded_tasks, write_artifacts):
4850
loader = self._get_loader()

src/taskgraph/transforms/task_context.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@
8585
@transforms.add
8686
def render_task(config, tasks):
8787
for task in tasks:
88-
sub_config = task.pop("task-context")
88+
sub_config = task.pop("task-context", None)
89+
if sub_config is None:
90+
yield task
91+
continue
8992
params_context = {}
9093
for var, path in sub_config.pop("from-parameters", {}).items():
9194
if isinstance(path, str):

src/taskgraph/util/python_path.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5+
import importlib
56
import inspect
67
import os
78

89

9-
def find_object(path):
10+
def find_object(path: str):
1011
"""
1112
Find a Python object given a path of the form <modulepath>:<objectpath>.
1213
Conceptually equivalent to
@@ -19,11 +20,10 @@ def find_object(modulepath, objectpath):
1920
raise ValueError(f'python path {path!r} does not have the form "module:object"')
2021

2122
modulepath, objectpath = path.split(":")
22-
obj = __import__(modulepath)
23-
for a in modulepath.split(".")[1:]:
24-
obj = getattr(obj, a)
23+
obj = importlib.import_module(modulepath)
2524
for a in objectpath.split("."):
2625
obj = getattr(obj, a)
26+
2727
return obj
2828

2929

test/test_transform_task_context.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from copy import deepcopy
77
from pprint import pprint
88

9+
import pytest
910
from pytest_taskgraph import FakeParameters
1011

1112
from taskgraph.transforms import task_context
@@ -14,7 +15,7 @@
1415
here = os.path.abspath(os.path.dirname(__file__))
1516

1617
TASK_DEFAULTS = {
17-
"description": "fake description {object} {file} {param} {object_and_file}"
18+
"description": "fake description {object} {file} {param} {object_and_file} "
1819
"{object_and_param} {file_and_param} {object_file_and_param} {param_fallback} {name}",
1920
"name": "fake-task-name",
2021
"task-context": {
@@ -37,11 +38,24 @@
3738
],
3839
},
3940
}
41+
EXPECTED_DESCRIPTION = (
42+
"fake description object file param object-overrides-file "
43+
"param-overrides-object param-overrides-file param-overrides-all default fake-task-name"
44+
)
45+
NO_CONTEXT = deepcopy(TASK_DEFAULTS)
46+
del NO_CONTEXT["task-context"]
4047

4148

42-
def test_transforms(request, run_transform, graph_config):
43-
task = deepcopy(TASK_DEFAULTS)
44-
49+
@pytest.mark.parametrize(
50+
"task,description",
51+
(
52+
pytest.param(deepcopy(TASK_DEFAULTS), EXPECTED_DESCRIPTION, id="with-context"),
53+
pytest.param(
54+
deepcopy(NO_CONTEXT), TASK_DEFAULTS["description"], id="no-context"
55+
),
56+
),
57+
)
58+
def test_transforms(request, run_transform, graph_config, task, description):
4559
params = FakeParameters(
4660
{
4761
"param": "param",
@@ -77,8 +91,4 @@ def test_transforms(request, run_transform, graph_config):
7791
print("Dumping task:")
7892
pprint(task, indent=2)
7993

80-
assert (
81-
task["description"]
82-
== "fake description object file param object-overrides-file"
83-
"param-overrides-object param-overrides-file param-overrides-all default fake-task-name"
84-
)
94+
assert task["description"] == description

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)