diff options
author | Usta Shrestha <usta@google.com> | 2023-02-17 17:09:12 -0500 |
---|---|---|
committer | Usta Shrestha <usta@google.com> | 2023-02-21 14:37:43 -0500 |
commit | a96677dcdd02670ac868ce1613cd6508f34aa64e (patch) | |
tree | 78288215cf0b5fd6ce4e18f1c1e277fe52999614 | |
parent | e0963a6e6f04c44ed535f8b470ee89194951a24b (diff) | |
download | bazel-a96677dcdd02670ac868ce1613cd6508f34aa64e.tar.gz |
skip over unavailable data
Test: run without params and run with params
Bug: NA
Change-Id: I2f39a48bf4183ef244f3b1bb659adafd108bc401
-rwxr-xr-x | scripts/incremental_build/incremental_build.py | 8 | ||||
-rwxr-xr-x | scripts/incremental_build/perf_metrics.py | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/scripts/incremental_build/incremental_build.py b/scripts/incremental_build/incremental_build.py index 7a83318b..ba5f978d 100755 --- a/scripts/incremental_build/incremental_build.py +++ b/scripts/incremental_build/incremental_build.py @@ -93,6 +93,8 @@ def _build(user_input: ui.UserInput, logfile: Path) -> (int, dict[str, any]): ninja_log_file = util.get_out_dir().joinpath('.ninja_log') def get_action_count() -> int: + if not ninja_log_file.exists(): + return 0 with open(ninja_log_file, 'r') as ninja_log: # subtracting 1 to account for "# ninja log v5" in the first line return sum(1 for _ in ninja_log) - 1 @@ -109,11 +111,9 @@ def _build(user_input: ui.UserInput, logfile: Path) -> (int, dict[str, any]): stdout=f, stderr=f) with open(logfile, mode='w') as f: - if ninja_log_file.exists(): + action_count_before = get_action_count() + if action_count_before > 0: recompact_ninja_log() - action_count_before = get_action_count() - else: - action_count_before = 0 f.write(f'Command: {cmd}\n') f.write(f'Environment Variables:\n{textwrap.indent(env_str, " ")}\n\n\n') f.flush() diff --git a/scripts/incremental_build/perf_metrics.py b/scripts/incremental_build/perf_metrics.py index 90000259..0ee4b253 100755 --- a/scripts/incremental_build/perf_metrics.py +++ b/scripts/incremental_build/perf_metrics.py @@ -206,7 +206,10 @@ def _get_column_headers(rows: list[Row], allow_cycles: bool) -> list[str]: def get_build_info_and_perf(d: Path) -> dict[str, any]: perf = read_pbs(d) - with open(d.joinpath(util.BUILD_INFO_JSON), 'r') as f: + build_info_json = d.joinpath(util.BUILD_INFO_JSON) + if not build_info_json.exists(): + return perf + with open(build_info_json, 'r') as f: build_info = json.load(f) return build_info | perf |