Skip to content

Commit 5f030fd

Browse files
Revert "Create GitHub Action script to prevent API v1 deployment if v1 and v2 model versions don't align" (#2549)
* Revert "Create GitHub Action script to prevent API v1 deployment if v1 and v2…" This reverts commit 7c3d21b. * Add error handling
1 parent be5e0e1 commit 5f030fd

6 files changed

Lines changed: 33 additions & 67 deletions

File tree

.github/find-api-model-versions.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/install-jq.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/request-simulation-model-versions.sh renamed to .github/request-model-versions.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
set -e
44

55
# Google Cloud Workflow execution script
6-
# Usage: ./request-simulation-model-versions.sh -b <bucket_name> -us <us_version> -uk <uk_version> [-t timeout] [-i interval]
6+
# Usage: ./wait_for_country_versions.sh -b <bucket_name> -us <us_version> -uk <uk_version> [-t timeout] [-i interval]
77

88
usage() {
9-
echo "Usage: $0 -us <us_version> -uk <uk_version> [-t timeout] [-i interval]"
9+
echo "Usage: $0 -b <bucket_name> -us <us_version> -uk <uk_version> [-t timeout] [-i interval]"
1010
echo ""
1111
echo "Required flags:"
1212
echo " -b bucket_name - GCS bucket name"
@@ -19,8 +19,8 @@ usage() {
1919
echo " -h help - Show this help message"
2020
echo ""
2121
echo "Example:"
22-
echo " $0 -us v1.2.3 -uk v1.2.4"
23-
echo " $0 -us v1.2.3 -uk v1.2.4 -t 600 -i 15"
22+
echo " $0 -b my-bucket -us v1.2.3 -uk v1.2.4"
23+
echo " $0 -b my-bucket -us v1.2.3 -uk v1.2.4 -t 600 -i 15"
2424
exit 1
2525
}
2626

@@ -34,9 +34,6 @@ CHECK_INTERVAL="10"
3434
# Parse command line arguments
3535
while [ $# -gt 0 ]; do
3636
case "$1" in
37-
-h|--help)
38-
usage
39-
;;
4037
-b)
4138
if [ -z "$2" ]; then
4239
echo "Error: -b requires a bucket name"
@@ -88,7 +85,7 @@ while [ $# -gt 0 ]; do
8885
done
8986

9087
# Validate required arguments
91-
if [ -z "$BUCKET_NAME" ] || -z "$US_VERSION" ] || [ -z "$UK_VERSION" ]; then
88+
if [ -z "$BUCKET_NAME" ] || [ -z "$US_VERSION" ] || [ -z "$UK_VERSION" ]; then
9289
echo "Error: Missing required arguments"
9390
echo "bucket_name (-b), us_version (-us), and uk_version (-uk) are required"
9491
usage
@@ -101,10 +98,15 @@ if ! [[ "$TIMEOUT_SECONDS" =~ ^[0-9]+$ ]] || ! [[ "$CHECK_INTERVAL" =~ ^[0-9]+$
10198
fi
10299

103100
# Configuration
104-
PROJECT_ID="prod-api-v2-c4d5"
105-
WORKFLOW_LOCATION="us-central1"
101+
PROJECT_ID="${GOOGLE_CLOUD_PROJECT:-$(gcloud config get-value project 2>/dev/null)}"
102+
WORKFLOW_LOCATION="${WORKFLOW_LOCATION:-us-central1}"
106103
WORKFLOW_NAME="wait-for-country-packages"
107104

105+
if [ -z "$PROJECT_ID" ]; then
106+
echo "Error: Could not determine project ID. Set GOOGLE_CLOUD_PROJECT environment variable."
107+
exit 1
108+
fi
109+
108110
echo "Starting workflow execution..."
109111
echo "Project: $PROJECT_ID"
110112
echo "Location: $WORKFLOW_LOCATION"
@@ -132,7 +134,6 @@ echo "Input: $INPUT_JSON"
132134
# Execute workflow
133135
echo "Executing workflow..."
134136
EXECUTION_RESULT=$(gcloud workflows execute "$WORKFLOW_NAME" \
135-
--project="$PROJECT_ID" \
136137
--location="$WORKFLOW_LOCATION" \
137138
--data="$INPUT_JSON" \
138139
--format="json")

.github/workflows/push.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ jobs:
6565
uses: actions/setup-python@v5
6666
with:
6767
python-version: "3.11"
68-
- name: Install dependencies (required for finding API model versions)
69-
run: make install
70-
- name: Install jq (required only for GitHub Actions)
71-
run: ".github/install-jq.sh"
72-
- name: Find API model versions and write to environment variable
73-
run: python3 .github/find-api-model-versions.py
74-
- name: Ensure full API and simulation API model versions are in sync
75-
run: ".github/request-simulation-model-versions.sh -b prod-api-v2-c4d5-metadata -us ${{ env.US_VERSION }} -uk ${{ env.UK_VERSION }}"
7668
- name: GCP authentication
7769
uses: "google-github-actions/auth@v2"
7870
with:

changelog_entry.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- bump: patch
2+
changes:
3+
fixed:
4+
- Reverted a previous PR.

policyengine_api/jobs/calculate_economy_simulation_job.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,23 @@ def run(
296296
progress_log.model_dump(mode="json"), severity="INFO"
297297
)
298298
except Exception as e:
299-
trace = traceback.format_exc()
300-
# Send error log to GCP
301-
error_log: V2V1Comparison = V2V1Comparison.model_validate(
302-
{
303-
**comparison_data,
304-
"v2_error": trace,
305-
}
306-
)
307-
logger.log_struct(
308-
error_log.model_dump(mode="json"), severity="ERROR"
309-
)
299+
try:
300+
trace = traceback.format_exc()
301+
# Send error log to GCP
302+
error_log: V2V1Comparison = (
303+
V2V1Comparison.model_validate(
304+
{
305+
**comparison_data,
306+
"v2_error": trace,
307+
}
308+
)
309+
)
310+
logger.log_struct(
311+
error_log.model_dump(mode="json"), severity="ERROR"
312+
)
313+
except Exception as e2:
314+
print("Something really wrong.", e2)
315+
pass
310316

311317
# Compute baseline economy
312318
logger.log_struct(

0 commit comments

Comments
 (0)