Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary custom dict from downloader #24

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)