Skip to content
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

Merge lib submodule into ops #3134

Merged
merged 37 commits into from
May 6, 2023
Merged

Conversation

ThomasLaPiana
Copy link
Contributor

@ThomasLaPiana ThomasLaPiana commented Apr 24, 2023

Closes #2032

Code Changes

  • move source files from lib into ops, mostly maintaining the structure
  • remove the lib submodule completely once the functionality has been copied over
  • clean up ops/lib oauth utils/functions

Steps to Confirm

  • automated checks pass
  • logical code conversion/synthesis is done

Pre-Merge Checklist

Description Of Changes

Long-awaited change to merge the previously-separate lib code with the ops api code. This is an iteration on the path towards a total unification of ctl and ops server code as well

Given the size of the changes here as well as being a pure refactor change, I'm not expecting much in terms of a manual review here

@ThomasLaPiana ThomasLaPiana self-assigned this Apr 24, 2023
@cypress
Copy link

cypress bot commented Apr 24, 2023

Passing run #1795 ↗︎

0 4 0 0 Flakiness 0

Details:

Merge c597ec7 into b5b1649...
Project: fides Commit: fdd87cc4f1 ℹ️
Status: Passed Duration: 00:43 💡
Started: May 6, 2023 5:22 PM Ended: May 6, 2023 5:23 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@codecov
Copy link

codecov bot commented Apr 24, 2023

Codecov Report

Patch coverage: 94.94% and project coverage change: -0.05 ⚠️

Comparison is base (b5b1649) 87.43% compared to head (c597ec7) 87.39%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3134      +/-   ##
==========================================
- Coverage   87.43%   87.39%   -0.05%     
==========================================
  Files         314      305       -9     
  Lines       18341    18265      -76     
  Branches     2384     2384              
==========================================
- Hits        16036    15962      -74     
+ Misses       1868     1866       -2     
  Partials      437      437              
Impacted Files Coverage Δ
...c/fides/api/ops/cryptography/cryptographic_util.py 100.00% <ø> (ø)
src/fides/api/ops/cryptography/schemas/jwt.py 100.00% <ø> (ø)
src/fides/api/ops/oauth/jwt.py 100.00% <ø> (ø)
src/fides/api/ops/oauth/roles.py 100.00% <ø> (ø)
src/fides/api/ops/oauth/system_manager.py 100.00% <ø> (ø)
src/fides/api/ops/util/text.py 100.00% <ø> (ø)
src/fides/api/ops/common_exceptions.py 91.01% <78.57%> (-5.77%) ⬇️
.../ops/api/v1/endpoints/privacy_request_endpoints.py 90.24% <87.50%> (-0.12%) ⬇️
src/fides/api/ops/db/base_class.py 87.33% <89.05%> (+15.90%) ⬆️
...c/fides/api/ops/api/v1/endpoints/user_endpoints.py 95.00% <95.06%> (-0.39%) ⬇️
... and 93 more

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ThomasLaPiana
Copy link
Contributor Author

@pattisdr I'm nearing the point of being ready for a review, but before I get there I wanted to make sure there wasn't anything super specific you had in mind for cleanup here? At the very least this will combine the code and do some minimal de-duplication

from fides.api.ops.util.text import to_snake_case

