-
Notifications
You must be signed in to change notification settings - Fork 399
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 User
class to manage and create users within Argilla
#3169
Conversation
Improve `whoami` mock in `conftest`, and remove duplicated client-error tests
Aligned with API, as before there was no alignment due to the lack of an integration within the Python client
Meant to be imported as `rg.User`
shouldn't we also be able to update users? or will we then need to delete and re-create? |
That's a nice question indeed, maybe @frascuchon can answer this. But for the moment, the only available endpoints for user-management are the following, so I guess we're not able to, but it's a nice addition for sure. |
Yes exactly, because I would expect to be able to update passwords, roles etc. |
To be removed and replaced with the `UserModel` created upon #3169 completion
The CLI commands for users management are not using the API for the actions. I would prefer to provide basic support from python cli (by using available endpoints) and add more features later iteratively (which maybe means creating a new endpoint to update users, or reset passwords,...) |
Perfect. @frascuchon could you potentially add some context here for our contributors? |
To be removed once all the SDK functions are aligned to expect the `httpx.Client` to be provided instead of the `AuthenticatedClient`
def test_list_users(owner: User) -> None: | ||
UserFactory.create(username="user_1") | ||
UserFactory.create(username="user_2") | ||
httpx_client = ArgillaSingleton.init(api_key=owner.api_key).http_client.httpx | ||
|
||
response = list_users(client=httpx_client) |
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.
For this kind of tests I think you can use directly the client: TestClient
, fixture
def test_list_users(owner: User) -> None: | |
UserFactory.create(username="user_1") | |
UserFactory.create(username="user_2") | |
httpx_client = ArgillaSingleton.init(api_key=owner.api_key).http_client.httpx | |
response = list_users(client=httpx_client) | |
def test_list_users(client: TestClient, owner: User, owner_auth_header: dict) -> None: | |
UserFactory.create(username="user_1") | |
UserFactory.create(username="user_2") | |
client.headers.update(owner_auth_header) | |
response = list_users(client=client) |
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.
But won't the ArgillaSingleton
use the TestClient
as configured in the conftest.py
? Is this change worth it? Asking because if so, we should change this is more than one place, LMKWYT!
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.
Yes, just to be more explicit here in tests if we're using the HTTP client directly. The conftest is a fixture to use the rg.init functions with an already mocked client
Co-authored-by: Gabriel Martin <gabriel@argilla.io> Co-authored-by: Francisco Aranda <francis@argilla.io>
Also included under `TYPE_CHECKING` when applicable Co-authored-by: Francisco Aranda <francis@argilla.io>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #3169 +/- ##
===========================================
+ Coverage 90.91% 90.99% +0.08%
===========================================
Files 215 219 +4
Lines 11304 11663 +359
===========================================
+ Hits 10277 10613 +336
- Misses 1027 1050 +23
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Co-authored-by: Francisco Aranda <francis@argilla.io>
#3729) # Description This PR addresses a pending TODO upon #3169 completion where the `UserModel` was included when wrapping the `/api/users` API endpoints. So on, in this PR we remove the `WorkspaceUserModel` schema in favour of `UserModel` to avoid duplicating the same schema to avoid potential incompatibilities. **Type of change** - [X] Refactor (change restructuring the codebase without changing functionality) - [X] Improvement (change adding some improvement to an existing functionality) **How Has This Been Tested** (Please describe the tests that you ran to verify your changes. And ideally, reference `tests`) - [X] Replace outdated references to `WorkspaceUserModel` with `UserModel` and re-run the existing unit/integration tests **Checklist** - [ ] I added relevant documentation - [X] follows the style guidelines of this project - [X] I did a self-review of my code - [ ] I made corresponding changes to the documentation - [X] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK) (see text above) - [ ] I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)
Description
This PR addresses the addition of a new user-management layer in the Python client via the
User
class, wrapping up the/api/users
and/api/me
endpoints in the API v0.Closes #2968
Type of change
How Has This Been Tested
User
classuser_api
endpointsUserModel
(formerly namedUser
)Checklist