Skip to content
Merged
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
8 changes: 8 additions & 0 deletions release/portal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ cannot read the state, scans the release as before.
| `nightly_binaries` | `repo`, `branch` | the wheel, libtorch and docker builds of the latest finished nightly of `repo` are green (below) |
| `viable_strict_lag` | `repo`, `branch`, `base`, `max_hours` | `branch` is less than `max_hours` hours behind `base` by the commit time of their heads (below) |
| `rc_binaries` | `repo` | the wheel, libtorch and docker builds of the newest release candidate tag of the release are green (below) |
| `docs_build` | `repo`, `workflow`, `docs_repo`, `docs_branch`, `docs_path` | `workflow` is green on the commit of the newest release candidate tag, and `docs_path` exists on `docs_branch` of `docs_repo` (below) |
| `triton_release_branch` | none | `triton-lang/triton` has the release branch `release/X.Y.x` of `versions.triton`, and the triton pin of pytorch is on it (below) |
| `pypi_release` | `package`, `version` | `version` of the package is on PyPI |
| `dev_discuss_post` | `title_starts_with` (a prefix or a list of them, or one of those per release type), `carries_dates` (optional) | a post whose title starts with one of the prefixes exists in the Release Announcements category of dev-discuss (below) |
Expand Down Expand Up @@ -225,6 +226,13 @@ libtorch and docker builds all ran and none failed, and blocked otherwise, so a
shows in red on the board. It is RC-scoped: the row is the newest candidate's, and a new candidate
starts the step again.

`docs_build` (step 2.12) is checked by the same script, for the same newest release candidate.
The tag does not start the docs workflow; the push of its commit to the release branch does, so
the runs read are the push runs of `workflow` (`docs-build.yml`) whose head is the tag's commit.
The step is in progress while that run is going, blocked when it failed, in progress when it is
green but `docs_path` (`{minor}`, e.g. `2.16`) is not yet on `docs_branch` (`site`) of
`docs_repo` (`pytorch/docs`), and done when both hold.

A **blocked** step is the red flag: the collector writes it with the blocking flag, the board
counts it in the blocking steps, shows the row in red and shows the release as blocked. A step
with `blocks_until_branch_cut: true` (needs `types: [minor]`; steps 1.4 and 1.5) stops being
Expand Down
29 changes: 29 additions & 0 deletions release/portal/config/releases/2.17.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Per-release file for PyTorch 2.17.0. The steps are the shared ones in ../steps.yml; add
# `remove`, `override` or `add` here only when this release's process differs (see
# release/portal/README.md).
#
# `type`, `branch`, the milestone, the tracker issue and the validation issue are not
# written here: the first two follow from the version and the rest are found on GitHub
# by the rules under `discovery` in steps.yml.
#
# `dates` are the PLANNED dates, from the 2.17 release milestones schedule:
# M1 release announcement Mon Jan 4, 2027
# M2 land target PRs Fri Jan 29, 2027
# M3.1 release branch cut Feb 1 - 3, 2027 -> branch_cut 2027-02-01
# M4 branch finalized, final RC produced Tue Feb 16, 2027 -> final_rc 2027-02-16
# M4.1 tutorial drafts, external content Feb 17 & 19, 2027
# M6 release day Wed Feb 24, 2027 -> ga 2027-02-24
# M4 moved from Mon Feb 15 to Tue Feb 16 because Feb 15 is Presidents' Day. A
# multi-day milestone is dated by its first day.
#
# `versions`: 2.17.0 ships triton 3.10.0. torchvision and torchaudio are not decided yet,
# so they are left out.
release: "2.17.0"

versions:
triton: "3.10.0"

dates:
branch_cut: 2027-02-01
final_rc: 2027-02-16
ga: 2027-02-24
4 changes: 1 addition & 3 deletions release/portal/config/steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,9 @@ steps:
name: Docs build for the RC
tier: A
owner: docs-team
# The preview URL is shared across RCs and cannot identify a particular build.
informational: true
rc_scoped: true
depends_on: ["2.1"]
check: {type: url_exists, url: "https://docs-preview.pytorch.org/pytorch/pytorch/{minor}"}
check: {type: docs_build, repo: pytorch/pytorch, workflow: docs-build.yml, docs_repo: pytorch/docs, docs_branch: site, docs_path: "{minor}"}

