Skip to content

Commit e3f9df2

Browse files
committed
updates v0.5.0 tracking docs
1 parent 6fe9bd1 commit e3f9df2

File tree

2 files changed

+52
-64
lines changed

2 files changed

+52
-64
lines changed

version_tracking/v0.5.0/README.md

Lines changed: 15 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
# v0.5.0
22

3+
- [Results Summary](#results-summary)
34
- [Documentation of Changes](#documentation-of-changes)
45
- [Test the Changes](#test-the-changes)
5-
- [Results Summary](#results-summary)
6+
7+
---
8+
9+
## Results Summary
10+
11+
Auto-scheduler and cue-response checker appear to be working smoothly.
12+
13+
Documentation is back up on ReadTheDocs.
614

715
---
816

917
## Documentation of Changes
1018

1119
- PR [#62](https://github.com/mwvgroup/Pitt-Google-Broker/pull/62)
12-
- [schedule-night-conductor.md](schedule-night-conductor.md)
13-
- [external-connection.md](external-connection.md)
14-
20+
- Auto-scheduler: [schedule-night-conductor.md](schedule-night-conductor.md)
21+
- Pub/Sub tutorial setup:
22+
- [external-connection.md](external-connection.md) (setup an external GCP project and connect to our Pub/Sub streams)
23+
- [stream-looper.md](stream-looper.md) (setup a VM to run a consumer simulator that publishes ZTF alerts to a dedicated PS topic on a slow loop)
1524

25+
Started but didn't finish; TODO in a future version:
26+
- [supernnova.md](supernnova.md) (implement SuperNNova)
1627

1728
---
1829

@@ -89,52 +100,4 @@ attr=topic_date=20210727
89100
gcloud pubsub topics publish "$topic" --message="$cue" --attribute="$attr"
90101
```
91102

92-
#### consumer sim, tbd
93-
94-
95-
start/stop the broker
96-
```bash
97-
survey=ztf
98-
testid=v050
99-
topic="${survey}-cue_night_conductor-${testid}"
100-
101-
# start the night
102-
cue=START
103-
attr=KAFKA_TOPIC=NONE # leave consumer VM off
104-
gcloud pubsub topics publish "$topic" --message="$cue" --attribute="$attr"
105-
106-
# end the night
107-
cue=END
108-
gcloud pubsub topics publish "$topic" --message="$cue"
109-
```
110-
111-
```python
112-
from broker_utils import consumer_sim as bcs
113-
114-
testid = 'v050'
115-
survey = 'decat'
116-
sub_id = 'decat-alerts-reservoir-testschema' # production instance doesn't exist yet
117-
# survey = 'ztf'
118-
# sub_id = 'ztf_alerts-reservoir' # production instance names are not yet updated
119-
instance = (survey, testid)
120-
# alert_rate = (100, 'once')
121-
alert_rate = 'ztf-active-avg'
122-
runtime = (30, 'min') # options: 'sec', 'min', 'hr', 'night'(=10 hrs)
123-
124-
bcs.publish_stream(alert_rate, instance, sub_id=sub_id, runtime=runtime)
125-
```
126-
```bash
127-
# end the night
128-
NIGHT="END"
129-
gcloud compute instances add-metadata "$nconductVM" --zone="$zone" \
130-
--metadata NIGHT="$NIGHT"
131-
gcloud compute instances start "$nconductVM" --zone "$zone"
132-
```
133-
134103
<!-- fe Test the Changes -->
135-
136-
137-
138-
---
139-
140-
## Results Summary

version_tracking/v0.5.0/stream-looper.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## Setup stream-looper VM and topic
1+
# Setup stream-looper VM and topic
2+
3+
## Create the Pub/Sub topic and allow public subscriptions
24

3-
Create the topic and allow public subscriptions
45
```bash
56
PROJECT=$GOOGLE_CLOUD_PROJECT
67
TOPIC="ztf-loop"
@@ -15,7 +16,8 @@ gcloud pubsub topics get-iam-policy $topic_path --format yaml > $fnametmp
1516
gcloud pubsub topics set-iam-policy $topic_path $fname
1617
```
1718

18-
Create the VM and setup the consumer simulator
19+
## Create the VM and setup the consumer simulator
20+
1921
```bash
2022
vmname="stream-looper"
2123
zone="us-central1-a"
@@ -34,21 +36,44 @@ gcloud compute instances create "$vmname" \
3436
gcloud compute instances add-metadata "$vmname" --zone="$zone" --metadata=startup-script=""
3537

3638
# ssh in
37-
gcloud compute ssh $vmname
38-
screen
39-
ipython3
39+
# gcloud compute ssh $vmname
4040
```
41+
42+
### Set a startup script to run consumer simulator indefinitely
43+
44+
Python script to trigger at startup.
45+
Save the following code to a root-executable file at
46+
/home/consumer_sim/run-looper-indefinitely.py:
47+
4148
```python
49+
#!/usr/bin/env python3
50+
# -*- coding: UTF-8 -*-
4251
from broker_utils import consumer_sim as bcs
4352

44-
# publish 1 alert every 5 seconds
45-
alert_rate = (12, 'perMin')
53+
# set args to publish 1 alert every second
54+
alert_rate = (60, 'perMin')
4655
kwargs = {
4756
'instance': None,
48-
'runtime': (1, 'hr'),
49-
'publish_batch_every': (5, 'sec'),
50-
'sub_id': 'ztf-alerts-reservoir-v050',
57+
'runtime': (1, 'night'),
58+
'publish_batch_every': (1, 'sec'),
59+
'sub_id': 'ztf-alerts-reservoir',
5160
'topic_id': 'ztf-loop',
61+
'auto_confirm': True,
5262
}
53-
bcs.publish_stream(alert_rate, **kwargs)
63+
64+
# run indefinitely
65+
while True:
66+
bcs.publish_stream(alert_rate, **kwargs)
67+
```
68+
69+
Set a startup script to execute the python file in a background thread:
70+
```bash
71+
startupscript="#! /bin/bash
72+
dir=/home/consumer_sim/
73+
fname=run-looper-indefinitely
74+
nohup python3 \${dir}\${fname}.py >> \${dir}\${fname}.out 2>&1 &
75+
"
76+
77+
# set the startup script
78+
gcloud compute instances add-metadata "$vmname" --metadata=startup-script="$startupscript"
5479
```

0 commit comments

Comments
 (0)