Skip to content

Commit

Permalink
Remove unnecessary custom dict from downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
mimi1vx committed Feb 21, 2025
1 parent 2676d03 commit e84c9fd
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions mtui/export/downloader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections.abc import Callable, Hashable
from collections.abc import Callable
import concurrent.futures
from logging import getLogger
import os.path
Expand All @@ -10,14 +10,6 @@
logger = getLogger("mtui.export.downloader")


class DownloaderDict(dict):
def __getitem__(self, item: Hashable) -> Callable[[str, dict, str, str, str], None]:
try:
return super().__getitem__(item)
except KeyError:
return _emptylog


def _subdl(oqa_path: str, l_path: str, test: dict, errormode: str) -> None:
try:
logger.info("Downloading log %s", oqa_path)
Expand All @@ -28,7 +20,7 @@ def _subdl(oqa_path: str, l_path: str, test: dict, errormode: str) -> None:
raise ResultsMissingError(test["name"], test["arch"])


def _emptylog(host, test, *args, **kwds):
def _emptylog(host, test, *args, **kwds) -> None:
logger.debug("No log to download for test: %s on %s", test["name"], host)
pass

Expand Down Expand Up @@ -57,7 +49,10 @@ def _installlog(host, test, _, installlogsdir, errormode) -> None:
_subdl(oqa_path, l_path, test, errormode)


downloader = DownloaderDict({"install": _installlog, "ltp": _resultlog})
downloader: dict[str, Callable[[str, dict, str, str, str], None]] = {
"install": _installlog,
"ltp": _resultlog,
}


def download_logs(oqa, resultsdir, installogsdir, errormode: str) -> None:
Expand All @@ -71,5 +66,5 @@ def download_logs(oqa, resultsdir, installogsdir, errormode: str) -> None:
with concurrent.futures.ThreadPoolExecutor() as e:
for host, name, test_id, arch in results_matrix:
test = {"name": name, "test_id": test_id, "arch": arch}
dl = downloader[name.split("_")[0]]
dl = downloader.get(name.split("_")[0], _emptylog)
e.submit(dl, host, test, resultsdir, installogsdir, errormode)

0 comments on commit e84c9fd

Please sign in to comment.