Skip to content

Commit ec38014

Browse files
Quick fixes for loader class
1 parent 9f7e9f4 commit ec38014

File tree

6 files changed

+33
-17
lines changed

6 files changed

+33
-17
lines changed

tools/submission/submission_checker/__init__.py

Whitespace-only changes.

tools/submission/submission_checker/configuration/__init__.py

Whitespace-only changes.

tools/submission/submission_checker/loader.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
from .constants import PERFORMANCE_LOG_PATH, PERFORMANCE_SUMMARY_PATH, ACCURACY_LOG_PATH, VALID_DIVISIONS
33
from .utils import list_dir
44
from .parsers.loadgen_parser import LoadgenParser
5-
from typing import Generator
5+
from typing import Generator, Literal
6+
import logging
7+
8+
logging.basicConfig(
9+
level=logging.INFO,
10+
format="[%(asctime)s %(filename)s:%(lineno)d %(levelname)s] %(message)s",
11+
)
612

713

814
class SubmissionLogs:
@@ -15,26 +21,36 @@ class Loader:
1521
def __init__(self, root, version) -> None:
1622
self.root = root
1723
self.version = version
18-
self.perf_log_path = PERFORMANCE_LOG_PATH.get(version, PERFORMANCE_LOG_PATH["default"])
19-
self.perf_summary_path = PERFORMANCE_SUMMARY_PATH.get(version, PERFORMANCE_SUMMARY_PATH["default"])
20-
self.acc_log_path = ACCURACY_LOG_PATH.get(version, ACCURACY_LOG_PATH["default"])
24+
self.logger = logging.getLogger("LoadgenParser")
25+
self.perf_log_path = os.path.join(self.root, PERFORMANCE_LOG_PATH.get(version, PERFORMANCE_LOG_PATH["default"]))
26+
self.perf_summary_path = os.path.join(self.root, PERFORMANCE_SUMMARY_PATH.get(version, PERFORMANCE_SUMMARY_PATH["default"]))
27+
self.acc_log_path = os.path.join(self.root, ACCURACY_LOG_PATH.get(version, ACCURACY_LOG_PATH["default"]))
28+
29+
def load_single_log(self, path, log_type: Literal["Performance", "Accuracy", "Test"]):
30+
log = None
31+
if os.path.exists(path):
32+
self.logger.info("Loading %s log from %s", log_type, path)
33+
log = LoadgenParser(path)
34+
else:
35+
self.logger.info("Could not load %s log from %s, path does not exist", log_type, path)
36+
return log
2137

2238

23-
def load(self) -> Generator[SubmissionLogs, None]:
39+
def load(self) -> Generator[SubmissionLogs, None, None]:
2440
for division in list_dir(self.root):
2541
if division not in VALID_DIVISIONS:
2642
continue
2743
division_path = os.path.join(self.root, division)
28-
for submitter in list_dir(division):
44+
for submitter in list_dir(division_path):
2945
results_path = os.path.join(division_path, submitter, "results")
3046
for system in list_dir(results_path):
3147
system_path = os.path.join(results_path, system)
3248
for benchmark in list_dir(system_path):
3349
benchmark_path = os.path.join(system_path, benchmark)
34-
for scenario in benchmark_path:
50+
for scenario in list_dir(benchmark_path):
3551
scenario_path = os.path.join(benchmark_path, benchmark)
36-
perf_log = LoadgenParser(self.perf_log_path.format(division = division, submitter = submitter, system = system, benchmark = system, scenario = scenario))
37-
acc_log = LoadgenParser(self.acc_log_path.format(division = division, submitter = submitter, system = system, benchmark = system, scenario = scenario))
52+
perf_path = self.perf_log_path.format(division = division, submitter = submitter, system = system, benchmark = benchmark, scenario = scenario)
53+
acc_path = self.acc_log_path.format(division = division, submitter = submitter, system = system, benchmark = benchmark, scenario = scenario)
54+
perf_log = self.load_single_log(perf_path, "Performance")
55+
acc_log = perf_log = self.load_single_log(acc_path, "Accuracy")
3856
yield SubmissionLogs(perf_log, acc_log)
39-
yield None
40-

tools/submission/submission_checker/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import os
44

5-
from .constants import MODEL_CONFIG, CSV_HEAD
5+
from .constants import MODEL_CONFIG
66
from .configuration.configuration import Config
77

88
logging.basicConfig(level=logging.INFO)
@@ -15,7 +15,7 @@ def get_args():
1515
parser.add_argument("--input", required=True, help="submission directory")
1616
parser.add_argument(
1717
"--version",
18-
default="v4.1",
18+
default="v5.1",
1919
choices=list(MODEL_CONFIG.keys()),
2020
help="mlperf version",
2121
)

tools/submission/submission_checker/parsers/__init__.py

Whitespace-only changes.

tools/submission/submission_checker/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
def list_dir(*path):
55
path = os.path.join(*path)
6-
return [f for f in os.listdir(
7-
path) if os.path.isdir(os.path.join(path, f))]
6+
return sorted([f for f in os.listdir(
7+
path) if os.path.isdir(os.path.join(path, f))])
88

99

1010
def list_files(*path):
1111
path = os.path.join(*path)
12-
return [f for f in os.listdir(
13-
path) if os.path.isfile(os.path.join(path, f))]
12+
return sorted([f for f in os.listdir(
13+
path) if os.path.isfile(os.path.join(path, f))])
1414

1515

1616
def list_empty_dirs_recursively(*path):

0 commit comments

Comments
 (0)