- id: "2.13"
phase: 2
Expand Down
123 changes: 119 additions & 4 deletions tools/analytics/nightly_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- `rc_binaries`: the same wheel, libtorch and docker builds for the newest release candidate
of the release (the runs of its v<version>-rc<N> tag, which is a commit of the release
branch, as https://hud.pytorch.org/hud/pytorch/pytorch/release%2F2.15/1 shows them).
- `docs_build`: whether the docs workflow is green on the commit of the newest release
candidate, and the versioned docs of the release are in the docs site repo.

The nightly and viable/strict are one branch for every release, so each is read once and
written for every release in flight that is before its branch cut (release/X.Y does not exist yet). Each run records the
Expand Down Expand Up @@ -45,6 +47,7 @@

from dev_discuss_scan import github_get, releases_in_flight # noqa: E402
from github_analyze import ( # noqa: E402
fill_step_template,
insert_clickhouse_rows,
workflow_run_info,
write_step_summary,
Expand All @@ -55,6 +58,7 @@
VIABLE_STRICT_CHECK_TYPE = "viable_strict_lag"
RC_CHECK_TYPE = "rc_binaries"
WORKFLOW_RUN_CHECK_TYPE = "github_workflow_run"
DOCS_CHECK_TYPE = "docs_build"
DOCKER_WORKFLOW = ".github/workflows/docker-release.yml"
# The workflows that build the binaries, on the nightly branch and on a release candidate tag
# (a tag also starts others, like the builds of the manywheel docker images, which are not
Expand Down Expand Up @@ -577,6 +581,92 @@ def rc_step_rows(
return rows


def docs_runs(repo: str, workflow: str, sha: str) -> List[Dict[str, Any]]:
"""The runs of one workflow started by the push of a commit."""
return github_get(
f"repos/{repo}/actions/workflows/{quote(workflow, safe='')}/runs?event=push"
f"&head_sha={sha}&per_page={RUNS_PER_PAGE}"
)["workflow_runs"]


def docs_published(repo: str, branch: str, path: str) -> bool:
"""Whether the path exists on the branch of the docs site repo."""
found = github_get(
f"repos/{repo}/contents/{quote(path)}?ref={quote(branch, safe='')}",
allow_404=True,
)
return bool(found)


def docs_build_result(
check: Dict[str, Any],
tag: str,
runs: List[Dict[str, Any]],
published: bool,
) -> Tuple[str, str, str, Dict[str, Any]]:
"""
The docs workflow on the commit of a release candidate tag, and the release's docs on
the docs site. The tag itself does not start the workflow; the push of its commit to
the release branch does.
"""
workflow = check["workflow"]
site = f"https://github.com/{check['docs_repo']}/tree/{check['docs_branch']}/{check['docs_path']}"
details: Dict[str, Any] = {"workflow": workflow, "tag": tag, "docs": site}
runs = [r for r in runs if r.get("conclusion") not in WORKFLOW_IGNORED]
if not runs:
return "todo", f"no {workflow} run on {tag} yet", "", details
run = max(runs, key=run_started_at)
details.update(
run_id=run["id"],
status=run.get("status"),
conclusion=run.get("conclusion"),
published=published,
)
on = f"{workflow} run {run['id']} on {tag}"
if run.get("status") != "completed":
return "in_progress", f"{on} is {run.get('status')}", run["html_url"], details
if run.get("conclusion") not in WORKFLOW_GREEN:
return "blocked", f"{on} {run.get('conclusion')}", run["html_url"], details
if not published:
return "in_progress", f"{on} green; {site} not found", run["html_url"], details
return "done", f"{on} green; {site} exists", site, details


def docs_step_rows(
release: str,
config: Dict[str, Any],
result_for: Callable[
[Dict[str, Any]], Optional[Tuple[str, Tuple[str, str, str, Dict]]]
],
config_sha: str,
run_id: str,
run_url: str,
observed_at: datetime,
) -> List[Dict[str, Any]]:
"""One row per docs_build step, for the newest release candidate; none before the first."""
rows = []
for step in config["steps"]:
if step["check"]["type"] != DOCS_CHECK_TYPE:
continue
found = result_for(step["check"])
if found is not None:
rc, result = found
rows.append(
step_row(
release,
step["id"],
DOCS_CHECK_TYPE,
result,
config_sha,
run_id,
run_url,
observed_at,
rc,
)
)
return rows


def branch_head(repo: str, branch: str) -> Dict[str, Any]:
"""The sha and commit time of the head of a branch."""
commit = github_get(f"repos/{repo}/commits/{quote(branch, safe='/')}")
Expand Down Expand Up @@ -650,9 +740,14 @@ def scan_release(
workflow_needs_ga = any(
step.get("window", {}).get("closes") == "ga" for step in workflow_steps
)
if not (before_cut or RC_CHECK_TYPE in types or workflow_checks):
if not (
before_cut
or RC_CHECK_TYPE in types
or DOCS_CHECK_TYPE in types
or workflow_checks
):
print(
f"{release} has no nightly, viable/strict, release candidate or workflow step"
f"{release} has no nightly, viable/strict, release candidate, docs or workflow step"
)
return True
branch_cut = (
Expand Down Expand Up @@ -714,7 +809,12 @@ def newest_candidate(repo: str, version: str) -> Optional[Dict[str, Any]]:
f"{quote(config['branch'], safe='')}/1?per_page=50",
)
result[3]["rc"] = rc
candidate_cache[key] = {"rc": rc, "tag": tag, "result": result}
candidate_cache[key] = {
"rc": rc,
"tag": tag,
"sha": sha,
"result": result,
}
return candidate_cache[key]

def rc_for(
Expand All @@ -726,6 +826,20 @@ def rc_for(
return None
return latest["rc"], latest["result"]

def docs_for(
check: Dict[str, Any],
) -> Optional[Tuple[str, Tuple[str, str, str, Dict[str, Any]]]]:
latest = newest_candidate(check["repo"], release)
if latest is None:
return None
docs_path = fill_step_template(check["docs_path"], release, config["branch"])
check = {**check, "docs_path": docs_path}
runs = docs_runs(check["repo"], check["workflow"], latest["sha"])
published = docs_published(
check["docs_repo"], check["docs_branch"], check["docs_path"]
)
return latest["rc"], docs_build_result(check, latest["tag"], runs, published)

workflow_cache: Dict[Tuple[str, str, str], List[Dict[str, Any]]] = {}

def workflow_runs_for(check: Dict[str, Any]) -> List[Dict[str, Any]]:
Expand All @@ -747,6 +861,7 @@ def workflow_runs_for(check: Dict[str, Any]) -> List[Dict[str, Any]]:
release, config, result_for, *common
) + viable_strict_step_rows(release, config, viable_strict_for, *common)
rows += rc_step_rows(release, config, rc_for, *common)
rows += docs_step_rows(release, config, docs_for, *common)
if workflow_checks:
workflow_config = {**config, "steps": workflow_steps}
rows += workflow_step_rows(
Expand Down Expand Up @@ -808,7 +923,7 @@ def main(argv: Optional[List[str]] = None) -> int:
finally:
print("::endgroup::")
write_step_summary(
"Nightly binaries, viable/strict, release candidate binaries and workflow runs",
"Nightly binaries, viable/strict, release candidate binaries and docs, and workflow runs",
summary_rows,
args.write_to_clickhouse,
failed_job_lines(summary_rows),
Expand Down
9 changes: 9 additions & 0 deletions tools/torchci/release_portal_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
"crcr_summary": {"required": set(), "optional": set()},
"nightly_binaries": {"required": {"repo", "branch"}, "optional": set()},
"rc_binaries": {"required": {"repo"}, "optional": set()},
"docs_build": {
"required": {"repo", "workflow", "docs_repo", "docs_branch", "docs_path"},
"optional": set(),
},
"viable_strict_lag": {
"required": {"repo", "branch", "base", "max_hours"},
"optional": set(),
Expand Down Expand Up @@ -283,6 +287,11 @@ def one_of(key: str, allowed: tuple) -> None:
repo = check.get("repo")
if "repo" in check and not (isinstance(repo, str) and "/" in repo):
errors.append(f"{where}: check rc_binaries `repo` must be owner/name")
elif ctype == "docs_build":
for key in ("repo", "docs_repo"):
value = check.get(key)
if key in check and not (isinstance(value, str) and "/" in value):
errors.append(f"{where}: check docs_build `{key}` must be owner/name")
elif ctype == "viable_strict_lag":
for key in ("repo", "branch", "base"):
if key in check and not (isinstance(check[key], str) and check[key]):
Expand Down
107 changes: 107 additions & 0 deletions tools/torchci/tests/test_nightly_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "analytics"))

from analytics.nightly_scan import ( # noqa: E402
docs_build_result,
docs_published,
docs_runs,
docs_step_rows,
failed_job_lines,
job_category,
JOBS_PER_PAGE,
Expand Down Expand Up @@ -855,7 +859,110 @@ def test_a_run_with_a_whole_number_of_pages_ends_on_an_empty_one(self):
self.assertEqual(len(urls), 3)


DOCS_TAG = "v2.16.0-rc2"
DOCS_CHECK = {
"type": "docs_build",
"repo": "pytorch/pytorch",
"workflow": "docs-build.yml",
"docs_repo": "pytorch/docs",
"docs_branch": "site",
"docs_path": "2.16",
}
DOCS_SITE = "https://github.com/pytorch/docs/tree/site/2.16"


class TestDocsBuild(TestCase):
def docs(self, runs, published=True):
return docs_build_result(DOCS_CHECK, DOCS_TAG, runs, published)

def test_done_when_green_and_published(self):
status, text, url, details = self.docs(
[workflow_run(7, "2026-12-03T00:26:50Z", "success")]
)
self.assertEqual(status, "done")
self.assertIn(f"run 7 on {DOCS_TAG} green", text)
self.assertEqual(url, DOCS_SITE)
self.assertEqual((details["run_id"], details["published"]), (7, True))

def test_green_but_not_published_is_in_progress(self):
status, text, url, _ = self.docs(
[workflow_run(7, "2026-12-03T00:26:50Z", "success")], published=False
)
self.assertEqual(status, "in_progress")
self.assertIn(f"{DOCS_SITE} not found", text)
self.assertEqual(url, "https://github.com/actions/runs/7")

def test_a_failed_run_is_blocked(self):
status, text, _, _ = self.docs(
[workflow_run(7, "2026-12-03T00:26:50Z", "failure")]
)
self.assertEqual(status, "blocked")
self.assertIn("failure", text)

def test_a_running_run_is_in_progress(self):
running = workflow_run(7, "2026-12-03T00:26:50Z", None, status="in_progress")
self.assertEqual(self.docs([running])[0], "in_progress")

def test_the_latest_run_wins_and_cancelled_runs_are_ignored(self):
runs = [
workflow_run(6, "2026-12-03T00:00:00Z", "failure"),
workflow_run(7, "2026-12-03T01:00:00Z", "success"),
workflow_run(8, "2026-12-03T02:00:00Z", "cancelled"),
]
status, _, _, details = self.docs(runs)
self.assertEqual((status, details["run_id"]), ("done", 7))

def test_no_run_is_todo(self):
status, text, url, _ = self.docs(
[workflow_run(8, "2026-12-03T02:00:00Z", "cancelled")]
)
self.assertEqual((status, url), ("todo", ""))
self.assertIn(f"no docs-build.yml run on {DOCS_TAG}", text)

def test_runs_are_the_push_runs_of_the_commit(self):
with mock.patch(
"analytics.nightly_scan.github_get", return_value={"workflow_runs": []}
) as get:
docs_runs("pytorch/pytorch", "docs-build.yml", "c" * 40)
url = get.call_args.args[0]
self.assertIn("actions/workflows/docs-build.yml/runs?event=push", url)
self.assertIn(f"head_sha={'c' * 40}", url)

def test_published_reads_the_path_on_the_site_branch(self):
with mock.patch(
"analytics.nightly_scan.github_get",
side_effect=[[{"name": "index.html"}], None],
) as get:
self.assertTrue(docs_published("pytorch/docs", "site", "2.16"))
self.assertFalse(docs_published("pytorch/docs", "site", "2.17"))
self.assertEqual(
get.call_args_list[0].args[0], "repos/pytorch/docs/contents/2.16?ref=site"
)
self.assertTrue(get.call_args_list[0].kwargs["allow_404"])

def test_the_row_is_rc_scoped_and_none_before_the_first_candidate(self):
config = {"steps": [{"id": "2.12", "check": DOCS_CHECK}]}

def rows(found):
return docs_step_rows(
"2.16.0", config, lambda check: found, "0" * 40, "1-1", "", NOW
)

blocked = rows(("rc2", ("blocked", "failure", "", {})))
self.assertEqual(
{k: blocked[0][k] for k in ("step_id", "rc", "blocking", "check_type")},
{"step_id": "2.12", "rc": "rc2", "blocking": 1, "check_type": "docs_build"},
)
self.assertEqual(rows(None), [])


class TestConfig(TestCase):
def test_step_2_12_checks_the_docs_of_the_release_candidate(self):
steps = {s["id"]: s for s in cfg.load_resolved("2.16.0")["steps"]}
self.assertEqual(steps["2.12"]["check"], {**DOCS_CHECK, "docs_path": "{minor}"})
self.assertTrue(steps["2.12"]["rc_scoped"])
self.assertFalse(steps["2.12"].get("informational", False))

def test_workflow_checks_follow_the_release_branch(self):
steps = {step["id"]: step for step in cfg.load_resolved("2.16.0")["steps"]}
for step_id in ("2.5", "2.6", "3.4"):
Expand Down
Loading
Loading