-
Notifications
You must be signed in to change notification settings - Fork 72
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
avoid circular deps caused within api.api.v1
#3692
Conversation
@ThomasLaPiana @pattisdr @galvana i've made some progress but my brain's a bit stuck here as i wrap up my day - wrote up where i am and the problem as i see it. maybe there's a totally different approach here that's either simpler or preferred - i went down this path and didn't really look back! |
Passing run #2993 ↗︎
Details:
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #3692 +/- ##
=======================================
Coverage 87.05% 87.05%
=======================================
Files 310 310
Lines 18990 18990
Branches 2446 2446
=======================================
Hits 16532 16532
Misses 2029 2029
Partials 429 429
☔ View full report in Codecov by Sentry. |
proposed update is to move |
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.
Local testing worked well, thanks for digging into these circular dependency issues - they can be so time-consuming 😓
53b3611
to
8e7406b
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.
🏆
I'm just saying this out loud...the majority of these issues were caused specifically by the admin router due to it's need to directly modify the database. While we probably could have avoided most of these changes by directly moving that endpoint into Thanks for the changes here @adamsachs ! |
ha - i also made that observation @ThomasLaPiana , thank you for calling it out here! i felt a bit hesitant to move it and "special-case" the endpoint for lack of consistency, but i think you're right to make a case for it - it does feel like a good change to simplify the dependency tree longer-term! |
Closes #3691
note that we will need to update
fidesplus
accordingly if we moveurn_registry.py
as is proposed here currently!Description Of Changes
The root cause here is that the
__init__.py
of ourapi.api.v1
module brings in a lot of dependencies viaADMIN_ROUTER
. this means we need to be judicious when to depend on code withinapi.api.v1
so as to keep it as self-contained as possible. in this case, the immediate cause of the problem is thatpostgres_setup.py
depends on ourconnectors
module, and ourconnectors
module was bringing inapi.api.v1
via some utilities (namelyconsent_util
which brought inendpoint.utils
.)it seems like an unambiguously good update to move our
api.api.v1.endpoint.utils
up a few levels intoapi.util.endpoint_utils
, alongside other API related utilities that are not only used by code withinapi.api.v1
, per the general principle above. i've made that change in 5bee963, and that does help us resolve the initial error here.but we quickly hit another error (stack trace below), this time because our
fides_connector
(specifically thefides_client
it is highly dependent on), which is also initialized by theconnectors
module, relies directly on theurn_registry
that's withinapi.api.v1
. the solution to this feels less straightforward to me -- i see 3 potential paths forward but none seem like an obvious best choice:urn_registry
out ofapi.api.v1
,but that doesn't feel right, because it's pretty strictly related/coupled to the code in that module-- @ThomasLaPiana also suggested this, and given some more thought, this feels like it might be the right path forward. my proposed change here is to move it to acommon.api.v1
module/directory, so that it's clear it refers to ourapi.v1
endpoints/code.__init__.py
ofapi.api.v1
to not bring in so many dependencies via theADMIN_ROUTER
, but this feels like a tall order and larger scope than what we're doing here. i'm not even sure it's desirable, it may lead to other problems.fides_connector
(andfides_client
) out of theconnectors
module, or at least not have it initialized as part of the module's__init__.py
, so that it's not initialized withpostgres_setup.py
. this feels simpler and better, it's not crazy to have thefides_connector
special-cased, since it's a pretty special connector in how self-referential it is. but where's the better spot for it so that we're sure it gets properly initialized on normal app runtime/startup, but it's not causing dep issues?fides_client
to not rely on theurn_registry
and instead just use string literals for its URL/URN references. this would be simple, but it feels like it makes that code materially worse, and it just doesn't feel like the right solution here - constants are good :)new error with the update contained in 5bee963:
Code Changes
api.api.v1.endpoint.utils.py
toapi.util.endpoint_utils.py
and updated referencesfides_connector.py
/fides_client.py
when runningpostgres_setup.py
--> proposed update here is to moveurn_registry.py
tocommon.api.v1
rather thanapi.api.v1
Steps to Confirm
nox -s quickstart
andnox -s dev -- shell postgres
should both work finefides_env(test)
(just given the number of files touched) - privacy request execution and system management still worked fine.Pre-Merge Checklist
CHANGELOG.md