Skip to content

feat(ci,tools): expand nightly examples suite to all 12 example workloads - #903

Closed
janzak-dev wants to merge 3 commits into
feat/nightly-examples-pipeline-basefrom
feat/nightly-examples-suite
Closed

janzak-dev wants to merge 3 commits into
feat/nightly-examples-pipeline-basefrom
feat/nightly-examples-suite

Conversation

@janzak-dev

@janzak-dev janzak-dev commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stack Navigation

  • #901 Layer 1 (Base): refactor(tools,ci): rename demo_workload_verify to simple_job_verify
  • #902 Layer 2: feat(ci,tools): add unified nightly examples e2e pipeline with simple_job baseline
  • #903 Layer 3 (Apex): feat(ci,tools): expand nightly examples suite to all 12 example workloads 👈

🏛️ Role in PR Stack Architecture

This PR serves as Layer 3 (Complete Multi-Example Suite & Dedicated Verifiers - Apex) within the 3-part nightly examples testing stack.

  • Stack Objective: Establish an automated, robust, end-to-end multi-example workload execution and validation framework running against xmc-nightly.
  • Layer 3 Role: Expands the .github/workflows/nightly-examples-e2e.yml matrix from the simple_job baseline to all 12 example workloads and introduces dedicated verifiers, JobSet topology validation, artifact payload checking, and full hermetic unit test suites.

Summary

Expands the nightly examples E2E validation matrix to cover all 12 example workloads in XMC, adding dedicated CLI verifier binaries and full unit test coverage.

Motivation & Context

  • Comprehensive E2E Coverage: With the pipeline foundation established in Layer 2, this layer plugs in the remaining 11 example workloads (init_container_job, sidecar, multipod_job, per_job_node_selector, pathways_job, chart_artifact_job, managed_xprof_artifact_job, xdash_dashboard, metrics_job, clickhouse_metrics_job, metrics_dashboard_job) into the nightly matrix runner.

Key Changes

  • CI / Workflow (.github/workflows/nightly-examples-e2e.yml):
    • Expands matrix to all 12 example workloads.
  • Validation Engine & Verifier CLIs (tools/nightly_tests/):
    • init_container_job_verify.py: Validates init container setup and execution.
    • sidecar_verify.py: Validates Kubernetes native sidecar services.
    • multipod_job_verify.py: Validates multi-pod multi-role JobSet topology.
    • per_job_node_selector_verify.py: Validates heterogeneous nodeSelector targeting per role.
    • pathways_job_verify.py: Validates Pathways TPU multi-component topologies.
    • chart_artifact_job_verify.py: Validates ChartArtifact provisioning and metric sequences.
    • managed_xprof_artifact_job_verify.py: Validates ManagedXprofArtifact records.
    • xdash_dashboard_verify.py: Validates xDash REST API definitions and chart references.
    • metrics_job_verify.py: Validates autologging for Keras, PyTorch Lightning, and custom metrics.
    • clickhouse_metrics_job_verify.py: Validates ClickHouse metrics ingestion pipeline.
    • metrics_dashboard_job_verify.py: Validates Metrics Dashboard integration.
    • xmc_entities_validator.py: Comprehensive assertions for artifacts, REST dashboards, JobSet topology, and WorkUnit states (all functions <= 25 lines).
  • Build & Tests:
    • BUILD.bazel: Registers all 12 py_binary targets and test harnesses.
    • xmc_entities_validator_test.py: Full test matrix covering all helper functions and edge cases (54 tests).
    • examples_verify_test.py: Full CLI integration tests for all 12 verifiers (26 tests).

Assumptions

None — requirements were fully specified.

Verification & Testing

  • Bazel Unit Tests: bazel test //tools/nightly_tests:all (3/3 targets passed, 83 tests passing)
  • Node Unit Tests: node --test .github/scripts/aggregate-example-results.test.js (11/11 tests passing)
  • Pre-commit Checks: ./.githooks/pre-commit check (100% clean)

TAG=agy
CONV=606f1e41-6785-4137-b85b-cd0f56237339

TAG=agy
CONV=606f1e41-6785-4137-b85b-cd0f56237339
…_job baseline

TAG=agy
CONV=606f1e41-6785-4137-b85b-cd0f56237339
…oads

TAG=agy
CONV=ecefc9c1-e07a-45e0-b05c-4a732c9545fe

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new nightly test verification scripts for XMC workloads, updates the Bazel build configurations, and enhances the xmc_entities_validator library to support artifact and dashboard validation. The review feedback focuses on improving code robustness, style, and efficiency. Key recommendations include moving the re import to the top of the file, removing redundant string decoding and URL fallbacks, adding defensive checks to prevent potential TypeError and AttributeError crashes, catching ValueError during JSON parsing of transient server responses, and leveraging the newly added resolve_dashboard_endpoint helper for better code reuse.

import logging
import os
import time
import urllib.error

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Move the re import to the top of the file to adhere to PEP 8 style guidelines regarding import placement.

Suggested change
import urllib.error
import re
import urllib.error
References
  1. PEP 8: Imports should be placed at the top of the file, after any module comments and docstrings, and before module globals and constants. (link)

Comment on lines +689 to +691
import re

t = type_name.strip()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Remove the local re import since it has been moved to the top of the file.

