Skip to content

Commit

Permalink
chore: add logging to DRS ingestion
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Oct 25, 2023
1 parent 2403a0b commit e42a1ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion chord_drs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class DrsBlob(db.Model, DrsMixin):
location = db.Column(db.String(500), nullable=False)

def __init__(self, *args, **kwargs):
logger = current_app.logger

# If set, we are deduplicating with an existing file object
object_to_copy: DrsBlob | None = kwargs.get("object_to_copy")

Expand Down Expand Up @@ -104,10 +106,12 @@ def __init__(self, *args, **kwargs):
self.size = os.path.getsize(p)
self.checksum = drs_file_checksum(location)
except Exception as e:
current_app.logger.error(f"Encountered exception during DRS object creation: {e}")
logger.error(f"Encountered exception during DRS object creation: {e}")
# TODO: implement more specific exception handling
raise Exception("Well if the file is not saved... we can't do squat")

logger.info(f"Creating new DRS object: name={self.name}; size={self.size}; sha256={self.checksum}")

for key_to_remove in ("location", "filename"):
if key_to_remove in kwargs:
del kwargs[key_to_remove]
Expand Down
1 change: 1 addition & 0 deletions chord_drs/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ def object_ingest():
try:
filename: str | None = None # no override, use path filename if path is specified instead of a file upload
if file is not None:
logger.debug(f"ingest - recieved file object: {file}")
file.save(t_obj_path)
obj_path = t_obj_path
filename = file.filename # still may be none, in which case the temporary filename will be used
Expand Down

0 comments on commit e42a1ae

Please sign in to comment.