Skip to content

Commit 1e17405

Browse files
committed
Cache TaskCluster artifacts already fetched
1 parent e30dd16 commit 1e17405

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

mozci/taskcluster/tc.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
TC_SCHEMA_URL = 'http://schemas.taskcluster.net/scheduler/v1/task-graph.json'
3636
TC_INDEX_URL = 'https://index.taskcluster.net/v1/task/'
3737
TC_QUEUE_URL = 'https://queue.taskcluster.net/v1/task/'
38+
TC_ARTIFACTS_CACHE = {}
3839

3940

4041
class TaskClusterManager(BaseCIManager):
@@ -454,13 +455,20 @@ def get_artifact_for_task_id(task_id, artifact_path):
454455
"""
455456
This is a generic function which downloads a TaskCluster artifact in plain text.
456457
"""
458+
global TC_ARTIFACTS_CACHE
459+
457460
if task_id is None or len(task_id) == 0:
458461
raise TaskClusterError("Please input a valid Task ID to fetch the artifact.")
459462
url = TC_QUEUE_URL + task_id + "/artifacts/" + artifact_path
460-
resp = requests.get(url)
461-
if resp.status_code != 200:
462-
raise TaskClusterArtifactError("Please check your Task ID and artifact path.")
463-
return resp.text
463+
464+
try:
465+
TC_ARTIFACTS_CACHE[task_id][artifact_path]
466+
except Exception as e:
467+
handle_exception(e)
468+
resp = requests.get(url)
469+
if resp.status_code != 200:
470+
raise TaskClusterArtifactError("Please check your Task ID and artifact path.")
471+
return resp.text
464472

465473

466474
def is_taskcluster_label(task_label, decision_task_id):

0 commit comments

Comments
 (0)