Skip to content

Commit

Permalink
remove schema_version
Browse files Browse the repository at this point in the history
  • Loading branch information
hernandezc1 committed Sep 9, 2024
1 parent d93dc85 commit 635c354
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
9 changes: 4 additions & 5 deletions broker/cloud_functions/lvk/store_BigQuery/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
# Deploys or deletes broker Cloud Function
# This script will not delete Cloud Functions that are in production

testid="${1:-test}"
# "False" uses production resources
# any other string will be appended to the names of all resources
teardown="${2:-False}"
testid="${1:-test}"
# "True" tearsdown/deletes resources, else setup
survey="${3:-lvk}"
teardown="${2:-False}"
# name of the survey this broker instance will ingest
versiontag="${4:-vO4}"
survey="${3:-lvk}"

#--- GCP resources used in this script
store_bq_trigger_topic="${survey}-alerts"
Expand Down Expand Up @@ -38,5 +37,5 @@ else # Deploy the Cloud Functions
--runtime python312 \
--memory "${memory}" \
--trigger-topic "${store_bq_trigger_topic}" \
--set-env-vars TESTID="${testid}",SURVEY="${survey}",VERSIONTAG="${versiontag}",GCP_PROJECT="${GOOGLE_CLOUD_PROJECT}"
--set-env-vars TESTID="${testid}",SURVEY="${survey}",GCP_PROJECT="${GOOGLE_CLOUD_PROJECT}"
fi
3 changes: 1 addition & 2 deletions broker/cloud_functions/lvk/store_BigQuery/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
PROJECT_ID = os.getenv("GCP_PROJECT")
SURVEY = os.getenv("SURVEY")
TESTID = os.getenv("TESTID")
VERSIONTAG = os.getenv("VERSIONTAG")

# connect to the cloud logger
log_name = "store-bigquery-cloudfnc" # same log for all broker instances
logging_client = logging.Client()
logger = logging_client.logger(log_name)

# GCP resources used in this module
TABLE = pittgoogle.Table.from_cloud(f"alerts_{VERSIONTAG}", survey=SURVEY, testid=TESTID)
TABLE = pittgoogle.Table.from_cloud("alerts", survey=SURVEY, testid=TESTID)
TOPIC = pittgoogle.Topic.from_cloud("bigquery", survey=SURVEY, testid=TESTID, projectid=PROJECT_ID)


Expand Down
6 changes: 2 additions & 4 deletions broker/setup_broker/lvk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ Initialize parameters and call the deployment script:
testid="mytest"
teardown="False"
survey="lvk"
schema_version="O4"
region="us-central1"

./setup_broker.sh "${testid}" "${teardown}" "${survey}" "${schema_version}" "${region}"
./setup_broker.sh "${testid}" "${teardown}" "${survey}" "${region}"
```

This will create all of the necessary GCP resources. Allow the consumer VM to finish its installation process. Once
Expand Down Expand Up @@ -142,8 +141,7 @@ Similar to [deploy broker instance](#deploy-broker-instance). Initialize paramet
testid="mytest"
teardown="True"
survey="lvk"
schema_version="O4"
region="us-central1"

./setup_broker.sh "${testid}" "${teardown}" "${survey}" "${schema_version}" "${region}"
./setup_broker.sh "${testid}" "${teardown}" "${survey}" "${region}"
```
14 changes: 6 additions & 8 deletions broker/setup_broker/lvk/setup_broker.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#! /bin/bash
# Create and configure GCP resources needed to run the nightly broker.

testid="${1:-test}"
# "False" uses production resources
# any other string will be appended to the names of all resources
teardown="${2:-False}"
testid="${1:-test}"
# "True" tearsdown/deletes resources, else setup
survey="${3:-lvk}"
teardown="${2:-False}"
# name of the survey this broker instance will ingest
schema_version="${4:-O4}"
versiontag="v${schema_version}" # O4 -> vO4
region="${5:-us-central1}"
survey="${3:-lvk}"
region="${4:-us-central1}"
zone="${region}-a" # just use zone "a" instead of adding another script arg

PROJECT_ID=$GOOGLE_CLOUD_PROJECT # get the environment variable
Expand Down Expand Up @@ -48,7 +46,7 @@ if [ "$testid" != "False" ]; then
topic_storebigquery="${topic_storebigquery}-${testid}"
fi

alerts_table="alerts_${versiontag}"
alerts_table="alerts"

#--- Create (or delete) BigQuery, GCS, Pub/Sub resources
echo
Expand Down Expand Up @@ -101,7 +99,7 @@ cd cloud_functions && cd lvk || exit

#--- BigQuery storage cloud function
cd store_BigQuery || exit
./deploy.sh "$testid" "$teardown" "$survey" "$versiontag"
./deploy.sh "$testid" "$teardown" "$survey"

#--- return to setup_broker directory
cd .. && cd .. || exit
Expand Down

0 comments on commit 635c354

Please sign in to comment.