Schedule Night Conductor¶
Cloud Scheduler cron job -> Pub/Sub -> Cloud Function -> start VM
[Cloud Scheduler] Define a schedule on which Pub/Sub messages will be published
[Pub/Sub]
[Cloud Function]
cue_night_conductor
: listens to a PS topic, sets metadata onnight-conductor
, startsnight-conductor
Scheduling compute instances with Cloud Scheduler
replace their CF with our own
[Python Examples for Cloud Function]
export GCP_PROJECT=$GOOGLE_CLOUD_PROJECT
export TESTID=v050
export SURVEY=ztf
export ZONE="us-central1-a"
Test the Pub/Sub message:
# import base64
from pgb_utils import pubsub as pgbps
survey="ztf"
testid="v050"
topic_name = f'{survey}-cue_night_conductor-{testid}'
# topic_name = 'test'
cue = b'START'
attrs = {'topic_date': 'False'}
# cue = base64.b64encode('START'.encode('utf-8'))
fut = pgbps.publish(topic_name, cue, attrs=attrs)
msg = pgbps.pull(topic_name, msg_only=False)
attrs = msg[0][0].message.attributes