-
Notifications
You must be signed in to change notification settings - Fork 61
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
chore: swap core for yggdrasil #322
Conversation
UnleashClient/__init__.py
Outdated
""" | ||
variant = self.engine.get_variant(feature_name, context) | ||
if variant: | ||
return {k: v for k, v in asdict(variant).items() if v is not 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.
Just curious: Why do we need this?
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.
It's a good question. Yggdrasil core returns a dataclass here (which is like an object without methods, similar to a Rust struct). I'm a fan of dataclasses because they're quite explicit about their intent. The SDK at the moment returns an untyped dict. So I don't want to change it for 3 reasons:
- Yggdrasil abstractions should stay in Yggdrasil, bleeding internal classes outside of the domain boundary is poor encapsulation
- This is one less thing for consumers to have to think about or worry about, that one is quite important to me in Python because its quite hard to know all the places you may be using a return type. This means no one has to hunt down all their variants and change the way they access data on them
- Dataclasses do optionals, which become nulls. The client spec suggests that variants without payloads shouldn't include that field rather than including a null. The dict comprehension here is filtering out nulls
feature_name, | ||
) | ||
variant = DISABLED_VARIATION |
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.
Would probably be cleaner to move this part over to _resolve_variant
and make it always return a variant instead of either a variant or 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.
I left it alone because I was going to implement the fallback function, which needs to know if there's a variant or not... then I realised we never got around to implementing that. So I'm leaving this until we do actually implement it
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.
Other than a few nitpicks it seems to me like you're doing all the right things 👍
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.
Some random thoughts:
- Should update the development docs on what yggdrasil is/how to upgrade.
- Custom strategy changes probably need updates.
Cheers, both are absolutely on my list of things to do. I just wanted to keep this PR as narrow as possible. Will definitely be a thing prior to an actual release |
30e9cf7
to
6e92e16
Compare
for more information, see https://pre-commit.ci
Co-authored-by: Nuno Góis <github@nunogois.com>
Co-authored-by: Nuno Góis <github@nunogois.com>
6824042
to
490e1a1
Compare
…leash-client-python into chore/swap-core-for-yggdrasil
…efore being passed to Yggdrasil (#329)
Swaps the core of the SDK for the Python bindings to Yggdrasil.
Currently this "works on my machine" because the engine isn't yet published, but all tests do pass with a local link.
Details
features
field has been left intact on theUnleashClient
class but will now always return empty. This is intended to be swapped out forfeature_definitions
.features
will be removed in a further clean up PR prior to releaseDiscussion points