Skip to content

Add validation helper cloud run job - #771

Draft
vish-cs wants to merge 1 commit into
datacommonsorg:masterfrom
vish-cs:validation
Draft

vish-cs wants to merge 1 commit into
datacommonsorg:masterfrom
vish-cs:validation

Conversation

@vish-cs

@vish-cs vish-cs commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Add validation-helper Cloud Run Job & Clean Up Differ/Validation Utilities

Summary

Adds validation-helper as a standalone Cloud Run Job (validation-helper-job) orchestrated by import-automation-workflow.yaml to run dataset diffing and validation after Cloud Batch import jobs, and cleans up unused legacy code copied from the data repo.

Changes

  • Workflow Integration: Updated import-automation-workflow.yaml, build-services.yaml, and deploy-services.yaml to run runImportJob in execute-only mode and trigger validation-helper-job immediately after.
  • Differ Cleanup: Removed Dataflow (cloud) and DirectRunner (direct) modes from import_differ.py, keeping only bigquery (default) and native modes. Extracted reusable MCF-to-BigQuery streaming/loading helpers into util/bq_util.py.
  • Removed Unused Utilities:
    • Removed tools/statvar_importer/ (config_flags.py, mcf_diff.py, data_sampler.py), moving mcf_file_util.py to util/mcf_file_util.py.
    • Removed unused util/aggregation_util.py and util/config_map.py, and simplified util/counters.py (removed psutil and background timers).
    • Fixed file_get_matching() in util/file_util.py to check blob.exists() for non-wildcard gs:// URIs.
    • Removed unused psutil and google-api-python-client dependencies from pyproject.toml.

Testing

  • Unit Tests: uv run pytest (120 passed).
  • E2E Workflow (datcom-ci): Deployed and verified import-automation-workflow-staging (1139ba22-f58b-4184-8bc2-92b2b365c941) on USFed_ConstantMaturityRates_Test. Confirmed validation-helper-job-staging ran BigQuery differ + validation rules and uploaded differ_summary.csv, differ_summary.json, and validation_output.csv to GCS.

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

Copy link
Copy Markdown
Contributor

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 integrates a new validation helper service into the import automation pipeline, adding build and deployment configurations for a Cloud Run job that runs a BigQuery-based dataset differ and an automated validation framework. The validation framework supports custom rules, SQL-based validations, and golden set checks. The review feedback identifies two important improvements: updating path resolution in the golden set validator to recursively handle lists of paths, and copying the initial dictionary in the MCF utility to prevent unintended in-place mutation of the caller's data.

Comment on lines +265 to +272
def _resolve_paths(path: str, config_dir: str) -> str:
"""Resolves relative path to be absolute relative to config_dir."""
if (isinstance(path, str) and path and not os.path.isabs(path) and
file_util.file_is_local(path)):
resolved = os.path.join(config_dir, path)
logging.info("Resolved relative path '%s' to '%s'", path, resolved)
return resolved
return path

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The golden_files parameter can be specified as a list of paths (e.g., ["golden_data/critical_stats.csv"]). However, _resolve_paths only handles str inputs and will return a list unmodified without resolving its relative paths against config_dir. Update _resolve_paths to recursively handle lists of paths.

Suggested change
def _resolve_paths(path: str, config_dir: str) -> str:
"""Resolves relative path to be absolute relative to config_dir."""
if (isinstance(path, str) and path and not os.path.isabs(path) and
file_util.file_is_local(path)):
resolved = os.path.join(config_dir, path)
logging.info("Resolved relative path '%s' to '%s'", path, resolved)
return resolved
return path
def _resolve_paths(path, config_dir: str):
"""Resolves relative path to be absolute relative to config_dir."""
if isinstance(path, list):
return [_resolve_paths(p, config_dir) for p in path]
if (isinstance(path, str) and path and not os.path.isabs(path) and
file_util.file_is_local(path)):
resolved = os.path.join(config_dir, path)
logging.info("Resolved relative path '%s' to '%s'", path, resolved)
return resolved
return path

Comment thread pipeline/workflow/validation-helper/util/mcf_file_util.py
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 10 high · 37 medium · 53 minor

Alerts:
⚠ 100 issues (≤ 0 issues of at least minor severity)

Results:
100 new issues

Category Results
UnusedCode 7 medium
1 minor
Documentation 48 minor
ErrorProne 8 high
Security 2 high
CodeStyle 4 minor
Complexity 30 medium

View in Codacy

🟢 Metrics 876 complexity

Metric Results
Complexity 876

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@vish-cs
vish-cs marked this pull request as draft September 21, 2026 12:01

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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant