Skip to content

Commit 4bf9fc6

Browse files
🔄 synced file(s) with mlcommons/power-dev (#2125)
* 🔄 synced local 'tools/submission/power/power_checker.py' with remote 'compliance/check.py' * 🔄 synced local 'tools/submission/power/sources_checksums.json' with remote 'compliance/sources_checksums.json' --------- Co-authored-by: mlcommons-bot <null>
1 parent f4a195e commit 4bf9fc6

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

tools/submission/power/power_checker.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,13 @@ def get_command_by_value_and_number(cmd: str, number: int) -> Optional[str]:
262262
initial_amps = get_initial_range(1, msgs[2]["reply"])
263263
initial_volts = get_initial_range(3, msgs[2]["reply"])
264264

265-
initial_amps_command = get_command_by_value_and_number("SR,A", 3)
265+
# sometimes the SR,A,Auto comes from 3rd or 4th response
266+
initial_amps_command_3 = get_command_by_value_and_number("SR,A", 3)
267+
initial_amps_command_4 = get_command_by_value_and_number("SR,A", 4)
266268
initial_volts_command = get_command_by_value_and_number("SR,V", 3)
267-
268-
assert (
269-
initial_amps_command == f"SR,A,{initial_amps}"
270-
), f"Do not set Amps range as initial. Expected 'SR,A,{initial_amps}', got {initial_amps_command!r}."
269+
assert (initial_amps_command_3 == f"SR,A,{initial_amps}") or (
270+
initial_amps_command_4 == f"SR,A,{initial_amps}"
271+
), f"Do not set Amps range as initial. Expected 'SR,A,{initial_amps}', got {initial_amps_command_3!r} and {initial_amps_command_4!r}."
271272
assert (
272273
initial_volts_command == f"SR,V,{initial_volts}"
273274
), f"Do not set Volts range as initial. Expected 'SR,V,{initial_volts}', got {initial_volts_command!r}."
@@ -706,33 +707,33 @@ def check_ptd_config(server_sd: SessionDescriptor) -> None:
706707
"""
707708
ptd_config = server_sd.json_object["ptd_config"]
708709

709-
dev_num = ptd_config["device_type"]
710-
assert (
711-
dev_num in SUPPORTED_MODEL.values()
712-
), f"Device number {dev_num} is not supported. Supported numbers are " + ", ".join(
713-
[str(i) for i in set(SUPPORTED_MODEL.values())]
714-
)
710+
for analyzer in ptd_config:
711+
dev_num = analyzer["device_type"]
712+
assert dev_num in SUPPORTED_MODEL.values(), (
713+
f"Device number {dev_num} is not supported. Supported numbers are "
714+
+ ", ".join([str(i) for i in set(SUPPORTED_MODEL.values())])
715+
)
715716

716-
if dev_num == 77:
717-
channels = ""
718-
command = ptd_config["command"]
717+
if dev_num == 77:
718+
channels = ""
719+
command = analyzer["command"]
719720

720-
for i in range(len(command)):
721-
if command[i] == "-c":
722-
channels = command[i + 1]
723-
break
721+
for i in range(len(command)):
722+
if command[i] == "-c":
723+
channels = command[i + 1]
724+
break
724725

725-
dev_name = ""
726-
for name, num in SUPPORTED_MODEL.items():
727-
if num == dev_num:
728-
dev_name = name
729-
break
726+
dev_name = ""
727+
for name, num in SUPPORTED_MODEL.items():
728+
if num == dev_num:
729+
dev_name = name
730+
break
730731

731-
assert (
732-
len(channels.split(",")) == 2
733-
and ptd_config["channel"]
734-
and len(ptd_config["channel"]) == 2
735-
), f"Expected multichannel mode for {dev_name}, but got 1-channel."
732+
assert (
733+
len(channels.split(",")) == 2
734+
and analyzer["channel"]
735+
and len(analyzer["channel"]) == 2
736+
), f"Expected multichannel mode for {dev_name}, but got 1-channel."
736737

737738

738739
def debug_check(server_sd: SessionDescriptor) -> None:

tools/submission/power/sources_checksums.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
"tests/unit/test_server.py": "948c1995d4008bc2aa6c4046a34ffa3858d6d671",
1717
"tests/unit/test_source_hashes.py": "00468a2907583c593e6574a1f6b404e4651c221a"
1818
}
19-
]
19+
]

0 commit comments

Comments
 (0)