Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org on Tuesday 22nd September 2020 starting at approximately 9am MST.It is expected to take around 15 minutes and there will be a short period of downtime towards the end of the maintenance window. Please address any comments, questions, or concerns to computing-help@igwn.org.

Commit a6bacaf7 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

events: bugfix voevent population migration

Found a few more edge cases when applying this in production,
so I'm patching this migration retroactively.
parent 44cc57ab
......@@ -89,19 +89,34 @@ def populate_values(voevent, event_or_superevent):
# Parse parameters
for parameter in PARAMETER_MAPPINGS:
result = None
for path in PARAMETER_MAPPINGS[parameter]:
result = None
try:
result = root.find(path)
except SyntaxError as e:
pass
else:
# If result is not None, we've found something, so let's break
if result is not None:
break
if result is None:
# not found, likely due to an old VOEvent schema
continue
# Special parameter parsing
if parameter in ['hardware_inj', 'internal', 'open_alert']:
value = bool(int(result.attrib['value']))
# Better bool processing
try:
value = bool(int(result.attrib['value']))
except ValueError:
value = result.attrib['value']
if value.lower() in ['f', '0', 'false']:
value = False
elif value.lower() in ['t', '1', 'true']:
value = True
else:
raise ValueError("Can't process value {0}".format(value))
elif parameter == 'skymap_filename':
value = result.attrib['value'].split('/')[-1]
elif parameter == 'skymap_type':
......@@ -118,9 +133,10 @@ def populate_values(voevent, event_or_superevent):
for parameter, str_list in DESCRIPTION_PARAMETER_MAPPINGS.items():
for s in str_list:
if any([s in dp for dp in desc_text]):
setattr(voevent, parameter, True)
value = True
else:
setattr(voevent, parameter, False)
value = False
setattr(voevent, parameter, value)
# Save VOEvent
voevent.save()
......
......@@ -86,12 +86,17 @@ def populate_values(voevent, event_or_superevent):
# Parse parameters
for parameter in PARAMETER_MAPPINGS:
result = None
for path in PARAMETER_MAPPINGS[parameter]:
result = None
try:
result = root.find(path)
except SyntaxError as e:
pass
else:
# If result is not None, we've found something, so let's break
if result is not None:
break
if result is None:
continue
......@@ -114,9 +119,10 @@ def populate_values(voevent, event_or_superevent):
for parameter, str_list in DESCRIPTION_PARAMETER_MAPPINGS.items():
for s in str_list:
if any([s in dp for dp in desc_text]):
setattr(voevent, parameter, True)
value = True
else:
setattr(voevent, parameter, False)
value = False
setattr(voevent, parameter, value)
# Save VOEvent
voevent.save()
......
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