Skip to content

feat(ci,tools): add unified nightly examples e2e pipeline with simple_job baseline - #897

Closed
janzak-dev wants to merge 2 commits into
mainfrom
feat/nightly-examples-pipeline-base
Closed

janzak-dev wants to merge 2 commits into
mainfrom
feat/nightly-examples-pipeline-base

Conversation

@janzak-dev

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

Copy link
Copy Markdown
Collaborator

Summary

Adds the unified nightly examples E2E validation pipeline foundation (.github/workflows/nightly-examples-e2e.yml) and baseline multi-unit job validator (tools/nightly_tests/simple_job_verify.py).

📚 Stack Navigation

Layer PR / Branch Role & Status
Layer 1 PR #897 (feat/nightly-examples-pipeline-base) 👉 Unified Pipeline & simple_job Baseline (This PR)
Layer 2 PR #898 (feat/nightly-examples-suite) Expand Suite to All 12 Example Workloads 👆

Motivation & Context

  • Consolidated CI Runner Efficiency: Adopting the streamlined unified action pattern from PR refactor(ci): consolidate demo workload launch and verification into unified nightly workflow #895 eliminates redundant runner setup and executes workload submission and verification within a single matrix job.
  • Incremental Foundation: Introducing the nightly pipeline with only simple_job keeps the initial PR small (<300 prod lines) and provides a clean, extensible pattern for subsequent example additions.

Key Changes

  • CI / Workflow (.github/workflows/nightly-examples-e2e.yml):
    • Sets up single-action unified matrix job run-and-verify-examples configured for workflow_dispatch and nightly cron schedule.
    • Implements matrix runner with simple_job baseline executing via virtualenv python3 -m <verify_module>.
  • Validation Engine (tools/nightly_tests/):
    • simple_job_verify.py: 100% Protobuf spec assertions for simple_job (verifies Priority HIGH, cpu-queue, worker naming demo-worker-1..3, replicas 1, CPU 500m, memory 512 MiB, tags, notes, completed status).
    • xmc_entities_validator.py: Decomposed foundational gRPC validator utilities (all functions <= 25 lines).
    • BUILD.bazel: Adds Bazel py_binary and py_test targets for simple_job_verify and common dependencies.
    • examples_verify_test.py & common_test.py: Hermetic unit tests verifying CLI arguments and execution flows.

Assumptions

None — requirements were fully specified.

Verification & Testing

  • Bazel Unit Tests: bazel test //tools/nightly_tests:all (3/3 targets passed, 83 tests passing)
  • Pre-commit Checks: ./.githooks/pre-commit check (100% clean)

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

@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 a new validation script simple_job_verify.py and comprehensive helper functions in xmc_entities_validator.py to verify simple multi-unit job workloads in XMC, alongside corresponding unit tests. Feedback focuses on improving robustness and logging practices: asserting the expected work unit count during spec validation to prevent silent bypasses, validating that expected_work_units is positive, raising a TypeError for unsupported types in container and spec validations, and replacing direct print statements with the standard logging module in library code.

Comment on lines +118 to +122
req = xmc_entities_validator._make_req("ListWorkUnitsRequest", parent=f"experiments/{xid}")
raw_work_units = list(getattr(stub.ListWorkUnits(req), "work_units", []))
for raw_wu in raw_work_units:
worker_name = xmc_entities_validator.extract_worker_name(raw_wu)
_assert_work_unit_spec(raw_wu, worker_name, expected_queue)

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

The expected_work_units parameter is passed to _assert_all_work_unit_specs but is never used. To prevent silent validation bypass if the second ListWorkUnits RPC returns fewer or no work units, we should assert that the number of fetched raw work units matches expected_work_units.

    req = xmc_entities_validator._make_req("ListWorkUnitsRequest", parent=f"experiments/{xid}")
    raw_work_units = list(getattr(stub.ListWorkUnits(req), "work_units", []))
    if len(raw_work_units) != expected_work_units:
        raise AssertionError(
            f"Expected {expected_work_units} raw WorkUnits for spec validation, but found {len(raw_work_units)}."
        )
    for raw_wu in raw_work_units:
        worker_name = xmc_entities_validator.extract_worker_name(raw_wu)
        _assert_work_unit_spec(raw_wu, worker_name, expected_queue)
References
  1. PEP-8 recommends avoiding unused parameters to keep code clean and maintainable. (link)

common.validate_argv(argv)
xid = common.parse_xid(getattr(FLAGS, "xid", None))
expected_queue = common.get_flag(FLAGS, "expected_queue", DEFAULT_QUEUE)
expected_work_units = common.get_flag(FLAGS, "expected_work_units", DEFAULT_WORK_UNITS)

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

The expected_work_units flag is not validated to ensure it is positive. If a user passes a value less than 1, it could lead to unexpected behavior or incorrect assertions. We should add a guard check to validate that expected_work_units is at least 1.

