-
Notifications
You must be signed in to change notification settings - Fork 56
LCORE-741: Proper quota limiters configuration #679
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ class "Configuration" as src.models.config.Configuration { | |
| llama_stack | ||
| mcp_servers : Optional[list[ModelContextProtocolServer]] | ||
| name : str | ||
| quota_handlers : Optional[QuotaHandlersConfig] | ||
| quota_handlers : Optional[QuotaHandlersConfiguration] | ||
| service | ||
| user_data_collection | ||
| dump(filename: str) -> None | ||
|
|
@@ -135,11 +135,23 @@ class "PostgreSQLDatabaseConfiguration" as src.models.config.PostgreSQLDatabaseC | |
| user : str | ||
| check_postgres_configuration() -> Self | ||
| } | ||
| class "QuotaHandlersConfig" as src.models.config.QuotaHandlersConfig { | ||
| class "QuotaHandlersConfiguration" as src.models.config.QuotaHandlersConfiguration { | ||
| enable_token_history : bool | ||
| limiters : Optional[list[QuotaLimiterConfiguration]] | ||
| postgres : Optional[PostgreSQLDatabaseConfiguration] | ||
| scheduler : Optional[QuotaSchedulerConfiguration] | ||
| sqlite : Optional[SQLiteDatabaseConfiguration] | ||
| } | ||
| class "QuotaLimiterConfiguration" as src.models.config.QuotaLimiterConfiguration { | ||
| initial_quota : Annotated | ||
| name : str | ||
| period : str | ||
| quota_increase : Annotated | ||
| type : Literal['user_limiter', 'cluster_limiter'] | ||
| } | ||
| class "QuotaSchedulerConfiguration" as src.models.config.QuotaSchedulerConfiguration { | ||
| period : Annotated | ||
| } | ||
|
Comment on lines
+152
to
+154
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing inheritance declaration for QuotaSchedulerConfiguration. The Add the missing inheritance declaration after line 200: src.models.config.QuotaLimiterConfiguration --|> src.models.config.ConfigurationBase
+src.models.config.QuotaSchedulerConfiguration --|> src.models.config.ConfigurationBase
src.models.config.SQLiteDatabaseConfiguration --|> src.models.config.ConfigurationBaseBased on learnings.
🤖 Prompt for AI Agents |
||
| class "SQLiteDatabaseConfiguration" as src.models.config.SQLiteDatabaseConfiguration { | ||
| db_path : str | ||
| } | ||
|
|
@@ -184,7 +196,8 @@ src.models.config.JwtRoleRule --|> src.models.config.ConfigurationBase | |
| src.models.config.LlamaStackConfiguration --|> src.models.config.ConfigurationBase | ||
| src.models.config.ModelContextProtocolServer --|> src.models.config.ConfigurationBase | ||
| src.models.config.PostgreSQLDatabaseConfiguration --|> src.models.config.ConfigurationBase | ||
| src.models.config.QuotaHandlersConfig --|> src.models.config.ConfigurationBase | ||
| src.models.config.QuotaHandlersConfiguration --|> src.models.config.ConfigurationBase | ||
| src.models.config.QuotaLimiterConfiguration --|> src.models.config.ConfigurationBase | ||
| src.models.config.SQLiteDatabaseConfiguration --|> src.models.config.ConfigurationBase | ||
| src.models.config.ServiceConfiguration --|> src.models.config.ConfigurationBase | ||
| src.models.config.TLSConfiguration --|> src.models.config.ConfigurationBase | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| """Unit tests for QuotaHandlersConfiguration model.""" | ||
|
|
||
| from models.config import QuotaHandlersConfiguration, QuotaSchedulerConfiguration | ||
|
|
||
|
|
||
| def test_quota_handlers_configuration() -> None: | ||
| """Test the quota handlers configuration.""" | ||
| cfg = QuotaHandlersConfiguration( | ||
| sqlite=None, | ||
| postgres=None, | ||
| limiters=[], | ||
| scheduler=QuotaSchedulerConfiguration(period=10), | ||
| enable_token_history=False, | ||
| ) | ||
| assert cfg is not None | ||
| assert cfg.sqlite is None | ||
| assert cfg.postgres is None | ||
| assert cfg.limiters == [] | ||
| assert cfg.scheduler is not None | ||
| assert not cfg.enable_token_history |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| """Unit tests for QuotaLimiterConfig model.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from models.config import QuotaLimiterConfiguration | ||
|
|
||
|
|
||
| def test_quota_limiter_configuration() -> None: | ||
| """Test the default configuration.""" | ||
| cfg = QuotaLimiterConfiguration( | ||
| type="cluster_limiter", | ||
| name="cluster_monthly_limits", | ||
| initial_quota=0, | ||
| quota_increase=10, | ||
| period="3 seconds", | ||
| ) | ||
| assert cfg is not None | ||
| assert cfg.type == "cluster_limiter" | ||
| assert cfg.name == "cluster_monthly_limits" | ||
| assert cfg.initial_quota == 0 | ||
| assert cfg.quota_increase == 10 | ||
| assert cfg.period == "3 seconds" | ||
|
|
||
|
|
||
| def test_quota_limiter_configuration_improper_value_1() -> None: | ||
| """Test the default configuration.""" | ||
| with pytest.raises(ValueError, match="Input should be greater than or equal to 0"): | ||
| _ = QuotaLimiterConfiguration( | ||
| type="cluster_limiter", | ||
| name="cluster_monthly_limits", | ||
| initial_quota=-1, | ||
| quota_increase=10, | ||
| period="3 seconds", | ||
| ) | ||
|
|
||
|
|
||
| def test_quota_limiter_configuration_improper_value_2() -> None: | ||
| """Test the default configuration.""" | ||
| with pytest.raises(ValueError, match="Input should be greater than or equal to 0"): | ||
| _ = QuotaLimiterConfiguration( | ||
| type="cluster_limiter", | ||
| name="cluster_monthly_limits", | ||
| initial_quota=1, | ||
| quota_increase=-10, | ||
| period="3 seconds", | ||
| ) | ||
|
|
||
|
|
||
| def test_quota_limiter_configuration_improper_value_3() -> None: | ||
| """Test the default configuration.""" | ||
| with pytest.raises( | ||
| ValueError, match="Input should be 'user_limiter' or 'cluster_limiter'" | ||
| ): | ||
| _ = QuotaLimiterConfiguration( | ||
| type="unknown_limiter", | ||
| name="cluster_monthly_limits", | ||
| initial_quota=1, | ||
| quota_increase=10, | ||
| period="3 seconds", | ||
| ) |
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.
Missing composition declarations for limiters and scheduler fields.
The
QuotaHandlersConfigurationclass contains two composition fields (limitersandscheduler), but the corresponding composition relationship declarations are missing from the diagram.Add the missing composition declarations after line 210:
Also applies to: 205-210
🤖 Prompt for AI Agents