15
15
# =============================================================================
16
16
17
17
from collections import OrderedDict
18
- from datetime import datetime , timezone
18
+ from datetime import datetime , timezone , timedelta
19
19
from typing import Dict , List , Tuple , Any , Optional , Callable
20
20
import argparse
21
21
import hashlib
@@ -84,7 +84,7 @@ class CheckerWarning(Exception):
84
84
re .compile (r"Uncertainty \d+.\d+%, which is above 1.00% limit for the last sample!" )
85
85
]
86
86
87
- TIME_DELTA_TOLERANCE = 500 # in milliseconds
87
+ TIME_DELTA_TOLERANCE = 800 # in milliseconds
88
88
89
89
90
90
def _normalize (path : str ) -> str :
@@ -395,6 +395,10 @@ def get_avg_power(power_path: str, run_path: str) -> Tuple[float, float]:
395
395
os .path .join (path , os .path .basename (run_path )), client_sd
396
396
)
397
397
398
+ # convert to UTC
399
+ power_begin = datetime .fromtimestamp (power_begin , tz = timezone .utc )
400
+ power_end = datetime .fromtimestamp (power_end , tz = timezone .utc )
401
+
398
402
detail_log_fname = os .path .join (run_path , "mlperf_log_detail.txt" )
399
403
datetime_format = "%m-%d-%Y %H:%M:%S.%f"
400
404
@@ -406,7 +410,7 @@ def get_avg_power(power_path: str, run_path: str) -> Tuple[float, float]:
406
410
for line in f :
407
411
timestamp = (
408
412
datetime .strptime (line .split ("," )[1 ], datetime_format )
409
- ).timestamp ( )
413
+ ).replace ( tzinfo = timezone . utc )
410
414
if timestamp > power_begin and timestamp < power_end :
411
415
cpower = float (line .split ("," )[3 ])
412
416
cpf = float (line .split ("," )[9 ])
@@ -596,13 +600,13 @@ def find_error_or_warning(reg_exp: str, line: str, error: bool) -> None:
596
600
problem_line = re .search (reg_exp , line )
597
601
598
602
if problem_line and problem_line .group (0 ):
599
- log_time = get_time_from_line (line , date_regexp , file_path , timezone_offset )
603
+ log_time = get_time_from_line (line , date_regexp , file_path , 0 )
600
604
if start_ranging_time is None or stop_ranging_time is None :
601
605
assert False , "Can not find ranging time in ptd_logs.txt."
602
606
if error :
603
607
if problem_line .group (0 ).strip () in COMMON_ERROR_TESTING :
604
608
raise CheckerWarning (
605
- f"{ line .strip ()!r} in ptd_log.txt during testing stage but it is accepted. Treated as WARNING"
609
+ f"{ line .strip (). replace ( 'ERROR' , 'Warning' ) !r} in ptd_log.txt during testing stage but it is accepted. Treated as WARNING"
606
610
)
607
611
assert (
608
612
start_ranging_time < log_time < stop_ranging_time
@@ -614,7 +618,7 @@ def find_error_or_warning(reg_exp: str, line: str, error: bool) -> None:
614
618
for common_ranging_error in COMMON_ERROR_RANGING
615
619
):
616
620
raise CheckerWarning (
617
- f"{ line .strip ()!r} in ptd_log.txt during ranging stage. Treated as WARNING"
621
+ f"{ line .strip (). replace ( 'ERROR' , 'Warning' ) !r} in ptd_log.txt during ranging stage. Treated as WARNING"
618
622
)
619
623
else :
620
624
if (
@@ -653,12 +657,12 @@ def get_msg_without_time(line: str) -> Optional[str]:
653
657
continue
654
658
if (not start_ranging_time ) and (start_ranging_line == msg ):
655
659
start_ranging_time = get_time_from_line (
656
- line , date_regexp , file_path , timezone_offset
660
+ line , date_regexp , file_path , 0 # timezone_offset
657
661
)
658
662
if (not stop_ranging_time ) and bool (start_ranging_time ):
659
663
if ": Completed test" == msg :
660
664
stop_ranging_time = get_time_from_line (
661
- line , date_regexp , file_path , timezone_offset
665
+ line , date_regexp , file_path , 0 # timezone_offset
662
666
)
663
667
break
664
668
@@ -673,7 +677,7 @@ def get_msg_without_time(line: str) -> Optional[str]:
673
677
try :
674
678
log_time = None
675
679
log_time = get_time_from_line (
676
- line , date_regexp , file_path , timezone_offset
680
+ line , date_regexp , file_path , 0 # timezone_offset
677
681
)
678
682
except LineWithoutTimeStamp :
679
683
assert (
0 commit comments