Skip to content

Commit

Permalink
Removed fallback logic and changed file path (aces#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffersoncasimir authored Jul 17, 2023
1 parent 3688406 commit f8e313c
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions python/lib/eeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,37 +733,14 @@ def fetch_and_insert_event_files(
event_path = self.copy_file_to_loris_bids_dir(
event_data_file.path, derivatives
)

# get the blake2b hash of the task events file
blake2 = utilities.compute_blake2b_hash(event_file.path)
blake2 = utilities.compute_blake2b_hash(event_data_file.path)

# insert event data in the database
# TODO: Temporary
# TODO: should not have two different insert_event_file methods
# TODO: remove this TRY/CATCH and the legacy method when
# TODO: all LORIS code will support additional events.
insert_fallback = False
msg = ""
try:
physiological.insert_event_file(
event_data, event_path, physiological_file_id, blake2
)
except NameError:
# when the insert_event_file function does not exist
msg = "WARNING: function 'insert_event_file' not found. Using fallback method."
insert_fallback = True
except Exception as ex:
# when event table structure is still the old one
if ex.args[0] and ex.args[0].startswith("Insert query failure: "):
msg = "WARNING: error during DB insert. Using fallback method."
insert_fallback = True
else:
# re-raise other errors from db insert
raise ex
# insert fallback, call legacy method
if insert_fallback:
print(msg)
physiological.insert_event_file_legacy(
event_data, event_path, physiological_file_id, blake2
)
physiological.insert_event_file(
event_data, event_path, physiological_file_id, blake2
)

event_paths.extend([event_path])

Expand Down

0 comments on commit f8e313c

Please sign in to comment.