-
Notifications
You must be signed in to change notification settings - Fork 2
Offline Init Part 2 of 4: Add getBanditsConfiguration() to export bandit models as JSON #117
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
Offline Init Part 2 of 4: Add getBanditsConfiguration() to export bandit models as JSON #117
Conversation
5c56e10 to
eae1ff4
Compare
7396a8f to
128bac6
Compare
src/index.ts
Outdated
| const configuration: { | ||
| bandits: Record<string, BanditParameters>; | ||
| } = { | ||
| bandits, | ||
| }; |
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.
This is simpler than the original flag configuration because we basically store bandit configurations (model parameters) as-is
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.
Pull request overview
This PR adds getBanditsConfiguration() to export bandit model configurations as JSON, complementing the existing getFlagsConfiguration() for offline SDK initialization.
Changes:
- Adds
getBanditsConfiguration()function that serializes bandit models to JSON - Includes comprehensive tests validating the JSON structure against bandit-models-v1.json
- Updates GitHub Actions workflow to use
**branch pattern instead of*
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/index.ts | Adds getBanditsConfiguration() function to export bandit models as JSON |
| src/index.spec.ts | Adds tests for getBanditsConfiguration() including null cases and structure validation |
| .github/workflows/lint-test-sdk.yml | Updates branch pattern from * to ** for pull request triggers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/index.ts
Outdated
| export function getBanditsConfiguration(): string | null { | ||
| if (!banditModelConfigurationStore) { | ||
| return null; | ||
| } |
Copilot
AI
Jan 20, 2026
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.
The early return when banditModelConfigurationStore is not initialized lacks test coverage. Add a test case that calls getBanditsConfiguration() before init() to verify it returns null.
| on: | ||
| pull_request: | ||
| branches: [ "*" ] | ||
| branches: [ "**" ] |
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.
still apply if merging into branches with slashes in their name
b235e30 to
c35ea62
Compare
This function returns the current bandits configuration as a JSON string that can be used together with getFlagsConfiguration() to bootstrap another SDK instance. Returns null if no bandits are configured. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Fixes test isolation issue where tests ran after API server was closed. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Verify exact structure from bandit-models-v1.json including: - Exact number of bandits (3) - Specific bandit keys (banner_bandit, car_bandit, cold_start_bandit) - Detailed banner_bandit structure verification - Different settings for car_bandit and cold_start_bandit Co-Authored-By: Claude Opus 4.5 <[email protected]>
Change branches pattern from "*" to "**" so the workflow triggers for PRs targeting branches like "aarsilv/feature-name" (stacked PRs). The single asterisk doesn't match "/" characters in GitHub Actions. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add BanditsConfigurationResponse interface matching IBanditParametersResponse structure from the common package (with updatedAt optional since not stored) - Update getBanditsConfiguration() to use the typed interface This ensures consistency with getFlagsConfiguration() and provides better type safety for the export/import workflow. Co-Authored-By: Claude Opus 4.5 <[email protected]>
291bc6f to
f3ee984
Compare
Summary
getBanditsConfiguration()function to export bandit models as JSONgetFlagsConfiguration()for complete offline initialization supportStacked PRs
getFlagsConfiguration()getBanditsConfiguration()(this PR)offlineInit()Test plan
getBanditsConfiguration()returns null before initialization🤖 Generated with Claude Code