Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 14 additions & 1 deletion aws/lambda/pytorch-auto-revert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,17 @@ The tool also supports:
Run with `--help` for more information:
```bash
python -m pytorch_auto_revert --help
```
```

## Rendering HUD HTML

- Add `--hud-html` (optionally with a filepath) to `autorevert-checker` to dump the
run state as a HUD-style HTML grid alongside the regular ClickHouse logging:
```bash
python -m pytorch_auto_revert autorevert-checker pull trunk --hud-html results.html
```

- Render historical runs from ClickHouse by timestamp with the `hud` subcommand:
```bash
python -m pytorch_auto_revert hud "2025-09-17 20:29:15" --repo-full-name pytorch/pytorch --hud-html hud.html
```
53 changes: 27 additions & 26 deletions aws/lambda/pytorch-auto-revert/pytorch_auto_revert/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .clickhouse_client_helper import CHCliFactory
from .github_client_helper import GHClientFactory
from .testers.autorevert_v2 import autorevert_v2
from .testers.hud import run_hud
from .testers.hud import render_hud_html_from_clickhouse, write_hud_html
from .testers.restart_checker import workflow_restart_checker
from .utils import RestartAction, RevertAction

Expand Down Expand Up @@ -113,6 +113,15 @@ def get_opts() -> argparse.Namespace:
"Revert mode: skip, log (no side effects), run-notify (side effect), or run-revert (side effect)."
),
)
workflow_parser.add_argument(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this functionality should not be a flag on revert mode, instead a separate entry point that reads from the database and creates this html.

this is because I don't want to couple the autorevert logic to the html generation logic.

This is not safe for a service, it makes more sense for those to be separated entities/actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdym?

there IS a separate endpoint: hud subcommand that reads and prints from the database

the flag to the autorevert just reuses the functionality to optionally dump the results of the run as html, it's a convenience

"--hud-html",
nargs="?",
const="hud.html",
default=None,
help=(
"If set, write the run state to HUD HTML at the given path (defaults to hud.html when flag provided)."
),
)

# workflow-restart-checker subcommand
workflow_restart_parser = subparsers.add_parser(
Expand All @@ -135,35 +144,27 @@ def get_opts() -> argparse.Namespace:

# hud subcommand: generate local HTML report for signals/detections
hud_parser = subparsers.add_parser(
"hud", help="Generate local HUD-like HTML with extracted signals"
"hud", help="Render HUD HTML from a logged autorevert run state"
)
hud_parser.add_argument(
"workflows",
nargs="+",
help="Workflow name(s) to analyze - e.g. trunk pull inductor",
)
hud_parser.add_argument(
"--hours", type=int, default=24, help="Lookback window in hours (default: 24)"
"timestamp",
help="Run timestamp in UTC (e.g. '2025-09-17 20:29:15') matching misc.autorevert_state.ts",
)
hud_parser.add_argument(
"--repo-full-name",
default=os.environ.get("REPO_FULL_NAME", "pytorch/pytorch"),
help="Full repo name to filter by (owner/repo).",
dest="repo_full_name",
default=None,
help=(
"Optional repo filter (owner/repo). Required if multiple runs share the same timestamp."
),
)
hud_parser.add_argument(
"--out",
"--hud-html",
nargs="?",
const="hud.html",
default="hud.html",
help="Output HTML file path (default: hud.html)",
)
hud_parser.add_argument(
"--ignore-newer-than",
dest="ignore_newer_than",
default=None,
help=(
"Commit SHA (short or long) — drop all commits that are newer than "
"this SHA from signal detection and HUD rendering"
),
)

return parser.parse_args()

Expand Down Expand Up @@ -207,23 +208,23 @@ def main(*args, **kwargs) -> None:
)
elif opts.subcommand == "autorevert-checker":
# New default behavior under the same subcommand
autorevert_v2(
_signals, _pairs, state_json = autorevert_v2(
opts.workflows,
hours=opts.hours,
repo_full_name=opts.repo_full_name,
restart_action=(RestartAction.LOG if opts.dry_run else opts.restart_action),
revert_action=(RevertAction.LOG if opts.dry_run else opts.revert_action),
)
if opts.hud_html:
write_hud_html(state_json, opts.hud_html)
elif opts.subcommand == "workflow-restart-checker":
workflow_restart_checker(opts.workflow, commit=opts.commit, days=opts.days)
elif opts.subcommand == "hud":
# Delegate to testers.hud module
run_hud(
opts.workflows,
hours=opts.hours,
render_hud_html_from_clickhouse(
opts.timestamp,
repo_full_name=opts.repo_full_name,
out=opts.out,
ignore_newer_than=getattr(opts, "ignore_newer_than", None),
out_path=opts.hud_html,
)


Expand Down
Loading