Adding superevent categories

Adding superevent categories (production, test, mdc) to
createSuperevent() with default: production.  Also updated
utils to recognize superevent prefixes for test and mdc events.
parent f3d84ef5
......@@ -439,6 +439,10 @@ class GraceDb(GsiRest):
def voevent_types(self):
return self.service_info.get('voevent-types')
def superevent_categories(self):
return self.service_info.get('superevent-categories')
def request(self, method, *args, **kwargs):
if method.lower() in ['post', 'put']:
kwargs['priming_url'] = self.service_url
......@@ -633,7 +637,7 @@ class GraceDb(GsiRest):
return self.get(uri).json()['numRows']
def createSuperevent(self, t_start, t_0, t_end, preferred_event,
events=[], labels=None):
category='production', events=[], labels=None):
Create a superevent.
......@@ -647,6 +651,7 @@ class GraceDb(GsiRest):
t_end: t_end of superevent
preferred_event: graceid corresponding to event which will be set
as the preferred event for this superevent
category: superevent category ('production', 'test', 'mdc')
events: list of graceids corresponding to events which
should be attached to this superevent (optional)
labels: list of labels which should be attached to this
......@@ -655,8 +660,9 @@ class GraceDb(GsiRest):
>>> g = GraceDb()
>>> r = g.createSuperevent(1,2,3, preferred_event='G123456',
... events=['G100', 'G101'], labels=['EM_READY', 'DQV'])
>>> r = g.createSuperevent(1, 2, 3, 'G123456',
... category='production', events=['G100', 'G101'],
... labels=['EM_READY', 'DQV'])
>>> r.status
......@@ -684,12 +690,20 @@ class GraceDb(GsiRest):
raise TypeError("events arg is {0}, should be str or list" \
# validate category, convert to short form if necessary
category = self._getCode(category.lower(),
if not category:
raise ValueError("category must be one of: {0}".format(
# Set up request body for POST
request_body = {
't_start': t_start,
't_0': t_0,
't_end': t_end,
'preferred_event': preferred_event,
'category': category,
if events:
request_body['events'] = events
......@@ -10,7 +10,7 @@ from subprocess import Popen, PIPE
if == 'posix':
import pwd
superevent_prefix_regex = re.compile(r'^({prefixes})\d+'.format(
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment