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

feat(flagd): Add in-process evaluator #104

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aepfli
Copy link
Member

@aepfli aepfli commented Nov 18, 2024

With these changes, we're adding in-process evaluation to the python flagd sdk. The whole e2e test-harness suite is passing, except the cases for unix socket and targetURI which are not implemented

@toddbaert toddbaert changed the title [draft] syng pr with gherkin and testcontainers [draft] sync pr with gherkin and testcontainers Nov 18, 2024
@aepfli aepfli force-pushed the feat/grpc-sync-addition branch from 2db5904 to e826b3d Compare November 19, 2024 06:47
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 94.13%. Comparing base (80cff25) to head (992bc37).

Files with missing lines Patch % Lines
.../flagd/resolvers/process/connector/grpc_watcher.py 94.17% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #104      +/-   ##
==========================================
+ Coverage   93.91%   94.13%   +0.21%     
==========================================
  Files          15       17       +2     
  Lines         789      903     +114     
==========================================
+ Hits          741      850     +109     
- Misses         48       53       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aepfli aepfli force-pushed the feat/grpc-sync-addition branch 3 times, most recently from 8a15f87 to 36269b5 Compare November 23, 2024 12:55
@aepfli aepfli force-pushed the feat/grpc-sync-addition branch from 36269b5 to af0df41 Compare November 23, 2024 13:07
@aepfli aepfli changed the title [draft] sync pr with gherkin and testcontainers feat(flagd sync): add sync with proper e2e tests Nov 23, 2024
@aepfli aepfli changed the title feat(flagd sync): add sync with proper e2e tests feat(flagd sync): add sync with test containers tests Nov 23, 2024
@aepfli aepfli force-pushed the feat/grpc-sync-addition branch 9 times, most recently from ca544a4 to c68da7b Compare November 24, 2024 09:32
@aepfli
Copy link
Member Author

aepfli commented Nov 24, 2024

no more e2e tests are skipped 🎉

@aepfli aepfli force-pushed the feat/grpc-sync-addition branch 3 times, most recently from cae988c to 87c50a4 Compare November 25, 2024 16:56
@aepfli aepfli marked this pull request as ready for review November 25, 2024 18:19
@aepfli aepfli requested a review from a team as a code owner November 25, 2024 18:19
@toddbaert
Copy link
Member

no more e2e tests are skipped 🎉

LEEEETSS GOOOOO!

@toddbaert
Copy link
Member

The only issue I found is that the enum for the resolver should be rpc | in-process instead of grpc | in-process, I pushed an update for this (code, docs, and tests).

@toddbaert toddbaert changed the title feat(flagd sync): add sync with test containers tests feat!: correct configuration params, stream reconnects, add tests Nov 25, 2024
@toddbaert toddbaert self-requested a review November 25, 2024 19:18
@aepfli
Copy link
Member Author

aepfli commented Nov 26, 2024

I can, and gladly will split it up into 4 parts again:

  1. proto buff generation build(flagd): auto generate proto files from schema #109
  2. events for RPC feat(flagd-rpc)!: add events for rpc mode, some breaking config fixes #108
  3. caching for RPC feat(flagd-rpc): add caching  #110 (depends on 1 and 2)
  4. sync implementation with config adaptions (this will still stay big, as it is a new feature overall) - this pr (depends on 3)

The config adaptations (Ms and seconds) also make sense because this syncs the behavior of environment flags for all providers. Java is in MS and is, IMHO, the most advanced provider for flags; hence, we should adhere to its environment variables usage and values, or else we have way more things to change. We use the same environment variables to make it easy to configure multiple providers with the same environment variables. This provider did not reach version 1, making it a better target than Java.

The same applies to the resolver's name. Everywhere else, it is named RPC; here, we do have GRPC. We should normalize this for consistency and easier maintenance in the long run.

A good thing is that all the features implemented fulfill the test-harness gherkin files. We're compliant with the expectations of flagd for a provider - confidence we did not have before. I also suggest not looking for perfect code; this confidence allows us to iterate faster and ship improvements confidently.

