Open
Conversation
Contributor
Author
|
@angosr Please I would love to hear your review on this |
Contributor
Author
|
@angosr Trust you had a great weekend. Please I would love to hear your review on this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deterministic Profile-Based Configuration System
Problem Description
The
affine-cortexSDK previously lacked a centralized, robust configuration management system. Users faced several challenges:Thought Process
To address these issues, we needed a system that is deterministic, hierarchical, and user-friendly.
Design Decisions:
affine.config.config)../affine.json): Highest priority (except CLI flags). Allows per-project settings.~/.affine/config.json): User-level defaults.localhost:8000and a "prod" profile pointing to the live API, and switch between them instantly.pydanticmodels (ProfileConfig) to enforce type safety. If a user provides a string for a timeout, the system fails fast with a clear error rather than causing cryptic runtime bugs.af) was updated to expose configuration commands (list, use, set) and a global--profileflag.base_url).The Fix
1. New Configuration Module (affine/config.py)
We introduced affine/config.py which contains:
2. SDK Integration (affine/utils/api_client.py)
The APIClient and CLIAPIClient were refactored to:
base_url,timeout, and retry settings from the active_profile.3. CLI Enhancements (affine/cli/main.py)
We added a new config command group:
af config list: Shows available profiles.af config use <name>: Switches the active profile globally.af config set <name> <key>=<value>: Allows easy modification of profile settings.--profileflag to override the active profile for a single command.4. Testing (tests/test_profiles.py)
A comprehensive test suite was added to verify: