-
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 code into palace.manager package (PP-1161) #1802
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1802 +/- ##
==========================================
- Coverage 90.31% 90.00% -0.31%
==========================================
Files 259 298 +39
Lines 28671 39642 +10971
Branches 6521 8597 +2076
==========================================
+ Hits 25893 35680 +9787
- Misses 1840 2630 +790
- Partials 938 1332 +394
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
3e1c27a
to
9a953d0
Compare
I'm still doing some testing locally to try to verify everything is still functional after the re-naming, but I think this is ready for a first round of review when folks have time. |
d43df19
to
760c4e7
Compare
@@ -4,9 +4,6 @@ | |||
# Temp files | |||
*~ | |||
|
|||
# Readmes | |||
**/*.md |
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.
Readme needs to be in the docker build for poetry to properly install the package
@@ -11,5 +11,5 @@ comment: | |||
|
|||
flag_management: | |||
default_rules: # the rules that will be followed for any flag added, generally | |||
carryforward: true | |||
carryforward: false |
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.
We changed the flags so if we keep carry forward enabled we will carry the old flags forward forever. I don't think carryforward is giving a lot of value here anyway. It really just masks problems when codecov fails to upload coverage, so I think turning it off makes sense.
@@ -31,15 +30,6 @@ | |||
# ... etc. | |||
|
|||
|
|||
# Import the models not included in models/__init__.py | |||
# This is required for autogenerate to work correctly | |||
from api.saml.metadata.federations.model import ( # noqa: autoflake |
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 is no longer necessary because all our models are in the same package and the init.py imports them
super().__init__(Goals.METADATA_GOAL) | ||
|
||
self.register(NYTBestSellerAPI, canonical="New York Times") | ||
self.register(NoveListAPI, canonical="NoveList Select") |
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.
The import changes were enough in this file that it's marked as removed, but the file still exists. It's just being counted by git as a removal and an add instead of a move.
@@ -88,51 +91,40 @@ create_pidfile () { | |||
create_dir $piddir | |||
|
|||
# Check that the script exists. | |||
FULL_SCRIPT_PATH=$LIBSIMPLE_DIR/bin/$SCRIPT_PATH | |||
FULL_SCRIPT_PATH=$PALACE_DIR/bin/$SCRIPT_PATH | |||
if [[ ! -f $FULL_SCRIPT_PATH ]]; then |
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.
Core/bin no longer exists so this script needed to be updated
from importlib.resources import files | ||
|
||
|
||
def resources_dir(subdir: str) -> Traversable: |
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.
We use this new function to load any content needed from the package. It uses importlib
to get the path to the package. This handles the various cases where our code could end up in different package locations.
|
||
"""These are files that are served by the CM in production, and aren't test suite specific.""" | ||
class FilesFixture: |
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 fixture is updated for the new import paths, and a number of the other separate files fixtures have all been centralized in this file.
initialize_application() | ||
|
||
# Make sure that the HTTP configuration was set | ||
mock_set_quick_failure_settings.assert_called_once() |
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 test was updated to use a mock. Previously the call it was making to initialize_application
was changing the global state for HTTP module, which caused other tests to fail. Using a mock here does the same test, but prevents this side effect.
from flask_pydantic_spec.utils import parse_multi_dict | ||
|
||
|
||
def add_request_context(request, model, form=None) -> 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.
This isn't new, it was just moved out of the tests package into mocks.
from palace.manager.api.sip.client import Constants | ||
|
||
|
||
class MockSIPClient(SIPClient): |
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 isn't new, but it was in the main package, so it got moved out to mocks
as part of this re-org.
@@ -31,12 +31,6 @@ def _parse_arguments(args: list[str]) -> argparse.Namespace: | |||
default=0, | |||
help="Increase verbosity", | |||
) | |||
parser.add_argument( | |||
"--report-schema-file", |
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.
Since these schema files are part of the package, it doesn't really make sense to pass them into the script anymore. Instead we load them from the package directly.
Codecov is reporting that coverage has decreased due to this PR. It looks like that is because we are now reporting coverage on all the files in the |
b1d07ad
to
d30fc4c
Compare
Pushed one small commit just now d30fc4c that resolves some issues I found when testing in the docker containers locally. These issues were causing the scripts not to run in the scripts container. |
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.
@@ -1,12 +1,12 @@ | |||
#!/bin/bash | |||
# | |||
# Ensures that Library Simplified Circulation Manager scripts don't run | |||
# Ensures that Palace Manager scripts don't run |
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.
Is there any reason for us not to abandon this script and instead using something that already does this like flock?
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.
Probably not worth changing it at this point, since it's used to run scripts via cron and those are going to be moved to the queue-based approach.
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 think it makes sense to keep whats here like @tdilauro mentioned, since this is going away soon. Nice to know flock exists though, I hadn't heard of it before, so I appreciate the tip.
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 like a temporary editing file. Should it be here?
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.
No it shouldn't. That is why the PR is deleting it 😄
Looks like its been in the repo for a looong time.
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 like a temporary editing file. Should it be here?
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.
No it shouldn't. That is why the PR is deleting it 😄
Looks like its been in the repo for a looong time.
@@ -1,12 +1,12 @@ | |||
#!/bin/bash | |||
# | |||
# Ensures that Library Simplified Circulation Manager scripts don't run | |||
# Ensures that Palace Manager scripts don't run |
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.
Probably not worth changing it at this point, since it's used to run scripts via cron and those are going to be moved to the queue-based approach.
Description
Move all the CM files into a namespace package called
palace
. The cm code is in thepalace.manager
sub-module.I started moving some of the code from
core
into the mainpalace.manager
package, but there is still more work to do there. We will probably want to continue moving things around after this PR, but this one is the most disruptive, since it moves all the code into the package, and moves around our database models.After this PR all our database models live at:
palace.manager.sqlalchemy.model.*
. I broke the import cycles that caused thelanes
andsaml
models to previously live elsewhere, so now all our DB models live in that module and importingpalace.manager.sqlalchemy.model
is enough to initialize them.The separate
customlists
package has also been moved into the mainpalace.manager
package.The large number of removals on this PR are due to fixture files that were removed, since they were not being used anywhere. Since we use relative paths to lookup the fixtures, I had to go through all these files anyway.
I went through and made comments on the PR in the parts of the code that I changed. I attempted to primarily move things around and not change much logic. The only logic changes that were made as part of this PR had to do with loading files based on paths, since the paths changed, and some of them moved into the package.
Motivation and Context
See PP-1161. Its helpful to be able to import our CM code, but previously this was impossible without messing with import paths since we didn't have a reliable package name.
Note: One major downside of this change is we no longer have the nice property of having two packages
api
andcore
to allow us to run tests in parallel. So all the tests have to run sequentially now, meaning CI runs take longer. I'm going to make a follow up ticket to see if there is anything we can do to make this a bit faster, since the test runs now take quite a lot longer.How Has This Been Tested?
Checklist