Skip to content

Commit 8617915

Browse files
authored
Merge branch 'develop' into u/ch/ztf/hostlesstransients
2 parents 10f4b24 + c83eebd commit 8617915

19 files changed

+4539
-396
lines changed

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2025, mwvgroup
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

broker/cloud_run/lsst/classify_snn/deploy.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ teardown="${2:-False}"
1111
survey="${3:-lsst}"
1212
region="${4:-us-central1}"
1313
# get the environment variable
14+
BASE_DIR=$(pwd)
1415
PROJECT_ID=$GOOGLE_CLOUD_PROJECT
16+
PROJECT_NUMBER=$(gcloud projects describe "$PROJECT_ID" --format="value(projectNumber)")
1517

1618
MODULE_NAME="supernnova" # lower case required by cloud run
1719
ROUTE_RUN="/" # url route that will trigger main.run()
@@ -30,12 +32,13 @@ define_GCP_resources() {
3032
#--- GCP resources used in this script
3133
artifact_registry_repo=$(define_GCP_resources "${survey}-cloud-run-services")
3234
bq_dataset=$(define_GCP_resources "${survey}" "_")
33-
bq_table="SuperNNova"
35+
bq_table="${MODULE_NAME}"
3436
cr_module_name=$(define_GCP_resources "${survey}-${MODULE_NAME}") # lower case required by cloud run
35-
ps_input_subscrip=$(define_GCP_resources "${survey}-SuperNNova") # pub/sub subscription used to trigger cloud run module
36-
ps_output_topic=$(define_GCP_resources "${survey}-SuperNNova")
37+
ps_input_subscrip=$(define_GCP_resources "${survey}-${MODULE_NAME}") # pub/sub subscription used to trigger cloud run module
38+
ps_output_topic=$(define_GCP_resources "${survey}-${MODULE_NAME}")
3739
ps_trigger_topic=$(define_GCP_resources "${survey}-lite")
3840
runinvoker_svcact="cloud-run-invoker@${PROJECT_ID}.iam.gserviceaccount.com"
41+
service_account="service-${PROJECT_NUMBER}@gcp-sa-pubsub.iam.gserviceaccount.com"
3942
# topics and subscriptions involved in writing data to BigQuery
4043
ps_bigquery_subscription=$(define_GCP_resources "${survey}-${MODULE_NAME}-bigquery-import")
4144
ps_deadletter_topic=$(define_GCP_resources "${survey}-deadletter")
@@ -51,7 +54,8 @@ if [ "${teardown}" = "True" ]; then
5154
gcloud run services delete "${cr_module_name}" --region "${region}"
5255
fi
5356
else
54-
echo "Configuring Pub/Sub resources..."
57+
echo
58+
echo "Configuring Pub/Sub resources for ${MODULE_NAME} module..."
5559
gcloud pubsub topics create "${ps_output_topic}"
5660
gcloud pubsub subscriptions create "${ps_bigquery_subscription}" \
5761
--topic="${ps_output_topic}" \
@@ -60,12 +64,14 @@ else
6064
--drop-unknown-fields \
6165
--dead-letter-topic="${ps_deadletter_topic}" \
6266
--max-delivery-attempts=5 \
63-
--dead-letter-topic-project="${PROJECT_ID}"
67+
--dead-letter-topic-project="${PROJECT_ID}" \
68+
--message-transforms-file="${BASE_DIR%%/cloud_run/*}/setup_broker/lsst/templates/ps_lsst_flatten_schema_smt.yaml"
6469
# set IAM policies on public Pub/Sub resources
6570
if [ "$testid" = "False" ]; then
6671
user="allUsers"
67-
roleid="projects/${GOOGLE_CLOUD_PROJECT}/roles/userPublic"
72+
roleid="roles/pubsub.subscriber"
6873
gcloud pubsub topics add-iam-policy-binding "${ps_output_topic}" --member="${user}" --role="${roleid}"
74+
gcloud pubsub subscriptions add-iam-policy-binding "${ps_bigquery_subscription}" --member="serviceAccount:${service_account}" --role="${roleid}"
6975
fi
7076

7177
#--- Deploy Cloud Run service

broker/cloud_run/lsst/classify_snn/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
# GCP resources used in this module
4848
# pittgoogle will construct the full resource names from the module name, SURVEY, and TESTID
4949
TOPIC = pittgoogle.Topic.from_cloud(
50-
"SuperNNova", survey=SURVEY, testid=TESTID, projectid=PROJECT_ID
50+
"supernnova", survey=SURVEY, testid=TESTID, projectid=PROJECT_ID
5151
)
5252

5353

broker/cloud_run/lsst/classify_snn/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pandas==1.5.1
22
numpy==1.23.3
33
google-cloud-functions
44
google-cloud-logging
5-
pittgoogle-client>=0.3.15
5+
pittgoogle-client>=0.3.17
66

77
# for Cloud Run
88
# https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-python-service

broker/cloud_run/lsst/classify_upsilon/deploy.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ teardown="${2:-False}"
1111
survey="${3:-lsst}"
1212
region="${4:-us-central1}"
1313
# get the environment variable
14+
BASE_DIR=$(pwd)
1415
PROJECT_ID=$GOOGLE_CLOUD_PROJECT
16+
PROJECT_NUMBER=$(gcloud projects describe "$PROJECT_ID" --format="value(projectNumber)")
1517

1618
MODULE_NAME="upsilon" # lower case required by cloud run
1719
ROUTE_RUN="/" # url route that will trigger main.run()
@@ -36,6 +38,7 @@ ps_input_subscrip=$(define_GCP_resources "${survey}-upsilon") # pub/sub subscrip
3638
ps_output_topic=$(define_GCP_resources "${survey}-upsilon")
3739
ps_trigger_topic=$(define_GCP_resources "${survey}-lite")
3840
runinvoker_svcact="cloud-run-invoker@${PROJECT_ID}.iam.gserviceaccount.com"
41+
service_account="service-${PROJECT_NUMBER}@gcp-sa-pubsub.iam.gserviceaccount.com"
3942
# topics and subscriptions involved in writing data to BigQuery
4043
ps_bigquery_subscription=$(define_GCP_resources "${survey}-${MODULE_NAME}-bigquery-import")
4144
ps_deadletter_topic=$(define_GCP_resources "${survey}-deadletter")
@@ -52,7 +55,8 @@ if [ "${teardown}" = "True" ]; then
5255
fi
5356

5457
else
55-
echo "Configuring Pub/Sub resources..."
58+
echo
59+
echo "Configuring Pub/Sub resources for ${MODULE_NAME} module..."
5660
gcloud pubsub topics create "${ps_output_topic}"
5761
gcloud pubsub subscriptions create "${ps_bigquery_subscription}" \
5862
--topic="${ps_output_topic}" \
@@ -61,12 +65,14 @@ else
6165
--drop-unknown-fields \
6266
--dead-letter-topic="${ps_deadletter_topic}" \
6367
--max-delivery-attempts=5 \
64-
--dead-letter-topic-project="${PROJECT_ID}"
68+
--dead-letter-topic-project="${PROJECT_ID}" \
69+
--message-transforms-file="${BASE_DIR%%/cloud_run/*}/setup_broker/lsst/templates/ps_lsst_flatten_schema_smt.yaml"
6570
# set IAM policies on public Pub/Sub resources
6671
if [ "$testid" = "False" ]; then
6772
user="allUsers"
68-
roleid="projects/${GOOGLE_CLOUD_PROJECT}/roles/userPublic"
73+
roleid="roles/pubsub.subscriber"
6974
gcloud pubsub topics add-iam-policy-binding "${ps_output_topic}" --member="${user}" --role="${roleid}"
75+
gcloud pubsub subscriptions add-iam-policy-binding "${ps_bigquery_subscription}" --member="serviceAccount:${service_account}" --role="${roleid}"
7076
fi
7177

7278
#--- Deploy Cloud Run

broker/cloud_run/lsst/classify_upsilon/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# file (or packaged with the function) in the same directory as `main.py`
55

66
google-cloud-logging
7-
pittgoogle-client>=0.3.15
7+
pittgoogle-client>=0.3.17
88
upsilon
99
# required by upsilon
1010
# https://github.com/dwkim78/upsilon?tab=readme-ov-file#1-dependency

broker/cloud_run/lsst/ps_to_storage/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
google-cloud-logging
77
google-cloud-storage
8-
pittgoogle-client>=0.3.15
8+
pittgoogle-client>=0.3.17
99

1010
# for Cloud Run
1111
# https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-python-service

broker/cloud_run/lsst/variability/deploy.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ teardown="${2:-False}"
1111
survey="${3:-lsst}"
1212
region="${4:-us-central1}"
1313
# get the environment variable
14+
BASE_DIR=$(pwd)
1415
PROJECT_ID=$GOOGLE_CLOUD_PROJECT
16+
PROJECT_NUMBER=$(gcloud projects describe "$PROJECT_ID" --format="value(projectNumber)")
1517

1618
MODULE_NAME="variability" # lower case required by cloud run
1719
ROUTE_RUN="/" # url route that will trigger main.run()
@@ -36,6 +38,7 @@ ps_input_subscrip=$(define_GCP_resources "${survey}-${MODULE_NAME}") # pub/sub s
3638
ps_output_topic=$(define_GCP_resources "${survey}-${MODULE_NAME}")
3739
ps_trigger_topic=$(define_GCP_resources "${survey}-lite")
3840
runinvoker_svcact="cloud-run-invoker@${PROJECT_ID}.iam.gserviceaccount.com"
41+
service_account="service-${PROJECT_NUMBER}@gcp-sa-pubsub.iam.gserviceaccount.com"
3942
# topics and subscriptions involved in writing data to BigQuery
4043
ps_bigquery_subscription=$(define_GCP_resources "${survey}-${MODULE_NAME}-bigquery-import")
4144
ps_deadletter_topic=$(define_GCP_resources "${survey}-deadletter")
@@ -51,7 +54,8 @@ if [ "${teardown}" = "True" ]; then
5154
gcloud run services delete "${cr_module_name}" --region "${region}"
5255
fi
5356
else
54-
echo "Configuring Pub/Sub resources..."
57+
echo
58+
echo "Configuring Pub/Sub resources for ${MODULE_NAME} module..."
5559
gcloud pubsub topics create "${ps_output_topic}"
5660
gcloud pubsub subscriptions create "${ps_bigquery_subscription}" \
5761
--topic="${ps_output_topic}" \
@@ -60,12 +64,14 @@ else
6064
--drop-unknown-fields \
6165
--dead-letter-topic="${ps_deadletter_topic}" \
6266
--max-delivery-attempts=5 \
63-
--dead-letter-topic-project="${PROJECT_ID}"
67+
--dead-letter-topic-project="${PROJECT_ID}" \
68+
--message-transforms-file="${BASE_DIR%%/cloud_run/*}/setup_broker/lsst/templates/ps_lsst_flatten_schema_smt.yaml"
6469
# set IAM policies on public Pub/Sub resources
6570
if [ "$testid" = "False" ]; then
6671
user="allUsers"
67-
roleid="projects/${GOOGLE_CLOUD_PROJECT}/roles/userPublic"
72+
roleid="roles/pubsub.subscriber"
6873
gcloud pubsub topics add-iam-policy-binding "${ps_output_topic}" --member="${user}" --role="${roleid}"
74+
gcloud pubsub subscriptions add-iam-policy-binding "${ps_bigquery_subscription}" --member="serviceAccount:${service_account}" --role="${roleid}"
6975
fi
7076

7177
#--- Deploy Cloud Run service

broker/cloud_run/lsst/variability/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# file (or packaged with the function) in the same directory as `main.py`
55

66
google-cloud-logging
7-
pittgoogle-client>=0.3.15
7+
pittgoogle-client>=0.3.17
88

99
# for Cloud Run
1010
# https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-python-service

broker/consumer/lsst/vm_startup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fi
4444
) || exit
4545

4646
#--- Set the topic names to the "FORCE" metadata attributes if exist, else defaults
47-
KAFKA_TOPIC_DEFAULT="alerts-simulated"
47+
KAFKA_TOPIC_DEFAULT="lsst-alerts-v9.0"
4848
KAFKA_TOPIC="${KAFKA_TOPIC_FORCE:-${KAFKA_TOPIC_DEFAULT}}"
4949
PS_TOPIC="${PS_TOPIC_FORCE:-${PS_TOPIC_DEFAULT}}"
5050
# set VM metadata, just for clarity and easy viewing

0 commit comments

Comments
 (0)