@beeme1mr
Copy link
Member

Thanks @aepfli! That should make it easier to review and make our release notes more accurate.

@toddbaert
Copy link
Member

toddbaert commented Nov 26, 2024

The config adaptations (Ms and seconds) also make sense because this syncs the behavior of environment flags for all providers. Java is in MS and is, IMHO, the most advanced provider for flags; hence, we should adhere to its environment variables usage and values, or else we have way more things to change. We use the same environment variables to make it easy to configure multiple providers with the same environment variables. This provider did not reach version 1, making it a better target than Java.

The same applies to the resolver's name. Everywhere else, it is named RPC; here, we do have GRPC. We should normalize this for consistency and for easier maintenance in the long run.

Besides the fact this is what Java does, these are actually in the spec for flagd providers, and are important for interop with the Operator.

But it sounds like we have a plan for moving forward! Feel free to link your other PRs to this one and close this one whenever @aepfli

@aepfli
Copy link
Member Author

aepfli commented Nov 26, 2024

But it sounds like we have a plan for moving forward! Feel free to link your other PRs to this one and close this one whenever @aepfli

this one is the last in the chain, i will update it and mark it as soon as we are ready

@aepfli aepfli marked this pull request as draft November 26, 2024 13:50
@aepfli aepfli force-pushed the feat/grpc-sync-addition branch 2 times, most recently from 6b21f96 to a37e5a3 Compare December 6, 2024 21:24
@aepfli aepfli force-pushed the feat/grpc-sync-addition branch 3 times, most recently from 4db7a48 to cda7342 Compare December 30, 2024 12:17
@aepfli
Copy link
Member Author

aepfli commented Dec 30, 2024

I merged all the previous work, and updated the implementation to match our latest findings regarding grpc. - there is room for improvements, eg. removing duplication between rpc and in-process for grpc connection etc. but i do think, this is something we can do in another step.

should i open a new pull request, or will we continue from here?

@aepfli aepfli force-pushed the feat/grpc-sync-addition branch 5 times, most recently from 8945ff2 to 77b9eb8 Compare December 30, 2024 19:06
@aepfli aepfli force-pushed the feat/grpc-sync-addition branch from 77b9eb8 to 75a2659 Compare February 4, 2025 17:31
@aepfli aepfli marked this pull request as ready for review February 6, 2025 16:32
@aepfli aepfli force-pushed the feat/grpc-sync-addition branch 2 times, most recently from 7f8d3af to 3a28e78 Compare February 6, 2025 16:39
Co-authored-by: Cole Bailey <[email protected]>
Signed-off-by: Simon Schrottner <[email protected]>
@aepfli aepfli force-pushed the feat/grpc-sync-addition branch from 3a28e78 to 622208b Compare February 6, 2025 16:43
@aepfli aepfli changed the title feat!: correct configuration params, stream reconnects, add tests feat!(flagd): Add in-process evaluator Feb 6, 2025
@aepfli aepfli changed the title feat!(flagd): Add in-process evaluator feat(flagd): Add in-process evaluator Feb 6, 2025
providers/openfeature-provider-flagd/README.md Outdated Show resolved Hide resolved
This can be used to enrich evaluations with such data.
If the `in-process` mode is not used, and before the provider is ready, the `getSyncMetadata` returns an empty map.
-->
#### Offline mode
Copy link
Member

Choose a reason for hiding this comment

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

Will the file mode changes come later?

self.connected = True

if not self.active:
logger.info("Terminating gRPC sync thread")
Copy link
Member

Choose a reason for hiding this comment

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

Is info level the right fit here? It appears to be more a debug message.

Comment on lines +7 to +8
# as soon as we support all the features, we can actually remove this limitation to not run on Python 3.8
# Python 3.8 does not fully support tagging, hence that it will run all cases
Copy link
Member

Choose a reason for hiding this comment

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

How many cases are not covered yet?

Copy link
Member Author

Choose a reason for hiding this comment

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

Targeturi, unixsockets

@toddbaert toddbaert self-requested a review February 6, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants