Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 6 additions & 21 deletions tpu_raiden/benchmarks/h2d_d2h_benchmark_gating.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,14 @@ def _baselines_path():


def _opted_out():
"""Returns a tag if this change opts out of the perf floor.

In CI the decision is made by the workflow and handed down as an env var:
this binary runs under `bazel run`, whose cwd is the runfiles tree, and on
pull_request events HEAD is GitHub's synthetic merge commit -- neither can
see the CL description. The git path below is the local-run fallback.
"""
if os.environ.get('TPU_RAIDEN_PERF_GATE_OPT_OUT', '').lower() == 'true':
return _SKIP_TAGS[0]

"""True if the HEAD commit message asks to skip the perf floor for this PR."""
try:
result = subprocess.run(
['git', 'log', '-1', '--format=%B'],
cwd=os.environ.get('BUILD_WORKSPACE_DIRECTORY'),
capture_output=True, text=True, check=True,
)
except (OSError, subprocess.CalledProcessError) as e:
print(f'WARNING: unable to inspect commit message: {e}', file=sys.stderr)
msg = subprocess.run(['git', 'log', '-1', '--format=%B'],
capture_output=True, text=True).stdout.lower()
except Exception: # pylint: disable=broad-exception-caught
return None

message = result.stdout.lower()
for tag in _SKIP_TAGS:
if tag in message:
if tag in msg:
return tag
return None

Expand Down Expand Up @@ -177,7 +162,7 @@ def main(_):
print(msg + ' [report-only: "enforce": false in baselines, NOT blocking]')
return
if opt:
print(msg + f' [report-only: opt-out requested via {opt}, NOT blocking]')
print(msg + f' [report-only: {opt} in commit message, NOT blocking]')
return
print(msg + f' (to bypass, add {_SKIP_TAGS[0]} to your CL description)',
file=sys.stderr)
Expand Down
Loading