Princeton-LSI-ResearchComputing / tracebase

Mouse Metabolite Tracing Data Repository for the Rabinowitz Lab
MIT License
4 stars 1 forks source link

`TableLoader` updates for the submission refactor #1008

Closed hepcat72 closed 2 months ago

hepcat72 commented 3 months ago

Summary Change Description

Cherry-picked necessary updates to TableLoader to support the coming StudyLoader class.

StudyLoader does not directly update any models. It just calls other loaders, so TableLoader needed to be able to:

  1. have an empty Models class attribute.
  2. Allow StudyLoader to be able to raise 2 new exceptions: AggregatedErrorsSet and MultiLoadStatus instead of stuffing them into the member AggregatedErrors object. The AggregatedErrorsSet exception is unchanged and its usage in StudyLoader is the same exact usage in the old load_study.py script. Basically, it organizes all of the AggregatedErrors objects from all the different loaders into a dict keyed on study sheet name (load_study.py keyed them on file name). And TableLoader just needs to raise AggregatedErrorsSet and MultiLoadStatus when it sees them

I also added a bunch of is_error and is_fatal arguments to the methods that handle exceptions, though I didn't end up actually using them. The purpose at the time was to resolve an issue where animal loader warnings were somehow resulting in a rollback when it shouldn't have rolled back and the next loader (in order) couldn't access the records from the previous loader it depends on. That problem however turned out to be that I wasn't supplying defer_rollback=True in StudyLoader when it was calling the individual loaders, so I didn't actually need to pass those new arguments. But, it didn't hurt anything and it left the option open to treat exceptions how you want, so I left those changes in.

Affected Issues/Pull Requests

Review Notes

See comments in-line.

Checklist

This pull request will be merged once the following requirements are met. The author and/or reviewers should uncheck any unmet requirements:

hepcat72 commented 2 months ago

Merged via #1076