diff --git a/gracedb/models.py b/gracedb/models.py index 338e84a666ff77dce0cab61cea10d14fe6977bd9..d6eb575d40b4798b9ce4bfdf312f8c96181e5503 100644 --- a/gracedb/models.py +++ b/gracedb/models.py @@ -751,7 +751,11 @@ class SingleInspiral(models.Model): e = cls(event=event) #log.debug("Single/creating event") for column in field_names: - value = getattr(row, column) + try: + value = getattr(row, column) + except: + # We don't want to fail if the value is not present. + value = None #log.debug("Setting column '%s' with value '%s'" % (column, value)) setattr(e, column, value) e.save() diff --git a/gracedb/translator.py b/gracedb/translator.py index 1a596cba49b3077c13955374e11939dff95fd803..0a2ee6b4d5a99eb3a9b68b56ddedbed6e0e5c28a 100644 --- a/gracedb/translator.py +++ b/gracedb/translator.py @@ -19,8 +19,6 @@ from utils.vfile import VersionedFile import json -import logging - use_in(LIGOLWContentHandler) # This function checks for 'inf' in a float field, asks the database @@ -166,6 +164,9 @@ def handle_uploaded_data(event, datafilename, # Extract Single Inspiral Information s_inspiral_table = SnglInspiralTable.get_table(xmldoc) + # If this is a replacement, we might already have single inspiral tables + # associated. So we should re-create them. + event.singleinspiral_set.all().delete() SingleInspiral.create_events_from_ligolw_table(s_inspiral_table, event) elif pipeline == 'HardwareInjection':