Skip to content

Commit

Permalink
address codacy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hernandezc1 committed Apr 29, 2024
1 parent 6970abd commit 94972a8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
1 change: 0 additions & 1 deletion broker/consumer/lvk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

See `broker/setup_broker/lvk/README.md` for setup instructions.


To start the consumer VM:

```bash
Expand Down
22 changes: 11 additions & 11 deletions broker/consumer/vm_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ gsutil -m cp -r "gs://${broker_bucket}/consumer" .
gsutil -m cp -r "gs://${broker_bucket}/schema_maps" .
# wait. otherwise the script may continue before all files are downloaded, with adverse behavior.
sleep 30s
cd ${workingdir}
cd "${workingdir}"

#--- Set the topic names to the "FORCE" metadata attributes if exist, else defaults
kafka_topic_syntax=$(cat "${brokerdir}/schema_maps/${survey}.yaml" | yq ".TOPIC_SYNTAX")
Expand Down Expand Up @@ -82,8 +82,8 @@ do
/bin/kafka-topics \
--bootstrap-server public2.alerts.ztf.uw.edu:9094 \
--list \
--command-config ${workingdir}/admin.properties \
> ${fout_topics}
--command-config "${workingdir}/admin.properties" \
> "${fout_topics}"
} || {
true
}
Expand All @@ -92,14 +92,14 @@ do
/bin/kafka-topics \
--bootstrap-server public.alerts.ztf.uw.edu:9092 \
--list \
> ${fout_topics}
> "${fout_topics}"
} || {
true
}
fi

# check if our topic is in the list
if grep -Fq "${KAFKA_TOPIC}" $fout_topics
if grep -Fq "${KAFKA_TOPIC}" "$fout_topics"
then
alerts_flowing=true # start consuming
else
Expand All @@ -111,12 +111,12 @@ done
if [ "${USE_AUTHENTICATION}" = true ]
then
/bin/connect-standalone \
${workingdir}/psconnect-worker-authenticated.properties \
${workingdir}/ps-connector.properties \
&>> ${fout_run}
"${workingdir}/psconnect-worker-authenticated.properties" \
"${workingdir}/ps-connector.properties" \
&>> "${fout_run}"
else
/bin/connect-standalone \
${workingdir}/psconnect-worker-unauthenticated.properties \
${workingdir}/ps-connector.properties \
&>> ${fout_run}
"${workingdir}/psconnect-worker-unauthenticated.properties" \
"${workingdir}/ps-connector.properties" \
&>> "${fout_run}"
fi
12 changes: 6 additions & 6 deletions broker/setup_broker/lvk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ April 2024 - Author: Christopher Hernandez

## Overview

Check notice on line 11 in broker/setup_broker/lvk/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

broker/setup_broker/lvk/README.md#L11

Expected: 1; Actual: 0; Below
Gravitational-wave transients detected by the LIGO, Virgo, and KAGRA network are distributed publicly as
machine-readable alerts through
machine-readable alerts through
[General Coordinates Network (GCN) Notices](https://gcn.nasa.gov/docs/notices#gcn-notices).
Here are some links which were used as a reference to set this up:

Expand All @@ -21,7 +21,7 @@ Below is the code I used to set up the necessary resources in GCP to ingest the

## Setup

Check notice on line 22 in broker/setup_broker/lvk/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

broker/setup_broker/lvk/README.md#L22

Expected: 1; Actual: 0; Below
The following assumes that you have:
- Completed the [GCN Notices quick start guide](https://gcn.nasa.gov/quickstart) and identified your client
- Completed the [GCN Notices quick start guide](https://gcn.nasa.gov/quickstart) and identified your client

Check notice on line 24 in broker/setup_broker/lvk/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

broker/setup_broker/lvk/README.md#L24

Lists should be surrounded by blank lines
credentials. This includes a client ID and client secret
- Set the environment variables `GOOGLE_CLOUD_PROJECT` and `GOOGLE_APPLICATION_CREDENTIALS` to appropriate values for
your GCP project and service account credentials
Expand All @@ -34,7 +34,6 @@ You may want to
or
[set up a GCP project from scratch](https://pitt-broker.readthedocs.io/en/latest/broker/run-a-broker-instance/initial-setup.html#setup-local-environment).


[Create secrets](https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets#create) for your client ID
and client secret

Expand All @@ -56,7 +55,7 @@ gcloud secrets create "${client_secret}" \
```

Select one of the following options to add a secret version. Note that adding a version directly on the command line is
discouraged by Google Cloud, see
discouraged by Google Cloud, see
[add a secret version documentation](https://cloud.google.com/secret-manager/docs/add-secret-version#add-secret-version)
for details.

Expand All @@ -72,7 +71,8 @@ echo -n "enter the client secret provided by GCN" | \
gcloud secrets versions add "${client_secret}" --data-file=-
```

Access the [IAM & Admin page](https://console.cloud.google.com/iam-admin) and grant the default compute service account the role of `Secret Manager Secret Accessor`
Access the [IAM & Admin page](https://console.cloud.google.com/iam-admin) and grant the default compute service account
the role of `Secret Manager Secret Accessor`.

```bash
user="[enter compute service account prefix]@developer.gserviceaccount.com"
Expand Down Expand Up @@ -102,7 +102,7 @@ region="us-central1"

This will create all of the necessary GCP resources. Allow the consumer VM to finish its installation process. Once
complete, the VM will shut down automatically. You can check the status of the VM in the
[Google Cloud Console](https://console.cloud.google.com/compute).
[Google Cloud Console](https://console.cloud.google.com/compute).
This entire process should take less than 10 minutes.

## Start the Consumer VM to ingest the LVK alert stream
Expand Down
2 changes: 0 additions & 2 deletions broker/setup_broker/lvk/setup_broker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ fi
#--- GCP resources used directly in this script
broker_bucket="${PROJECT_ID}-${survey}-broker_files"
topic_alerts="${survey}-alerts"
client_id="${survey}-${PROJECT_ID}-client-id"
client_secret="${survey}-${PROJECT_ID}-client-secret"
# use test resources, if requested
if [ "$testid" != "False" ]; then
broker_bucket="${broker_bucket}-${testid}"
Expand Down

0 comments on commit 94972a8

Please sign in to comment.