Skip to content

Commit f20ebf1

Browse files
bhearsumahal
authored andcommitted
BREAKING CHANGE: Delete taskgraph.util.memoize (fixes #491)
1 parent f6bd78a commit f20ebf1

File tree

9 files changed

+24
-40
lines changed

9 files changed

+24
-40
lines changed

docs/reference/source/taskgraph.util.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ taskgraph.util.keyed\_by module
6060
:undoc-members:
6161
:show-inheritance:
6262

63-
taskgraph.util.memoize module
64-
-----------------------------
65-
66-
.. automodule:: taskgraph.util.memoize
67-
:members:
68-
:undoc-members:
69-
:show-inheritance:
70-
7163
taskgraph.util.parameterization module
7264
--------------------------------------
7365

src/taskgraph/actions/registry.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55

6+
import functools
67
import json
78
from collections import namedtuple
89
from types import FunctionType
@@ -13,7 +14,6 @@
1314
from taskgraph.config import load_graph_config
1415
from taskgraph.parameters import Parameters
1516
from taskgraph.util import hash, taskcluster, yaml
16-
from taskgraph.util.memoize import memoize
1717
from taskgraph.util.python_path import import_sibling_modules
1818

1919
actions = []
@@ -31,13 +31,13 @@ def is_json(data):
3131
return True
3232

3333

34-
@memoize
34+
@functools.lru_cache(maxsize=None)
3535
def read_taskcluster_yml(filename):
36-
"""Load and parse .taskcluster.yml, memoized to save some time"""
36+
"""Load and parse .taskcluster.yml, cached to save some time"""
3737
return yaml.load_yaml(filename)
3838

3939

40-
@memoize
40+
@functools.lru_cache(maxsize=None)
4141
def hash_taskcluster_yml(filename):
4242
"""
4343
Generate a hash of the given .taskcluster.yml. This is the first 10 digits

src/taskgraph/transforms/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55

6+
import functools
67
import re
78
from dataclasses import dataclass, field
89
from typing import Dict, List, Union
@@ -11,7 +12,6 @@
1112

1213
from ..config import GraphConfig
1314
from ..parameters import Parameters
14-
from ..util.memoize import memoize
1515
from ..util.schema import Schema, validate_schema
1616

1717

@@ -58,7 +58,7 @@ class TransformConfig:
5858
write_artifacts: bool
5959

6060
@property
61-
@memoize
61+
@functools.lru_cache(maxsize=None)
6262
def repo_configs(self):
6363
repositories = self.graph_config["taskgraph"]["repositories"]
6464
if len(repositories) == 1:

src/taskgraph/transforms/task.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111

12+
import functools
1213
import hashlib
1314
import os
1415
import re
@@ -23,7 +24,6 @@
2324
from taskgraph.transforms.base import TransformSequence
2425
from taskgraph.util.hash import hash_path
2526
from taskgraph.util.keyed_by import evaluate_keyed_by
26-
from taskgraph.util.memoize import memoize
2727
from taskgraph.util.schema import (
2828
OptimizationSchema,
2929
Schema,
@@ -43,7 +43,7 @@
4343
)
4444

4545

46-
@memoize
46+
@functools.lru_cache(maxsize=None)
4747
def _run_task_suffix():
4848
"""String to append to cache names under control of run-task."""
4949
return hash_path(RUN_TASK)[0:20]
@@ -214,14 +214,14 @@ def get_branch_rev(config):
214214
return config.params["head_rev"]
215215

216216

217-
@memoize
217+
@functools.lru_cache(maxsize=None)
218218
def get_default_priority(graph_config, project):
219219
return evaluate_keyed_by(
220220
graph_config["task-priority"], "Graph Config", {"project": project}
221221
)
222222

223223

224-
@memoize
224+
@functools.lru_cache(maxsize=None)
225225
def get_default_deadline(graph_config, project):
226226
return evaluate_keyed_by(
227227
graph_config["task-deadline-after"], "Graph Config", {"project": project}

src/taskgraph/util/docker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55

6+
import functools
67
import hashlib
78
import io
89
import os
910
import re
1011
from typing import Optional
1112

1213
from taskgraph.util.archive import create_tar_gz_from_files
13-
from taskgraph.util.memoize import memoize
1414

1515
IMAGE_DIR = os.path.join(".", "taskcluster", "docker")
1616

@@ -205,7 +205,7 @@ def stream_context_tar(topsrcdir, context_dir, out_file, image_name=None, args=N
205205
return writer.hexdigest()
206206

207207

208-
@memoize
208+
@functools.lru_cache(maxsize=None)
209209
def image_paths():
210210
"""Return a map of image name to paths containing their Dockerfile."""
211211
config = load_yaml("taskcluster", "kinds", "docker-image", "kind.yml")
@@ -222,7 +222,7 @@ def image_path(name):
222222
return os.path.join(IMAGE_DIR, name)
223223

224224

225-
@memoize
225+
@functools.lru_cache(maxsize=None)
226226
def parse_volumes(image):
227227
"""Parse VOLUME entries from a Dockerfile for an image."""
228228
volumes = set()

src/taskgraph/util/hash.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
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 functools
56
import hashlib
67
from pathlib import Path
78

89
from taskgraph.util import path as mozpath
9-
from taskgraph.util.memoize import memoize
1010

1111

12-
@memoize
12+
@functools.lru_cache(maxsize=None)
1313
def hash_path(path):
1414
"""Hash a single file.
1515
@@ -44,13 +44,13 @@ def hash_paths(base_path, patterns):
4444
return h.hexdigest()
4545

4646

47-
@memoize
47+
@functools.lru_cache(maxsize=None)
4848
def _find_matching_files(base_path, pattern):
4949
files = _get_all_files(base_path)
5050
return [path for path in files if mozpath.match(path, pattern)]
5151

5252

53-
@memoize
53+
@functools.lru_cache(maxsize=None)
5454
def _get_all_files(base_path):
5555
return [
5656
mozpath.normsep(str(path))

src/taskgraph/util/memoize.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/taskgraph/util/taskcluster.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from taskgraph.task import Task
1818
from taskgraph.util import yaml
19-
from taskgraph.util.memoize import memoize
2019

2120
logger = logging.getLogger(__name__)
2221

@@ -31,7 +30,7 @@
3130
CONCURRENCY = 50
3231

3332

34-
@memoize
33+
@functools.lru_cache(maxsize=None)
3534
def get_root_url(use_proxy):
3635
"""Get the current TASKCLUSTER_ROOT_URL.
3736
@@ -106,7 +105,7 @@ def requests_retry_session(
106105
return session
107106

108107

109-
@memoize
108+
@functools.lru_cache(maxsize=None)
110109
def get_session():
111110
return requests_retry_session(retries=5)
112111

@@ -277,7 +276,7 @@ def get_task_url(task_id, use_proxy=False):
277276
return task_tmpl.format(task_id)
278277

279278

280-
@memoize
279+
@functools.lru_cache(maxsize=None)
281280
def get_task_definition(task_id, use_proxy=False):
282281
response = _do_request(get_task_url(task_id, use_proxy))
283282
return response.json()
@@ -446,7 +445,7 @@ def list_task_group_incomplete_tasks(task_group_id):
446445
break
447446

448447

449-
@memoize
448+
@functools.lru_cache(maxsize=None)
450449
def _get_deps(task_ids, use_proxy):
451450
upstream_tasks = {}
452451
for task_id in task_ids:

src/taskgraph/util/workertypes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
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 functools
56
from dataclasses import dataclass
67

78
from .keyed_by import evaluate_keyed_by
8-
from .memoize import memoize
99

1010

1111
@dataclass
@@ -29,7 +29,7 @@ def implementation(self):
2929
}
3030

3131

32-
@memoize
32+
@functools.lru_cache(maxsize=None)
3333
def worker_type_implementation(graph_config, worker_type):
3434
"""Get the worker implementation and OS for the given workerType, where the
3535
OS represents the host system, not the target OS, in the case of
@@ -46,7 +46,7 @@ def worker_type_implementation(graph_config, worker_type):
4646
return worker_config["implementation"], worker_config.get("os")
4747

4848

49-
@memoize
49+
@functools.lru_cache(maxsize=None)
5050
def get_worker_type(graph_config, alias, level):
5151
"""
5252
Get the worker type based, evaluating aliases from the graph config.

0 commit comments

Comments
 (0)