gwcelery.tasks.alerts module¶
- gwcelery.tasks.alerts.handler = {'fermi_gbm_alert': [<@task: gwcelery.tasks.external_triggers.handle_grb_gcn of gwcelery>], 'fermi_gbm_fin_pos': [<@task: gwcelery.tasks.external_triggers.handle_grb_gcn of gwcelery>], 'fermi_gbm_flt_pos': [<@task: gwcelery.tasks.external_triggers.handle_grb_gcn of gwcelery>], 'fermi_gbm_gnd_pos': [<@task: gwcelery.tasks.external_triggers.handle_grb_gcn of gwcelery>], 'fermi_gbm_subthresh': [<@task: gwcelery.tasks.external_triggers.handle_grb_gcn of gwcelery>], 'fermi_targeted': [<@task: gwcelery.tasks.external_triggers.handle_targeted_kafka_alert of gwcelery>], 'integral_offline': [<@task: gwcelery.tasks.external_triggers.handle_grb_gcn of gwcelery>], 'integral_refined': [<@task: gwcelery.tasks.external_triggers.handle_grb_gcn of gwcelery>], 'integral_wakeup': [<@task: gwcelery.tasks.external_triggers.handle_grb_gcn of gwcelery>], 'snews': [<@task: gwcelery.tasks.external_triggers.handle_snews_gcn of gwcelery>], 'swift_bat_grb_pos_ack': [<@task: gwcelery.tasks.external_triggers.handle_grb_gcn of gwcelery>], 'swift_targeted': [<@task: gwcelery.tasks.external_triggers.handle_targeted_kafka_alert of gwcelery>]}¶
Function decorator to register a handler callback for specified Kafka URLs. The decorated function is turned into a Celery task, which will be automatically called whenever a message is received from a matching URL.
- Parameters:
*keys – List of keys from
gwcelery.conf.kafka_consumer_config
associated with Kafka topics to listen to messages to.**kwargs – Additional keyword arguments for
celery.Celery.task()
.
Examples
Declare a new handler like this:
# Assumes kafka_consumer_config dictionary has 'fermi_swift' key @alerts.handler('fermi_swift') def handle_swift(record): # record is a dict that contains the contents of the message # do work here...
- (task)gwcelery.tasks.alerts._add_external_coinc_to_alert(alert_dict, superevent, combined_skymap_filename)[source]¶
Proxy that evaluates object once.
Proxy
will evaluate the object each time, while the promise will only evaluate it once.
- (task)gwcelery.tasks.alerts._upload_notice(payload, brokerhost, superevent_id)[source]¶
Upload serialized alert notice to GraceDB
- (task)gwcelery.tasks.alerts._send(alert_dict, skymap, brokerhost, combined_skymap=None)[source]¶
Write the alert to the Kafka topic
- (task)gwcelery.tasks.alerts._send_with_combined(alert_dict_combined_skymap, skymap, brokerhost)[source]¶
Proxy that evaluates object once.
Proxy
will evaluate the object each time, while the promise will only evaluate it once.
- (task)gwcelery.tasks.alerts.send(skymap_and_classification, superevent, alert_type, raven_coinc=False, combined_skymap_filename=None)[source]¶
Send an public alert to all currently connected kafka brokers.
- Parameters:
skymap_and_classification (tuple, None) – The filecontents of the skymap followed by a collection of JSON strings. The former generated by
gwcelery.tasks.gracedb.download()
, the latter generated bygwcelery.tasks.em_bright.classifier()
andgwcelery.tasks.p_astro.compute_p_astro()
or content of{gstlal,mbta}.p_astro.json
uploaded by {gstlal,mbta} respectively. Can also be None.superevent (dict) – The superevent dictionary, typically obtained from an IGWN Alert or from querying GraceDB.
alert_type (str) – The alert type. Either of {less-significant, earlywarning, preliminary, initial, update}.
raven_coinc (bool) – Is there a coincident external event processed by RAVEN?
combined_skymap_filename (str) – Combined skymap filename. Default None.
Notes
The alert_type value is used to set the significant field in the alert dictionary.
- (task)gwcelery.tasks.alerts._create_skymap_classification_tuple(skymap, classification)[source]¶
Proxy that evaluates object once.
Proxy
will evaluate the object each time, while the promise will only evaluate it once.
- (task)gwcelery.tasks.alerts.download_skymap_and_send_alert(classification, superevent, alert_type, skymap_filename=None, raven_coinc=False, combined_skymap_filename=None)[source]¶
Wrapper for send function when caller has not already downloaded the skymap.
- Parameters:
classification (tuple, None) – A collection of JSON strings, generated by
gwcelery.tasks.em_bright.classifier()
andgwcelery.tasks.p_astro.compute_p_astro()
or content of{gstlal,mbta}.p_astro.json
uploaded by {gstlal,mbta} respectively; or Nonesuperevent (dict) – The superevent dictionary, typically obtained from an IGWN Alert or from querying GraceDB.
alert_type ({'earlywarning', 'preliminary', 'initial', 'update'}) – The alert type.
skymap_filename (string) – The skymap filename.
raven_coinc (bool) – Is there a coincident external event processed by RAVEN?
combined_skymap_filename (str) – The combined skymap filename. Default None