Repository navigation
feat(ci,tools): expand nightly examples suite to all 12 example workloads - #903
janzak-dev wants to merge 3 commits into
Conversation
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Move the re import to the top of the file to adhere to PEP 8 style guidelines regarding import placement.
| import urllib.error | |
| import re | |
| import urllib.error |
References
- 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)
| import re | ||
|
|
||
| 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", ""), |
There was a problem hiding this comment.
| 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")) |
| 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: |
There was a problem hiding this comment.
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.
| except (urllib.error.HTTPError, urllib.error.URLError, OSError) as e: | |
| except (urllib.error.HTTPError, urllib.error.URLError, OSError, ValueError) as e: |
| if provided_endpoint: | ||
| ep = provided_endpoint.strip() |
There was a problem hiding this comment.
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.
| if provided_endpoint: | |
| ep = provided_endpoint.strip() | |
| if provided_endpoint and provided_endpoint.strip(): | |
| ep = provided_endpoint.strip() |
| dash_endpoint = ( | ||
| common.get_flag(FLAGS, "dashboard_endpoint", None) | ||
| or os.environ.get("XMC_DASHBOARD_ENDPOINT") | ||
| or os.environ.get("DASHBOARD_ENDPOINT") | ||
| ) |
There was a problem hiding this comment.
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).
| 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) |
| dash_endpoint = ( | ||
| common.get_flag(FLAGS, "dashboard_endpoint", None) | ||
| or os.environ.get("XMC_DASHBOARD_ENDPOINT") | ||
| or os.environ.get("DASHBOARD_ENDPOINT") | ||
| ) |
There was a problem hiding this comment.
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).
| 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", {})) |
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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.
| 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 |
🥞 Stack Navigation
refactor(tools,ci): rename demo_workload_verify to simple_job_verifyfeat(ci,tools): add unified nightly examples e2e pipeline with simple_job baselinefeat(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.
xmc-nightly..github/workflows/nightly-examples-e2e.ymlmatrix from thesimple_jobbaseline 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
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
.github/workflows/nightly-examples-e2e.yml):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.bazel: Registers all 12py_binarytargets 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 test //tools/nightly_tests:all(3/3 targets passed, 83 tests passing)node --test .github/scripts/aggregate-example-results.test.js(11/11 tests passing)./.githooks/pre-commit check(100% clean)TAG=agy
CONV=606f1e41-6785-4137-b85b-cd0f56237339