Skip to content

Commit cf5ff27

Browse files
Add next batch of checks
1 parent ae9cfbd commit cf5ff27

File tree

5 files changed

+130
-14
lines changed

5 files changed

+130
-14
lines changed

tools/submission/submission_checker/checks/performance_check.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ def min_duration_check(self):
199199
return True
200200

201201
def network_check(self):
202+
if self.system_json is None:
203+
self.log.error(
204+
"%s system json file not found",
205+
self.path
206+
)
207+
return False
202208
is_network_mode_sys_spec_str = self.system_json.get(SYSTEM_DESC_IS_NETWORK_MODE)
203209
is_network_system = (
204210
is_network_mode_sys_spec_str.lower() == "true"
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
from .base import BaseCheck
2+
from ..constants import *
3+
from ..loader import SubmissionLogs
4+
from ..configuration.configuration import Config
5+
6+
class SystemCheck(BaseCheck):
7+
def __init__(self, log, path, config: Config, submission_logs: SubmissionLogs):
8+
super().__init__(log, path)
9+
self.submission_logs = submission_logs
10+
self.system_json = self.submission_logs.system_json
11+
self.submitter = self.submission_logs.loader_data.get("submitter", "")
12+
self.division = self.submission_logs.loader_data.get("division", "")
13+
self.config = config
14+
self.setup_checks()
15+
16+
def setup_checks(self):
17+
self.checks.append(self.missing_check)
18+
self.checks.append(self.availability_check)
19+
self.checks.append(self.system_type_check)
20+
self.checks.append(self.network_check)
21+
self.checks.append(self.required_fields_check)
22+
self.checks.append(self.submitter_check)
23+
self.checks.append(self.division_check)
24+
25+
def missing_check(self):
26+
if self.system_json is None:
27+
self.log.error(
28+
"%s system json file not found",
29+
self.path
30+
)
31+
return False
32+
return True
33+
34+
def availability_check(self):
35+
availability = self.system_json.get("status").lower()
36+
if availability not in VALID_AVAILABILITIES:
37+
self.log.error(
38+
"%s has invalid status (%s)", self.path, availability
39+
)
40+
return False
41+
return True
42+
43+
def system_type_check(self):
44+
system_type = self.system_json.get("system_type")
45+
valid_system_types = [
46+
"datacenter", "edge", "datacenter,edge", "edge,datacenter"]
47+
48+
if system_type not in valid_system_types:
49+
self.log.error(
50+
"%s has invalid system type (%s)",
51+
self.path,
52+
system_type,
53+
)
54+
return False
55+
#Maybe add this line if needed
56+
#self.config.set_type(system_type)
57+
return True
58+
59+
def network_check(self):
60+
is_network = self.system_json.get(SYSTEM_DESC_IS_NETWORK_MODE)
61+
is_network = (
62+
is_network.lower() == "true"
63+
if is_network is not None
64+
else False
65+
)
66+
expected_state_by_division = {"network": True, "closed": False}
67+
if self.division in expected_state_by_division:
68+
if expected_state_by_division[self.division] != is_network:
69+
self.log.error(
70+
f"{self.path} incorrect network mode (={is_network}) for division '{self.division}'"
71+
)
72+
return False
73+
return False
74+
75+
def required_fields_check(self):
76+
required_fields = SYSTEM_DESC_REQUIRED_FIELDS.copy()
77+
is_network = self.system_json.get(SYSTEM_DESC_IS_NETWORK_MODE)
78+
if is_network:
79+
required_fields += SYSTEM_DESC_REQUIRED_FIELDS_NETWORK_MODE
80+
81+
check_empty_fields = True
82+
is_valid = True
83+
for k in required_fields:
84+
if k not in self.system_json:
85+
is_valid = False
86+
self.log.error("%s, field %s is missing", self.path, k)
87+
elif (
88+
check_empty_fields
89+
and k in SYSTEM_DESC_MEANINGFUL_RESPONSE_REQUIRED_FIELDS
90+
and not self.system_json[k]
91+
):
92+
is_valid = False
93+
self.log.error(
94+
"%s, field %s requires a meaningful response but is empty", self.path, k
95+
)
96+
return is_valid
97+
98+
def submitter_check(self):
99+
if self.system_json.get("submitter").lower() != self.submitter.lower():
100+
self.log.error(
101+
"%s has submitter %s, directory has %s",
102+
self.path,
103+
self.system_json.get("submitter"),
104+
self.submitter,
105+
)
106+
return False
107+
return True
108+
109+
def division_check(self):
110+
if self.system_json.get("division").lower() != self.division.lower():
111+
self.log.error(
112+
"%s has division %s, directory has %s",
113+
self.path,
114+
self.system_json.get("division"),
115+
self.division,
116+
)
117+
return False
118+
return True

tools/submission/submission_checker/checks/systems_check.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

tools/submission/submission_checker/constants.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,10 +1025,10 @@
10251025
}
10261026

10271027
MEASUREMENTS_PATH = {
1028-
"v5.0": "{division}/{submitter}/measurements/{system}/{benchmark}/{scenario}/{system}.json",
1029-
"v5.1": "{division}/{submitter}/measurements/{system}/{benchmark}/{scenario}/{system}.json",
1030-
"v6.0": "{division}/{submitter}/results/{system}/{benchmark}/{scenario}/{system}.json",
1031-
"default": "{division}/{submitter}/results/{system}/{benchmark}/{scenario}/{system}.json",
1028+
"v5.0": "{division}/{submitter}/measurements/{system}/{benchmark}/{scenario}/{file}.json",
1029+
"v5.1": "{division}/{submitter}/measurements/{system}/{benchmark}/{scenario}/{file}.json",
1030+
"v6.0": "{division}/{submitter}/results/{system}/{benchmark}/{scenario}/measurements.json",
1031+
"default": "{division}/{submitter}/results/{system}/{benchmark}/{scenario}/measurements.json",
10321032
}
10331033

10341034
TEST01_PERF_PATH = {

tools/submission/submission_checker/loader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, root, version) -> None:
3434
self.acc_json_path = os.path.join(self.root, ACCURACY_JSON_PATH.get(version, ACCURACY_JSON_PATH["default"]))
3535
self.system_log_path = os.path.join(self.root, SYSTEM_PATH.get(version, SYSTEM_PATH["default"]))
3636

37+
3738
def load_single_log(self, path, log_type: Literal["Performance", "Accuracy", "AccuracyResult", "AccuracyJSON", "Test", "System"]):
3839
log = None
3940
if os.path.exists(path):
@@ -89,6 +90,7 @@ def load(self) -> Generator[SubmissionLogs, None, None]:
8990
"scenario": scenario,
9091
"perf_path": perf_path,
9192
"acc_path": acc_path,
93+
"system_path": system_path,
9294
"model_mapping": model_mapping,
9395
}
9496
yield SubmissionLogs(perf_log, acc_log, acc_result, acc_json, system_json, loader_data)

0 commit comments

Comments
 (0)