-
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
Move storage integrations to be configured as services (PP-95) #1377
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1377 +/- ##
==========================================
+ Coverage 90.17% 90.22% +0.05%
==========================================
Files 226 229 +3
Lines 29871 29905 +34
Branches 6845 6831 -14
==========================================
+ Hits 26936 26983 +47
+ Misses 1893 1880 -13
Partials 1042 1042
☔ View full report in Codecov by Sentry. |
a13d3b1
to
fe97e88
Compare
d739045
to
3d690c5
Compare
This should be ready to merge now, once it gets a code review. All the dependant PRs have gone in, and its been rebased against the current |
I started looking at this yesterday and will continue today. |
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.
I'm still looking at the tests, but the app generally looks good. I do have a concern about relying on the Dependency Injector
project because it's not clear that it is being maintained (they haven't merged a PR in 9 months).
core/scripts.py
Outdated
if services is None: | ||
services = container_instance() | ||
self._services = services |
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.
Minor (style) - I think this is more clear as a ternary.
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.
Not sure I agree here, but I updated this one anyway.
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.
That's why it's "minor" and "style". I def won't be offended if you disagree or otherwise decide not to change it. I'll try to use "style pref" in the future, to make that more clear.
I generally like the ternary in these cases because it does two things:
- Makes it more clear to me that the main thing happening is that
self._services
is gonna get something assigned, either a specified value or a default. - Makes it impossible for what's happening in ll. 127-128 and l. 129 above to get separated in the code.
(2) here is also why I'm a fan of the walrus operator, though I never suggest that anyone change that one, since it seems more controversial.
|
||
|
||
class StorageConfiguration(ServiceConfiguration): | ||
region: str = "us-east-1" |
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.
Should we allow a default here? It might lead to some non-obvious misconfiguration.
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.
Okay. I removed the default here. This required a good number of code changes. I pushed a new commit that:
- Updates documentation
- Updates tests
- Adds new tests to s3 class constructor to make sure the URL template is consistent with the now optional region parameter.
I pushed a few commits resolving code review feedback.
Its hard to find a dependency injection container for Python. In the past I've found that constructor injection with a dependency injection container to wire up the dependencies is a helpful structure for webapps, and my hope is that we can slowly decouple our services this way. Despite not having any PRs merged in the last 9 months, the library does have 1 million downloads a month on Pypy making it by far the most popular dependency injection container I've found for Python. It also has well written documentation https://python-dependency-injector.ets-labs.org/ and has been around since 2015. There is a issue here ets-labs/python-dependency-injector#688 where the maintainer mentions that he considers the library feature complete at this point, but intends to support it to update python versions, dependency versions etc. If you have a suggestion of a different library, I'm willing to take a look at switching this code. Otherwise the library becoming unsupported is a risk, but IMO the immediate gain of decoupling our services is worth it. |
I'm fine with that (and agree about the docs). Just wanted to ensure that you were aware of the support situation. Along with the time since last commit, it was that same issue 688 along with issue 742 in that project that gave me pause. |
9a49beb
to
7371a07
Compare
7371a07
to
42586d2
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.
This looks good! 🚀
One question about whether a test might need a network connection.
|
||
def test_region_validation_fail(): | ||
with pytest.raises(CannotLoadConfiguration) as exc_info: | ||
StorageConfiguration(region="foo bar baz") |
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.
Does the StorageConfiguration
's validator's region check need a network connection?
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.
I don't think so, but I'll verify.
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.
Doesn't look like it. It seems like the available regions get loaded from the huge amount of json data that is included with botocore.
Description
Notes 🚨: (these are now all resolved)
The PR this is based on Remove collection content mirroring (PP-415) #1358 should get merged before this one does.This PR is dependant on an admin UI PR, that removes the admin UI side functionality for configuring storage integrations: Remove storage services component (PP-95) circulation-admin#87Before this is merged we will need to update our hosting-playbook to deploy the relevant environment variables our to our hosting environments. PR for this up here: https://github.com/ThePalaceProject/hosting-playbook/pull/489Motivation and Context
How Has This Been Tested?
Notes: The
docker-compose.yml
included in the repo was updated with the new environment variables, so that environment can be used for integration testing.docker-compose
environment./marc
endpoint.Checklist