Skip to content

Commit

Permalink
style: pre-commit.ci auto fixes [...]
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Dec 10, 2024
1 parent e2fe3b9 commit 5020b6a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions taskcluster/fxci_config_taskgraph/util/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

import copy
from functools import cache
from typing import Any, Dict, List, Union
from typing import Any

import requests
import taskcluster
from taskgraph.util.taskcluster import get_task_url, get_session
from taskgraph.util.memoize import memoize
from taskgraph.util.taskcluster import get_session, get_task_url

FIREFOXCI_ROOT_URL = "https://firefox-ci-tc.services.mozilla.com"
STAGING_ROOT_URL = "https://stage.taskcluster.nonprod.cloudops.mozgcp.net"


def _do_request(url, method=None, **kwargs):
if method is None:
method = "post" if kwargs else "get"
Expand Down Expand Up @@ -50,9 +52,7 @@ def _get_deps(task_ids, use_proxy):
return upstream_tasks


def get_ancestors(
task_ids: Union[List[str], str], use_proxy: bool = False
) -> Dict[str, str]:
def get_ancestors(task_ids: list[str] | str, use_proxy: bool = False) -> dict[str, str]:
"""Gets the ancestor tasks of the given task_ids as a dictionary of label -> taskid.
Args:
Expand All @@ -62,7 +62,7 @@ def get_ancestors(
Returns:
dict: A dict whose keys are task labels and values are task ids.
"""
upstream_tasks: Dict[str, str] = {}
upstream_tasks: dict[str, str] = {}

if isinstance(task_ids, str):
task_ids = [task_ids]
Expand All @@ -74,14 +74,17 @@ def get_ancestors(

return copy.deepcopy(upstream_tasks)


@cache
def get_taskcluster_client(service: str):
options = {"rootUrl": FIREFOXCI_ROOT_URL}
return getattr(taskcluster, service.capitalize())(options)


@cache
def find_tasks(decision_index_path: str, include_deps: bool = False) -> list[dict[str, Any]]:
def find_tasks(
decision_index_path: str, include_deps: bool = False
) -> list[dict[str, Any]]:
"""Find tasks targeted by the Decision task pointed to by `decision_index_path`."""
queue = get_taskcluster_client("queue")
index = get_taskcluster_client("index")
Expand Down Expand Up @@ -115,6 +118,7 @@ def find_tasks(decision_index_path: str, include_deps: bool = False) -> list[dic
if include_deps:
# TODO: remove hack
import os

orig = os.environ["TASKCLUSTER_ROOT_URL"]
os.environ["TASKCLUSTER_ROOT_URL"] = FIREFOXCI_ROOT_URL
for label, task_id in get_ancestors(task["task_id"]).items():
Expand Down

0 comments on commit 5020b6a

Please sign in to comment.