def pull_job_times_from_S3() -> Dict[str, float]: if HAVE_BOTO3: ci_job_prefix = get_stripped_CI_job() s3_reports: List["Report"] = get_previous_reports_for_branch('origin/viable/strict', ci_job_prefix) else: print('Uh oh, boto3 is not found. Either it is not installed or we failed to import s3_stat_parser.') print('If not installed, please install boto3 for automatic sharding and test categorization.') s3_reports = [] if len(s3_reports) == 0: print('Gathered no reports from S3. Please proceed without them.') return dict() return calculate_job_times(s3_reports)
def get_test_case_times() -> Dict[str, float]: reports: List[Report] = get_previous_reports_for_branch('origin/viable/strict', "") # an entry will be like ("test_doc_examples (__main__.TestTypeHints)" -> [values])) test_names_to_times: DefaultDict[str, List[float]] = defaultdict(list) for report in reports: if report.get('format_version', 1) != 2: raise RuntimeError("S3 format currently handled is version 2 only") v2report = cast(Version2Report, report) for test_file in v2report['files'].values(): for suitename, test_suite in test_file['suites'].items(): for casename, test_case in test_suite['cases'].items(): # The below attaches a __main__ as that matches the format of test.__class__ in # common_utils.py (where this data will be used), and also matches what the output # of a running test would look like. name = f'{casename} (__main__.{suitename})' succeeded: bool = test_case['status'] is None if succeeded: test_names_to_times[name].append(test_case['seconds']) return {test_case: statistics.mean(times) for test_case, times in test_names_to_times.items()}