-
Notifications
You must be signed in to change notification settings - Fork 4
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: Add the ability to override resources on a per-user basis #1981
base: main
Are you sure you want to change the base?
Conversation
The generated OpenAPI client is not up to date with the latest changes in the OpenAPI specification. |
API Changelog 4.15.1.dev18+g39fabe1fGET /api/v1/projects/{project_slug}/models
POST /api/v1/projects/{project_slug}/models
GET /api/v1/projects/{project_slug}/models/{model_slug}
PATCH /api/v1/projects/{project_slug}/models/{model_slug}
GET /api/v1/projects/{project_slug}/models/{model_slug}/provisioning
GET /api/v1/projects/{project_slug}/tools
POST /api/v1/projects/{project_slug}/tools
GET /api/v1/sessions
POST /api/v1/sessions
GET /api/v1/sessions/{session_id}
GET /api/v1/tools
POST /api/v1/tools
GET /api/v1/tools/*/versions
GET /api/v1/tools/default
GET /api/v1/tools/{tool_id}
PUT /api/v1/tools/{tool_id}
GET /api/v1/users/{user_id}/sessions
|
This comment has been minimized.
This comment has been minimized.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1981 +/- ##
==========================================
+ Coverage 85.46% 85.53% +0.07%
==========================================
Files 225 225
Lines 7411 7448 +37
Branches 513 524 +11
==========================================
+ Hits 6334 6371 +37
+ Misses 913 912 -1
- Partials 164 165 +1 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
c773244
to
cab1a6a
Compare
This comment has been minimized.
This comment has been minimized.
A Storybook preview is available for commit 39fabe1. |
cab1a6a
to
ee32de9
Compare
This comment has been minimized.
This comment has been minimized.
ee32de9
to
913c962
Compare
This comment has been minimized.
This comment has been minimized.
913c962
to
7f8a7f0
Compare
7c78706
to
dee00aa
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
dee00aa
to
6faaae9
Compare
This comment has been minimized.
This comment has been minimized.
6faaae9
to
bccb9e0
Compare
This comment has been minimized.
This comment has been minimized.
bccb9e0
to
c7638a7
Compare
This comment has been minimized.
This comment has been minimized.
c7638a7
to
36301ab
Compare
This comment has been minimized.
This comment has been minimized.
36301ab
to
5511b3e
Compare
This comment has been minimized.
This comment has been minimized.
5511b3e
to
bd2222e
Compare
This comment has been minimized.
This comment has been minimized.
bd2222e
to
c65e4ac
Compare
This comment has been minimized.
This comment has been minimized.
978e1df
to
b821a01
Compare
This comment has been minimized.
This comment has been minimized.
default_profile: DefaultResourceProfile = pydantic.Field( | ||
default_factory=DefaultResourceProfile, | ||
description="Default resource profile, which is used when no other profile matches.", | ||
) | ||
additional: dict[str, AdditionalResourceProfile] = pydantic.Field( | ||
default={}, | ||
description="Additional resource profiles, which can be used to limit the resource usage of sessions.", | ||
) |
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'd add another layer in the configuration:
resources:
profiles:
default: ...
additional: ...
If you change it, make sure to also update the docs and migration script.
) | ||
|
||
|
||
class Resources(core_pydantic.BaseModelStrict): |
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 API Changelog generation indicates for which endpoints the class is used: #1981 (comment)
For data protection and political reasons, we should not expose the list of usernames of the profiles to users with role user. We should hide the list of usernames in the response for normal users (e.g., via pydantic validator). Alternatively, we can return only the relevant resource profile for the user.
tools = get_tools(db) | ||
for tool in tools: | ||
updated = False | ||
for profile in tool.config.resources.additional.values(): | ||
if old_username in profile.usernames: | ||
profile.usernames = [ | ||
new_username if username == old_username else username | ||
for username in profile.usernames | ||
] | ||
updated = True | ||
if updated: | ||
orm.attributes.flag_modified(tool, "config") | ||
db.commit() |
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.
tools = get_tools(db) | |
for tool in tools: | |
updated = False | |
for profile in tool.config.resources.additional.values(): | |
if old_username in profile.usernames: | |
profile.usernames = [ | |
new_username if username == old_username else username | |
for username in profile.usernames | |
] | |
updated = True | |
if updated: | |
orm.attributes.flag_modified(tool, "config") | |
db.commit() | |
tools = get_tools(db) | |
for tool in tools: | |
for profile in tool.config.resources.additional.values(): | |
if old_username in profile.usernames: | |
profile.usernames = [ | |
new_username if username == old_username else username | |
for username in profile.usernames | |
] | |
orm.attributes.flag_modified(tool, "config") | |
db.commit() |
|
||
@pydantic.field_validator("additional") | ||
@classmethod | ||
def check_additional_profiles( |
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.
A validation if the user exists is missing.
@@ -80,6 +81,8 @@ def create_user( | |||
def update_user( |
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.
If the user is deleted, the username should be removed from the list.
b821a01
to
3b05699
Compare
Quality Gate passedIssues Measures |
Closes #1951