Suggested change
expected_work_units = common.get_flag(FLAGS, "expected_work_units", DEFAULT_WORK_UNITS)
expected_work_units = common.get_flag(FLAGS, "expected_work_units", DEFAULT_WORK_UNITS)
if expected_work_units < 1:
raise ValueError("expected_work_units must be at least 1.")

Comment on lines +320 to +334
if isinstance(expected_c, str):
act_name = getattr(actual_c, "name", "")
if act_name != expected_c:
raise AssertionError(
f"Job '{job_name}' {item_type} container name mismatch: "
f"expected '{expected_c}', found '{act_name}'."
)
elif isinstance(expected_c, dict):
for k, v in expected_c.items():
act_val = getattr(actual_c, k, None)
if act_val != v:
raise AssertionError(
f"Job '{job_name}' {item_type} container property '{k}' mismatch: "
f"expected '{v}', found '{act_val}'."
)

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 expected_c is neither a str nor a dict, the function silently completes without performing any validation. To prevent silent failures and ensure robust input validation, we should raise a TypeError if an unsupported type is passed.

    if isinstance(expected_c, str):
        act_name = getattr(actual_c, "name", "")
        if act_name != expected_c:
            raise AssertionError(
                f"Job '{job_name}' {item_type} container name mismatch: "
                f"expected '{expected_c}', found '{act_name}'."
            )
    elif isinstance(expected_c, dict):
        for k, v in expected_c.items():
            act_val = getattr(actual_c, k, None)
            if act_val != v:
                raise AssertionError(
                    f

Comment on lines +370 to +384
if isinstance(expected_spec, str):
act_name = getattr(actual_spec, "name", "")
if act_name != expected_spec:
raise AssertionError(
f"Job '{job_name}' primary container name mismatch: "
f"expected '{expected_spec}', found '{act_name}'."
)
elif isinstance(expected_spec, dict):
for k, v in expected_spec.items():
act_val = getattr(actual_spec, k, None)
if act_val != v:
raise AssertionError(
f"Job '{job_name}' primary container property '{k}' mismatch: "
f"expected '{v}', found '{act_val}'."
)

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 expected_spec is neither a str nor a dict, the function silently completes without performing any validation. To prevent silent failures and ensure robust input validation, we should raise a TypeError if an unsupported type is passed.

Suggested change
if isinstance(expected_spec, str):
act_name = getattr(actual_spec, "name", "")
if act_name != expected_spec:
raise AssertionError(
f"Job '{job_name}' primary container name mismatch: "
f"expected '{expected_spec}', found '{act_name}'."
)
elif isinstance(expected_spec, dict):
for k, v in expected_spec.items():
act_val = getattr(actual_spec, k, None)
if act_val != v:
raise AssertionError(
f"Job '{job_name}' primary container property '{k}' mismatch: "
f"expected '{v}', found '{act_val}'."
)
if isinstance(expected_spec, str):
act_name = getattr(actual_spec, "name", "")
if act_name != expected_spec:
raise AssertionError(
f"Job '{job_name}' primary container name mismatch: "
f"expected '{expected_spec}', found '{act_name}'."
)
elif isinstance(expected_spec, dict):
for k, v in expected_spec.items():
act_val = getattr(actual_spec, k, None)
if act_val != v:
raise AssertionError(
f"Job '{job_name}' primary container property '{k}' mismatch: "
f"expected '{v}', found '{act_val}'."
)
else:
raise TypeError(
f"Unsupported expected spec type: {type(expected_spec)}. Expected str or dict."
)

) -> tuple[dict[str, str], float]:
"""Logs state transitions or periodic progress if states changed or 30s elapsed."""
if current_states != last_states or (elapsed - last_time >= 30.0):
print(f"[{int(elapsed)}s] WorkUnit States: {current_states}", flush=True)

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

As a generic validator library, it is preferred to use the standard logging module instead of direct print statements. This allows importing applications to configure, redirect, or suppress log output as needed.

Suggested change
print(f"[{int(elapsed)}s] WorkUnit States: {current_states}", flush=True)
logging.info("[%ds] WorkUnit States: %s", int(elapsed), current_states)
References
  1. PEP-8 and general Python best practices recommend using the logging module instead of print statements in library code. (link)

@janzak-dev
janzak-dev deleted the branch main September 17, 2026 10:37
@janzak-dev janzak-dev closed this Sep 17, 2026
@janzak-dev janzak-dev reopened this Sep 17, 2026
@janzak-dev
janzak-dev removed this pull request from stack #899 September 17, 2026 10:40
@janzak-dev
janzak-dev changed the base branch from feat/nightly-common-validation to main September 17, 2026 10:41
@janzak-dev
janzak-dev force-pushed the feat/nightly-examples-pipeline-base branch from 9e1884d to 5dc0335 Compare September 17, 2026 10:41
@janzak-dev
janzak-dev added this pull request to stack #900 September 17, 2026 10:42
TAG=agy
CONV=606f1e41-6785-4137-b85b-cd0f56237339
…_job baseline

TAG=agy
CONV=606f1e41-6785-4137-b85b-cd0f56237339
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