Suggested change
import re
t = type_name.strip()
t = type_name.strip()

"normalized_type": norm_type or "unknown",
"metric_names": metrics,
"title": title,
"url": url_str if isinstance(url_str, str) else getattr(url_str, "url", ""),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since _extract_url_artifact_details already extracts and returns the URL as a string, this conditional check and fallback are redundant. Simplify it to directly assign url_str.

Suggested change
"url": url_str if isinstance(url_str, str) else getattr(url_str, "url", ""),
"url": url_str,

headers={"Accept": "application/json", "User-Agent": "xmc-validator/1.0"},
)
with urllib.request.urlopen(req, timeout=timeout) as resp:
return json.loads(resp.read().decode("utf-8"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

In Python 3.6+, json.loads directly accepts bytes or bytearray input, making the explicit .decode("utf-8") call redundant.

Suggested change
return json.loads(resp.read().decode("utf-8"))
return json.loads(resp.read())

return [_validate_single_dashboard(base_endpoint, d) for d in norm_dashboards]
except AssertionError:
raise
except (urllib.error.HTTPError, urllib.error.URLError, OSError) as e:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If the server returns a non-JSON response (e.g., an HTML error page from a proxy or gateway), json.loads will raise a ValueError (specifically json.JSONDecodeError). Catching ValueError here ensures that such transient issues are retried instead of crashing the validator immediately.

Suggested change
except (urllib.error.HTTPError, urllib.error.URLError, OSError) as e:
except (urllib.error.HTTPError, urllib.error.URLError, OSError, ValueError) as e:

Comment on lines +122 to +123
if provided_endpoint:
ep = provided_endpoint.strip()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If provided_endpoint is a string containing only whitespace, if provided_endpoint: evaluates to True, but provided_endpoint.strip() becomes "". This leads to an invalid URL like https:// being returned. Ensure the string is non-empty after stripping.

Suggested change
if provided_endpoint:
ep = provided_endpoint.strip()
if provided_endpoint and provided_endpoint.strip():
ep = provided_endpoint.strip()

Comment on lines +97 to +101
dash_endpoint = (
common.get_flag(FLAGS, "dashboard_endpoint", None)
or os.environ.get("XMC_DASHBOARD_ENDPOINT")
or os.environ.get("DASHBOARD_ENDPOINT")
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Leverage common.resolve_dashboard_endpoint to ensure the dashboard endpoint is properly resolved and normalized, respecting all fallback environment variables (such as XMANAGER_UI_URL and XMC_DOMAIN).

Suggested change
dash_endpoint = (
common.get_flag(FLAGS, "dashboard_endpoint", None)
or os.environ.get("XMC_DASHBOARD_ENDPOINT")
or os.environ.get("DASHBOARD_ENDPOINT")
)
raw_ep = (
common.get_flag(FLAGS, "dashboard_endpoint", None)
or os.environ.get("XMC_DASHBOARD_ENDPOINT")
or os.environ.get("DASHBOARD_ENDPOINT")
or os.environ.get("XMANAGER_UI_URL")
)
if raw_ep:
dash_endpoint = common.resolve_dashboard_endpoint(raw_ep)

Comment on lines +97 to +101
dash_endpoint = (
common.get_flag(FLAGS, "dashboard_endpoint", None)
or os.environ.get("XMC_DASHBOARD_ENDPOINT")
or os.environ.get("DASHBOARD_ENDPOINT")
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Leverage common.resolve_dashboard_endpoint to ensure the dashboard endpoint is properly resolved and normalized, respecting all fallback environment variables (such as XMANAGER_UI_URL and XMC_DOMAIN).

Suggested change
dash_endpoint = (
common.get_flag(FLAGS, "dashboard_endpoint", None)
or os.environ.get("XMC_DASHBOARD_ENDPOINT")
or os.environ.get("DASHBOARD_ENDPOINT")
)
raw_ep = (
common.get_flag(FLAGS, "dashboard_endpoint", None)
or os.environ.get("XMC_DASHBOARD_ENDPOINT")
or os.environ.get("DASHBOARD_ENDPOINT")
or os.environ.get("XMANAGER_UI_URL")
)
if raw_ep:
dash_endpoint = common.resolve_dashboard_endpoint(raw_ep)

actual_job = actual_jobs.get(job_name)
if actual_job is None:
raise AssertionError(f"Job '{job_name}' missing from JobSet jobs.")
actual_ns = dict(getattr(actual_job, "node_selector", {}))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If node_selector is explicitly set to None (or is missing and defaults to None in duck-typed mock objects), calling dict(None) will raise a TypeError. Use a defensive fallback to an empty dictionary.

Suggested change
actual_ns = dict(getattr(actual_job, "node_selector", {}))
actual_ns = dict(getattr(actual_job, "node_selector", None) or {})

work_unit=raw_work_units[0],
expected_jobs=EXPECTED_JOBSET_SPECS,
)
jobset = getattr(raw_work_units[0].executable, "jobset", None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If raw_work_units[0] does not have an executable attribute (e.g., in mock or malformed objects), accessing .executable directly will raise an AttributeError. Use getattr defensively.

Suggested change
jobset = getattr(raw_work_units[0].executable, "jobset", None)
executable = getattr(raw_work_units[0], "executable", None)
jobset = getattr(executable, "jobset", None) if executable else None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant