8000 fix(verifier): auto-validate managed_xprof xprof_url and honor expected_title_pattern by CatherineF-dev · Pull Request #1501 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

fix(verifier): auto-validate managed_xprof xprof_url and honor expected_title_pattern - #1501

Draft
CatherineF-dev wants to merge 2 commits into
fix/reconciler-mlrun-url-cachefrom
fix/verifier-managed-xprof-url
Draft

CatherineF-dev wants to merge 2 commits into
fix/reconciler-mlrun-url-cachefrom
fix/verifier-managed-xprof-url

Conversation

@CatherineF-dev
@CatherineF-dev CatherineF-dev commented Oct 30, 2026 •
Copy link
Copy Markdown
Collaborator

PR Stack

Summary

Adds --require_managed_xprof_url=auto|true|false (default: auto) to the nightly workload verification CLI so clusters configured with Managed XProf validate that ManagedXprofArtifact records receive an enriched xprof_url, and honors --expected_title_pattern CLI flag overrides.

Motivation & Context

Previously, nightly verification checked only that a ManagedXprofArtifact existed in Experiment State Server without verifying that the Reconciler enriched payload.xprof.xprof_url on clusters configured with a Managed XProf GCS bucket (ConfigMap managed-xprof-gcs-config), and ignored --expected_title_pattern overrides in verify_standard_workload.

Key Changes

  • Added --require_managed_xprof_url (auto | true | false) in tools/nightly_tests/verification/verifier_cli.py and cluster_has_managed_xprof_bucket() / resolve_require_managed_xprof_url() in tools/nightly_tests/verification/workload_verification.py.
  • Updated tools/nightly_tests/verification/xmc_entities_validator.py to validate ManagedXprofArtifact display_name, URL scheme, and top-level artifact.url consistency, and surface clear timeout diagnostics when xprof_url remains empty.
  • Honored --expected_title_pattern in verify_standard_workload and guarded verifier_cli.get_flag against UnparsedFlagAccessError.

Assumptions

None — requirements were fully specified.

Verification & Testing

  • Commands Executed: python3 -m unittest tools/nightly_tests/verification/verifier_cli_test.py tools/nightly_tests/verification/workload_verification_test.py tools/nightly_tests/verification/xmc_entities_validator_test.py
  • Coverage & Test Status: All unit tests pass.

Related Issues / Bugs

N/A

TAG=agy
CONV=108bc446-88fa-4cbf-b70b-e3e5e9c917c5

…ed_title_pattern

Nightly workload verification previously checked only whether a
ManagedXprofArtifact record existed in Experiment State Server, without
verifying that the Reconciler enriched payload.xprof.xprof_url on clusters
configured with a Managed XProf GCS bucket, and ignored CLI overrides for
--expected_title_pattern.

- Add --require_managed_xprof_url=auto|true|false (default: auto), inspecting
  ConfigMap managed-xprof-gcs-config in namespace xmc when set to auto so
  clusters configured with Managed XProf require a non-empty enriched
  xprof_url while CI clusters without a bucket continue verifying artifact
  registration cleanly.
- Validate ManagedXprofArtifact display_name, URL scheme, and top-level
  artifact.url consistency in xmc_entities_validator.validate_artifacts,
  and surface pending URL timeouts with actionable diagnostics.
- Honor the --expected_title_pattern CLI flag override in
  verify_standard_workload, and guard verifier_cli.get_flag against
  UnparsedFlagAccessError when verification functions are invoked directly
  from unit tests.

TAG=agy
CONV=108bc446-88fa-4cbf-b70b-e3e5e9c917c5
@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 the ability to enforce verification of xprof_url for ManagedXprof artifacts, controlled by a new require_managed_xprof_url flag. It adds logic to dynamically detect if the target Kubernetes cluster has a managed xprof bucket using kubectl and validates the artifact metadata accordingly. Unit tests have been added to cover these new verification flows. The review feedback suggests refactoring nested getattr calls in _extract_managed_xprof_details to improve readability, and making _normalize_artifact_type public in xmc_entities_validator.py instead of accessing it as a private member from workload_verification.py.

Comment on lines +825 to +826
xprof_url = str(getattr(getattr(payload, "xprof", None), "xprof_url", "") or "").strip()
top_url = str(getattr(getattr(art, "url", None), "url", "") or "").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

The nested getattr calls with fallback defaults are quite hard to read and maintain. In Python, it is much more idiomatic and readable to retrieve the intermediate objects first and perform a simple check, or use a helper function.

Suggested change
xprof_url = str(getattr(getattr(payload, "xprof", None), "xprof_url", "") or "").strip()
top_url = str(getattr(getattr(art, "url", None), "url", "") or "").strip()
xprof_url = ""
if (xprof_obj := getattr(payload, "xprof", None)) is not None:
xprof_url = str(getattr(xprof_obj, "xprof_url", "") or "").strip()
top_url = ""
if (art_url_obj := getattr(art, "url", None)) is not None:
top_url = str(getattr(art_url_obj, "url", "") or "").strip()

Comment on lines +138 to +140
normalized = {
xmc_entities_validator._normalize_artifact_type(t) for t in expected_artifact_types
}
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

Accessing a protected/private member (prefixed with _) of another module is discouraged as it violates encapsulation and can lead to maintainability issues. Consider renaming _normalize_artifact_type to normalize_artifact_type in xmc_entities_validator.py to make it public, and reference the public function here.

Suggested change
normalized = {
xmc_entities_validator._normalize_artifact_type(t) for t in expected_artifact_types
}
normalized = {
xmc_entities_validator.normalize_artifact_type(t) for t in expected_artifact_types
}
References
  1. PEP 8 recommends that public attributes and functions should have no leading underscores. Internal/non-public APIs should be prefixed with a leading underscore and should not be accessed from outside their defining module. (link)

"auto",
["auto", "true", "false"],
"Whether ManagedXprof artifacts must expose an enriched xprof_url "
"(auto enforces when ConfigMap managed-xprof-gcs-config exists in K8s).",
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

also, the xmc instance has been upgraded to enable Managed Xprof feature

…tr checks

- Rename _normalize_artifact_type to public normalize_artifact_type in xmc_entities_validator.py instead of calling a protected helper across modules.

- Simplify nested getattr calls in _extract_managed_xprof_details using explicit intermediate checks.

TAG=agy
@CatherineF-dev
CatherineF-dev force-pushed the fix/verifier-managed-xprof-url branch from d9de688 to 58889d2 Compare October 30, 2026 15:18

This branch has not been deployed

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

Labels

None yet

Projects

4552 None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0