T = TypeVar("T", bound="OrmWrappedFidesBase")
ALLOWED_CHARS = re.compile(r"[A-z0-9\-_]")

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that is equivalent to \[A-Z\\[\\\\]^_`a-z\].
@pattisdr
Copy link
Contributor

pattisdr commented May 1, 2023

@ThomasLaPiana taking a look at this now, apologize for missing this notification last week

@ThomasLaPiana
Copy link
Contributor Author

@ThomasLaPiana taking a look at this now, apologize for missing this notification last week

No worries! Release takes precedence and I'm fixing a few bugs real quick since merging in main 😄 they'll be in shortly

@ThomasLaPiana
Copy link
Contributor Author

ok...seems like it should be good to go now!

@galvana galvana added the run unsafe ci checks Runs fideops-related CI checks that require sensitive credentials label May 1, 2023
Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work @ThomasLaPiana really appreciate the consolidation here. Main things that stood out were the ConnectionConfig/MessagingConfig type issues and some of endpoints/URL's/schemas still in separate files from there rest of the ops endpoint details.

src/fides/api/ops/oauth/api/routes/user_endpoints.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
src/fides/api/ops/schemas/base_class.py Outdated Show resolved Hide resolved
src/fides/api/ops/util/text.py Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
src/fides/api/ops/oauth/schemas/user.py Outdated Show resolved Hide resolved
@@ -182,6 +182,6 @@ def filter_fides_connector_datasets(
return {
dataset.fides_key
for connector_config in connector_configs
for dataset in connector_config.datasets
for dataset in connector_config.datasets # type: ignore[attr-defined]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh why are these connection config attributes suddenly causing problems

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk 😢 but it was a lot

@@ -138,7 +138,7 @@ def dispatch_message(
raise MessageDispatchException("No notification service type configured.")

logger.info("Retrieving message config")
messaging_config: MessagingConfig = MessagingConfig.get_configuration(
messaging_config = MessagingConfig.get_configuration(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting a type hint being removed likely to get around linting issues

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep....I also have no idea why, but I had to add a lot of mypy workarounds and that makes me concerned, but not concerned enough to spend hours figuring out why 😅

src/fides/api/ops/util/oauth_util.py Show resolved Hide resolved
@ThomasLaPiana
Copy link
Contributor Author

@pattisdr thank you for the thorough review! Will go through and make changes accordingly 😄

@ThomasLaPiana
Copy link
Contributor Author

@pattisdr I've gone through and made all of the consolidation/refactor changes you mentioned!

The only ones left are the mypy failure ones and I'm honestly not sure what to do there...I could revert some of those changes and then add ignores instead?

@pattisdr
Copy link
Contributor

pattisdr commented May 4, 2023

thanks very much @ThomasLaPiana I plan to review first thing tomorrow. I know this touches a lot of files and you're anxious to merge -

Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThomasLaPiana Thanks very much especially for consolidating the user endpoints, that's probably what I hoped to get most out of this.

The cause of the type issues were bothering me so I dug into it and it looks like we were previously importing the MessagingConfig and ConnectionConfig models from a different directory in lib than the other models. I've tried to continue to clean up type hints in this corresponding PR that is pointed at your branch plus some other minor items I saw:

#3221

from fides.api.ops.util.oauth_util import verify_oauth_client_prod
from fides.api.ops.oauth.utils import verify_oauth_client_prod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something that just occurred to me is that this is going to need a corresponding plus PR that needs to go out in the same release as plus imports a lot of these oauth methods related to scopes and roles that should probably take priority then over other reorganization tickets this sprint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, I'll get on that as soon as this gets merged!

Comment on lines 231 to 234
connection_config: ConnectionConfig = ConnectionConfig.get_by(
connection_config = ConnectionConfig.get_by(
db, field="key", value=authentication_request.connection_key
)
assert connection_config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way your assert needs to be moved beneath the verify_oauth_connection_config as it is expected this could potentially return None. I'll take care of this in my corresponding PR to clean up some of this type stuff

src/fides/api/ops/util/text.py Show resolved Hide resolved
@ThomasLaPiana
Copy link
Contributor Author

@pattisdr This is ready for a final review, thanks again so much for the work you did in the type hints! I got those merged in and everything is looking good. I've also opened and cross-linked a Fidesplus issue for fixing things over there

Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me @ThomasLaPiana you'll need another changelog update (group "changed" together) after getting this up to date one more time. Thanks again for all your efforts here.

@ThomasLaPiana
Copy link
Contributor Author

Looks good to me @ThomasLaPiana you'll need another changelog update (group "changed" together) after getting this up to date one more time. Thanks again for all your efforts here.

Thank you so much for your contributions here! This is only the beginning of the decisive tech-debt payoff 🙂

@ThomasLaPiana
Copy link
Contributor Author

failed tests are expected, merging

@ThomasLaPiana ThomasLaPiana merged commit 8ecc3c7 into main May 6, 2023
@ThomasLaPiana ThomasLaPiana deleted the ThomasLaPiana-merge-lib-into-ops branch May 6, 2023 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run unsafe ci checks Runs fideops-related CI checks that require sensitive credentials
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deduplicate ops/lib code
3 participants