gwcelery.tasks.alerts module

gwcelery.tasks.alerts.handler = {'fermi': [<@task: gwcelery.tasks.external_triggers.handle_targeted_kafka_alert of gwcelery>], 'swift': [<@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:

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 by gwcelery.tasks.em_bright.classifier() and gwcelery.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() and gwcelery.tasks.p_astro.compute_p_astro() or content of {gstlal,mbta}.p_astro.json uploaded by {gstlal,mbta} respectively; or None

  • superevent (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