From 2124be5caee6803d5bfe6f7cdc8e3367cb375807 Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Thu, 21 Apr 2022 10:27:37 -0700 Subject: toolchain_utils: s/Cr OS/CrOS/g Result of running `sed -ri 's/Chrom(ium|e) OS/Chrom\1OS/g' $(find -type f)`. BUG=None TEST=None Change-Id: I59be92537aa19bc989f52b585e307e76dbde401b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3600147 Reviewed-by: Manoj Gupta Commit-Queue: George Burgess Tested-by: George Burgess --- pgo_tools/monitor_pgo_profiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pgo_tools/monitor_pgo_profiles.py') diff --git a/pgo_tools/monitor_pgo_profiles.py b/pgo_tools/monitor_pgo_profiles.py index 5c17423b..e56db427 100755 --- a/pgo_tools/monitor_pgo_profiles.py +++ b/pgo_tools/monitor_pgo_profiles.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright 2020 The Chromium OS Authors. All rights reserved. +# Copyright 2020 The ChromiumOS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -- cgit v1.2.3 From 74bd380a27f4f0e8e90ff2dc1cef0b502d74961b Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Fri, 2 Sep 2022 16:59:27 -0700 Subject: Autoformat all Python code This autoformats all Python code with our new Python formatter, `black`. BUG=b:244644217 TEST=None Change-Id: I15ee49233d98fb6295c0c53c129bbf8e78e0d9ff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3877337 Tested-by: George Burgess Reviewed-by: Jordan Abrahams-Whitehead Commit-Queue: George Burgess --- pgo_tools/monitor_pgo_profiles.py | 171 ++++++++++++++++++++------------------ 1 file changed, 89 insertions(+), 82 deletions(-) (limited to 'pgo_tools/monitor_pgo_profiles.py') diff --git a/pgo_tools/monitor_pgo_profiles.py b/pgo_tools/monitor_pgo_profiles.py index e56db427..846cdc2b 100755 --- a/pgo_tools/monitor_pgo_profiles.py +++ b/pgo_tools/monitor_pgo_profiles.py @@ -12,105 +12,112 @@ import subprocess import sys from typing import List, NamedTuple, Optional, Tuple -PGO_BUILDBOT_LINK = ('https://ci.chromium.org/p/chromeos/builders/toolchain/' - 'pgo-generate-llvm-next-orchestrator') + +PGO_BUILDBOT_LINK = ( + "https://ci.chromium.org/p/chromeos/builders/toolchain/" + "pgo-generate-llvm-next-orchestrator" +) class ProfdataInfo(NamedTuple): - """Data about an llvm profdata in our gs:// bucket.""" - date: datetime.datetime - location: str + """Data about an llvm profdata in our gs:// bucket.""" + + date: datetime.datetime + location: str def parse_date(date: str) -> datetime.datetime: - time_format = '%Y-%m-%dT%H:%M:%SZ' - if not date.endswith('Z'): - time_format += '%z' - return datetime.datetime.strptime(date, time_format) + time_format = "%Y-%m-%dT%H:%M:%SZ" + if not date.endswith("Z"): + time_format += "%z" + return datetime.datetime.strptime(date, time_format) def fetch_most_recent_profdata(arch: str) -> ProfdataInfo: - result = subprocess.run( - [ - 'gsutil.py', - 'ls', - '-l', - f'gs://chromeos-toolchain-artifacts/llvm-pgo/{arch}/' - '*.profdata.tar.xz', - ], - check=True, - stdout=subprocess.PIPE, - encoding='utf-8', - ) - - # Each line will be a profdata; the last one is a summary, so drop it. - infos = [] - for rec in result.stdout.strip().splitlines()[:-1]: - _size, date, url = rec.strip().split() - infos.append(ProfdataInfo(date=parse_date(date), location=url)) - return max(infos) + result = subprocess.run( + [ + "gsutil.py", + "ls", + "-l", + f"gs://chromeos-toolchain-artifacts/llvm-pgo/{arch}/" + "*.profdata.tar.xz", + ], + check=True, + stdout=subprocess.PIPE, + encoding="utf-8", + ) + + # Each line will be a profdata; the last one is a summary, so drop it. + infos = [] + for rec in result.stdout.strip().splitlines()[:-1]: + _size, date, url = rec.strip().split() + infos.append(ProfdataInfo(date=parse_date(date), location=url)) + return max(infos) def compose_complaint( out_of_date_profiles: List[Tuple[datetime.datetime, ProfdataInfo]] ) -> Optional[str]: - if not out_of_date_profiles: - return None + if not out_of_date_profiles: + return None - if len(out_of_date_profiles) == 1: - body_lines = ['1 profile is out of date:'] - else: - body_lines = [f'{len(out_of_date_profiles)} profiles are out of date:'] + if len(out_of_date_profiles) == 1: + body_lines = ["1 profile is out of date:"] + else: + body_lines = [f"{len(out_of_date_profiles)} profiles are out of date:"] - for arch, profdata_info in out_of_date_profiles: - body_lines.append( - f'- {arch} (most recent profile was from {profdata_info.date} at ' - f'{profdata_info.location!r})') + for arch, profdata_info in out_of_date_profiles: + body_lines.append( + f"- {arch} (most recent profile was from {profdata_info.date} at " + f"{profdata_info.location!r})" + ) - body_lines.append('\n') - body_lines.append( - 'PTAL to see if the llvm-pgo-generate bots are functioning normally. ' - f'Their status can be found at {PGO_BUILDBOT_LINK}.') - return '\n'.join(body_lines) + body_lines.append("\n") + body_lines.append( + "PTAL to see if the llvm-pgo-generate bots are functioning normally. " + f"Their status can be found at {PGO_BUILDBOT_LINK}." + ) + return "\n".join(body_lines) def main() -> None: - logging.basicConfig(level=logging.INFO) - - parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument( - '--max_age_days', - # These builders run ~weekly. If we fail to generate two in a row, - # something's probably wrong. - default=15, - type=int, - help='How old to let profiles get before complaining, in days', - ) - args = parser.parse_args() - - now = datetime.datetime.now() - logging.info('Start time is %r', now) - - max_age = datetime.timedelta(days=args.max_age_days) - out_of_date_profiles = [] - for arch in ('arm', 'arm64', 'amd64'): - logging.info('Fetching most recent profdata for %r', arch) - most_recent = fetch_most_recent_profdata(arch) - logging.info('Most recent profdata for %r is %r', arch, most_recent) - - age = now - most_recent.date - if age >= max_age: - out_of_date_profiles.append((arch, most_recent)) - - complaint = compose_complaint(out_of_date_profiles) - if complaint: - logging.error('%s', complaint) - sys.exit(1) - - logging.info('Nothing seems wrong') - - -if __name__ == '__main__': - sys.exit(main()) + logging.basicConfig(level=logging.INFO) + + parser = argparse.ArgumentParser( + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter, + ) + parser.add_argument( + "--max_age_days", + # These builders run ~weekly. If we fail to generate two in a row, + # something's probably wrong. + default=15, + type=int, + help="How old to let profiles get before complaining, in days", + ) + args = parser.parse_args() + + now = datetime.datetime.now() + logging.info("Start time is %r", now) + + max_age = datetime.timedelta(days=args.max_age_days) + out_of_date_profiles = [] + for arch in ("arm", "arm64", "amd64"): + logging.info("Fetching most recent profdata for %r", arch) + most_recent = fetch_most_recent_profdata(arch) + logging.info("Most recent profdata for %r is %r", arch, most_recent) + + age = now - most_recent.date + if age >= max_age: + out_of_date_profiles.append((arch, most_recent)) + + complaint = compose_complaint(out_of_date_profiles) + if complaint: + logging.error("%s", complaint) + sys.exit(1) + + logging.info("Nothing seems wrong") + + +if __name__ == "__main__": + sys.exit(main()) -- cgit v1.2.3 From fdcd39d5de4bd61cee94cf1e26416838d23092b8 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 13 Sep 2022 14:19:58 -0400 Subject: Update license boilerplate text in source code files Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icb42e5012a87920c2cd13b666fb3e55e7e4fb3b8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3891080 Auto-Submit: Mike Frysinger Tested-by: Mike Frysinger Commit-Queue: George Burgess Reviewed-by: George Burgess --- pgo_tools/monitor_pgo_profiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pgo_tools/monitor_pgo_profiles.py') diff --git a/pgo_tools/monitor_pgo_profiles.py b/pgo_tools/monitor_pgo_profiles.py index 846cdc2b..2c54ee80 100755 --- a/pgo_tools/monitor_pgo_profiles.py +++ b/pgo_tools/monitor_pgo_profiles.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright 2020 The ChromiumOS Authors. All rights reserved. +# Copyright 2020 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -- cgit v1.2.3