From 385f9ce5a8dd47895afea2d41b7aae08d049cc0c Mon Sep 17 00:00:00 2001 From: "jake.ross" Date: Tue, 6 Jan 2026 20:31:48 -0700 Subject: [PATCH] feat: update staging backfill script to use module execution and ensure repository root in path --- .github/workflows/CD_staging.yml | 2 +- transfers/backfill/staging.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CD_staging.yml b/.github/workflows/CD_staging.yml index c172d03d3..3d6eb72ec 100644 --- a/.github/workflows/CD_staging.yml +++ b/.github/workflows/CD_staging.yml @@ -55,7 +55,7 @@ jobs: CLOUD_SQL_USER: "${{ secrets.CLOUD_SQL_USER }}" CLOUD_SQL_PASSWORD: "${{ secrets.CLOUD_SQL_PASSWORD }}" run: | - uv run python transfers/backfill/staging.py + uv run python -m transfers.backfill.staging - name: Authenticate to Google Cloud uses: 'google-github-actions/auth@v2' diff --git a/transfers/backfill/staging.py b/transfers/backfill/staging.py index 7e0417ce3..ed511aee0 100644 --- a/transfers/backfill/staging.py +++ b/transfers/backfill/staging.py @@ -16,12 +16,18 @@ """ Orchestrates all backfills used in the staging CD pipeline. -Run with: +Preferred usage (avoids import path issues): python -m transfers.backfill.staging --batch-size 1000 """ import argparse import sys +from pathlib import Path + +# Ensure repository root on sys.path when run as a script (e.g., in CI). +ROOT = Path(__file__).resolve().parents[2] +if str(ROOT) not in sys.path: + sys.path.insert(0, str(ROOT)) from transfers.backfill.ngwmn_views import run as run_ngwmn_views from transfers.backfill.waterlevelscontinuous_pressure_daily import ( run as run_pressure_daily,