From 6da79de01a00757e2bb6096a7534f548031c0f1a Mon Sep 17 00:00:00 2001 From: Alexander Pace <alexander.pace@ligo.org> Date: Wed, 10 May 2023 20:48:35 -0500 Subject: [PATCH 1/2] fix handle_uploaded_data The file version *in log messages* for initial/replacement uploads was set to zero in all cases. And since the web file view uses gracedb's logs and not the actual folder contents, that was broken. This passes the file version as an argument and fixes this issue. --- gracedb/api/v1/events/views.py | 2 +- gracedb/events/translator.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gracedb/api/v1/events/views.py b/gracedb/api/v1/events/views.py index ded736275..e4cb61e13 100644 --- a/gracedb/api/v1/events/views.py +++ b/gracedb/api/v1/events/views.py @@ -628,7 +628,7 @@ class EventDetail(InheritPermissionsAPIView): # Extract Info from uploaded data uploadDestination = os.path.join(event.datadir, f.name) - handle_uploaded_data(event, uploadDestination) + handle_uploaded_data(event, uploadDestination, file_version=version) event.submitter = request.user # Save event diff --git a/gracedb/events/translator.py b/gracedb/events/translator.py index 3a851443d..4c0f332b8 100644 --- a/gracedb/events/translator.py +++ b/gracedb/events/translator.py @@ -75,6 +75,7 @@ def cleanData(val, field_name, table_name='events_event'): raise ValueError("Unrecognized value in column %s" % field_name) def handle_uploaded_data(event, datafilename, + file_version=0, log_filename='event.log', coinc_table_filename='coinc.xml', file_contents=None): @@ -86,7 +87,7 @@ def handle_uploaded_data(event, datafilename, base_file_name = os.path.basename(datafilename) log = EventLog(event=event, filename=base_file_name, - file_version=0, + file_version=file_version, issuer=event.submitter, comment="Original Data") log.save() -- GitLab From 647d87e3ce08f79af5214b62a9eebe71a49b1e91 Mon Sep 17 00:00:00 2001 From: Alexander Pace <alexander.pace@ligo.org> Date: Thu, 11 May 2023 09:32:50 -0500 Subject: [PATCH 2/2] change log message for event replacement it used to always say "Original Data", which isn't strictly true, in the sense that it was completely false. --- gracedb/events/translator.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gracedb/events/translator.py b/gracedb/events/translator.py index 4c0f332b8..7cd1cad05 100644 --- a/gracedb/events/translator.py +++ b/gracedb/events/translator.py @@ -82,6 +82,15 @@ def handle_uploaded_data(event, datafilename, # This is the base file name of the event creation upload: base_file_name = '' + + # The log message should be "Original Data" if it's the initial upload + # (file_version=0), but should reflect that it's an update/replacement + # otherwise. + if not bool(file_version): + comment = "Original Data" + else: + comment = "Event data replaced by new upload" + if datafilename: # Extract the base filename from the upload: base_file_name = os.path.basename(datafilename) @@ -89,7 +98,7 @@ def handle_uploaded_data(event, datafilename, filename=base_file_name, file_version=file_version, issuer=event.submitter, - comment="Original Data") + comment=comment) log.save() # XXX If you can manage to get rid of the MBTA .gwf parsing and -- GitLab