-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor LoanInfo and HoldInfo to be dataclasses (PP-1728) #2113
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2113 +/- ##
==========================================
+ Coverage 90.69% 90.72% +0.02%
==========================================
Files 351 351
Lines 40878 40878
Branches 8858 8853 -5
==========================================
+ Hits 37073 37085 +12
+ Misses 2493 2486 -7
+ Partials 1312 1307 -5 ☔ View full report in Codecov by Sentry. |
This one has some missing coverage, but all the lines that are not covered, we not previously covered, so I think it should be fine to merge as is. |
d490e4b
to
4e69c0c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. I made a few minor suggestions. Feel free to correct as you see fit before merging.
src/palace/manager/api/axis.py
Outdated
def process_one(self, e: _Element, namespaces: dict[str, str] | None) -> LoanInfo: | ||
def process_one( | ||
self, e: _Element, namespaces: dict[str, str] | None | ||
) -> datetime.datetime | None: | ||
"""Either turn the given document into a LoanInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the doc needs to be updated
src/palace/manager/api/odl/api.py
Outdated
holdinfo = HoldInfo.from_license_pool( | ||
licensepool, | ||
start_date=utc_now(), | ||
end_date=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this line be removed since None is the default for end date?
start_date=None, | ||
end_date=None, | ||
hold_position=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these lines be removed since None
is the default for start_date, end_date and hold_position?
None, | ||
hold_info = HoldInfo.from_license_pool( | ||
licensepool, | ||
start_date=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
src/palace/manager/api/overdrive.py
Outdated
licensepool.identifier.type, | ||
licensepool.identifier.identifier, | ||
return HoldInfo.from_license_pool( | ||
licensepool, | ||
start_date=start_date, | ||
end_date=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed.
start_date=None, | ||
end_date=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
start_date=None, | ||
end_date=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
LoanInfo.from_license_pool( | ||
pool, | ||
start_date=utc_now(), | ||
end_date=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
start_date=None, | ||
end_date=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
start_date=None, | ||
end_date=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
Description
Refactor
LoanInfo
andHoldInfo
to be simple dataclasses, and move the logic for creating and updating loans and holds from aLoanInfo
orHoldInfo
into a method calledcreate_or_update
.In the process, I removed the
Hold.external_identifier
column, which appears to be unused.Motivation and Context
Needed to modify how
LoanInfo
andHoldInfo
are used as part of PP-1728, this refactor makes that work easier, but I thought it would be easier to understand as a separate PR.How Has This Been Tested?
Checklist