PP-35 Migrate license goal integrations ⛰️ #1189
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1189 +/- ##
==========================================
- Coverage 89.94% 89.88% -0.06%
==========================================
Files 195 197 +2
Lines 29203 29451 +248
Branches 6714 6749 +35
==========================================
+ Hits 26266 26473 +207
- Misses 1913 1946 +33
- Partials 1024 1032 +8
☔ View full report in Codecov by Sentry. |
de63c98 to
e6b4a53
Compare
There was a problem hiding this comment.
This file contains all the Admin UI functionality for the Collections page
| settings = getattr(api, "SETTINGS", []) | ||
| protocol["settings"] = list(settings) | ||
| if _db and issubclass(api, HasIntegrationConfiguration): | ||
| protocol["settings"] = api.settings_class().configuration_form(_db) |
There was a problem hiding this comment.
Both cls.SETTINGS and def settings_class must coexist while some integrations still use external integrations.
| lcp_server = LCPServer( | ||
| configuration_storage, | ||
| configuration_factory, | ||
| self.configuration, |
There was a problem hiding this comment.
Notice that we pass in a callable.
| lcp_server = LCPServer( | ||
| configuration_storage, | ||
| configuration_factory, | ||
| integration_association.configuration, |
There was a problem hiding this comment.
This is a Callable.
api/lcp/server.py
Outdated
| self, | ||
| configuration_storage, | ||
| configuration_factory, | ||
| get_configuration, |
There was a problem hiding this comment.
Rather than a configuration factory and storage we use a get_configuration Callable to ensure the configuration values we pull at runtime are always pulled from the database and not an in-memory object.
| NUMBER = "number" | ||
|
|
||
| @classmethod | ||
| def options_from_enum(cls, enum_: Type[Enum]) -> Dict[Enum | str, str]: |
There was a problem hiding this comment.
The return type is actually Dict[str, str] but due to type invariance of the ConfigurationFormItem.options attribute we must match the typing.
| NUMBER = "number" | ||
|
|
||
| @classmethod | ||
| def options_from_enum(cls, enum_: Type[Enum]) -> Dict[Enum | str, str]: |
There was a problem hiding this comment.
The return type is actually Dict[str, str] but due to type invariance of the ConfigurationFormItem.options attribute we must match the typing.
| IntegrationConfiguration.settings[ | ||
| Collection.DATA_SOURCE_NAME_SETTING | ||
| ].astext | ||
| == data_source |
jonathangreen
left a comment
There was a problem hiding this comment.
Wow, this looks like it was a lot of work! Thanks for this, PR is looking good. I added some comments with a few things, as well as the change we talked about to move away from using the dict lookups directly.
alembic/versions/20230531_0af587ff8595_migrate_license_integrations_to_.py
Outdated
Show resolved
Hide resolved
… the API implementations Added a BaseCirculationAPIProtocol for mypy reasons
50441c3 to
c9cd6f4
Compare
|
I think the code here is looking good @RishiDiwanTT. Before merging, I wanted to make sure that we did a smoke test of the migration with an existing database, just to make sure it looked okay. I tried with the database from minotaur, and I'm seeing an error: I think that may be an issue that came in during the rebase. Can you take a look? If you want a copy of the database, ping me on slack and I can send it to you. |
| postgresql.ENUM("RED", "GREEN", name="status"), | ||
| autoincrement=False, | ||
| nullable=False, | ||
| server_default=sa.text("'GREEN'::status"), |
There was a problem hiding this comment.
Not sure we should add this line to an existing migration.
There was a problem hiding this comment.
This was required because NULL is not allowed in the column, so rollbacks were failing.
Description
These changes are a refactor of the external integrations system.
The refactor has undergone several refactors itself, every time a unit test would point out a different use case, some changes would have to be made. Due to this there may be some dead code lying around, I will try to clean it up.
Defined pydantic settings for all license goal type APIs.
Migration scripts have been added for the Goal enum and to move the data into IntegrationConfigurations.
The External Integration data has not been deleted, yet.
The Admin CollectionSettings controller defines new methods for integration configurations and uses them appropriately.
All API classes have been modified to utilise IntegrationConfigurations.
All API classes use the modified HasCollectionSelfTests class.
Migrated all collection tests to use IntegrationConfigurations.
JIRA
Motivation and Context
How Has This Been Tested?
Manually imported an OPDS feed.
Randomly ran collection self tests.
Modified the unit tests to work with integration configurations.
Modified existing collections and created new collections from the Admin UI.
Checklist