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: [docs for ruby v3 ufc + bandits] (FF-2859) #432

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

Conversation

leoromanovsky
Copy link
Member

@leoromanovsky leoromanovsky commented Jul 24, 2024

ruby v3 has been published with the UFC changes and bandits. I have modeled these docs on the python layout.

Code is located: https://github.com/Eppo-exp/rust-sdk/tree/main/ruby-sdk

👉 The bandits sections needs some attention.

Copy link

netlify bot commented Jul 24, 2024

Deploy Preview for eppo-data-docs ready!

Name Link
🔨 Latest commit 2f81ca6
🔍 Latest deploy log https://app.netlify.com/sites/eppo-data-docs/deploys/66a8143f0ed3c7000891908d
😎 Deploy Preview https://deploy-preview-432--eppo-data-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@aarsilv aarsilv 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! 🎉 Approving with a BOATLOAD 🛥️ of comments you are welcome to act on or ignore as you see fit!

docs/sdks/server-sdks/ruby.md Outdated Show resolved Hide resolved
docs/sdks/server-sdks/ruby.md Outdated Show resolved Hide resolved
docs/sdks/server-sdks/ruby.md Outdated Show resolved Hide resolved
EppoClient::init(config)

# Allow the configuration to be loaded from the CDN.
sleep(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

🤨 no awaits or callbacks in ruby? or can we make a synchronous version?

Don't love seeing sleep() in our example 😞

Copy link
Member

Choose a reason for hiding this comment

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

agreed, ruby is single threaded by default though and doesnt have async primitives like async/await. we could have a callback instead, but that would require changing the interface

docs/sdks/server-sdks/ruby.md Outdated Show resolved Hide resolved
To query the bandit for an action, you can use the `get_bandit_action` function. This function takes the following parameters:
- `flag_key` (str): The key of the feature flag corresponding to the bandit
- `subject_key` (str): The key of the subject or user assigned to the experiment variation
- `subject_attributes` (Attributes): The context of the subject
Copy link
Contributor

Choose a reason for hiding this comment

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

In other SDKs we allow either freeform attributes ([key] => bool | number | string) or contextual attributes (numeric_attributes => [key] => number, categorical_attributes => [key] => bool | number | string).

Assuming we do here (and if not, we should adjust) we should call this out in the documentation. It may also help to right after this explain the difference, as we do in our JavaScript documentation (link).

- `flag_key` (str): The key of the feature flag corresponding to the bandit
- `subject_key` (str): The key of the subject or user assigned to the experiment variation
- `subject_attributes` (Attributes): The context of the subject
- `actions` (Hash{String => Attributes}): A hash that maps available actions to their attributes
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for actions, except we also allow just a set of Strings too if we don't have any action context.

The `bandit_result` is an instance of `BanditResult`, which has two fields:

- `variation` (String): The variation that was assigned to the subject
- `action` (Optional[String]): The action that was assigned to the subject
Copy link
Contributor

Choose a reason for hiding this comment

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

is Optional[String] Ruby-speek?


The variation returns the feature flag variation; this can be the bandit itself, or the "status quo" variation if the user is not assigned to the bandit.
If we are unable to generate a variation, for example when the flag is turned off, then the `default` variation is returned.
In both of those cases, the `action` is `nil`, and you should use the status-quo algorithm to select an action.
Copy link
Contributor

Choose a reason for hiding this comment

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

this may not make sense because one of the above cases is the bandit itself, in which case action won't be nil.

Perhaps reword to "In both of those cases, when action is nil, you should use the status-quo algorithm to select an action.

- `action` (Optional[String]): The action that was assigned to the subject

The variation returns the feature flag variation; this can be the bandit itself, or the "status quo" variation if the user is not assigned to the bandit.
If we are unable to generate a variation, for example when the flag is turned off, then the `default` variation is returned.
Copy link
Contributor

Choose a reason for hiding this comment

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

There is another case, where the bandit encounters an error selecting an action (or there are no actions provided) in which case it will return the bandit variation, but a nil action. I wonder if that's worth explicitly calling out--I think it is.

@@ -19,33 +21,75 @@ gem install eppo-server-sdk
or add to you `Gemfile`:

```
gem 'eppo-server-sdk', '~> 0.3.0'
Copy link
Member

Choose a reason for hiding this comment

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

I honestly find it really weird we're jumping from 0.3.0 to 3.0.0. I understand the motivation but would find it jarring as a user

docs/sdks/server-sdks/ruby.md Outdated Show resolved Hide resolved

If you are using the SDK for experiment assignments, make sure to pass in an assignment logging callback (see [section](#define-an-assignment-logger-experiment-assignment-only) below).
After initialization, the SDK begins polling Eppo's API at regular intervals to retrieve the most recent experiment configurations such as variation values and traffic allocation. The SDK stores these configurations in memory so that assignments are effectively instant. For more information, see the [architecture overview](/sdks/overview) page.
Copy link
Member

Choose a reason for hiding this comment

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

hmm not sure about "effectively instant" - I'd reword as "synchronous" to be more precise

docs/sdks/server-sdks/ruby.md Outdated Show resolved Hide resolved
docs/sdks/server-sdks/ruby.md Outdated Show resolved Hide resolved
EppoClient::init(config)

# Allow the configuration to be loaded from the CDN.
sleep(1)
Copy link
Member

Choose a reason for hiding this comment

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

agreed, ruby is single threaded by default though and doesnt have async primitives like async/await. we could have a callback instead, but that would require changing the interface

docs/sdks/server-sdks/ruby.md Outdated Show resolved Hide resolved
@sameerank sameerank removed their request for review September 26, 2024 18:48
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.

3 participants