Skip to content
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

Support for owner, admin and annotator role system #3104

Merged
merged 7 commits into from
Jun 16, 2023

Conversation

frascuchon
Copy link
Member

@frascuchon frascuchon commented Jun 7, 2023

Description

This PR will be the main feature branch for a huge refactor that includes:

  1. Rename the current admin role to owner keeping all the current functionality but to this new role name
  2. Support for an admin role, with operation restrictions. Users with this role can work on scoped workspaces (must be specifically linked to those workspaces), and the supported operations will be:
    • Create, update, and delete datasets
    • Copy datasets
    • Create and delete dataset records
    • Snapshot and restore feedback datasets (reading and publishing all responses)

The rest of the operations will be denied for this role (users and workspace management,...)

Closes #3094

TODO

(The rest of the tasks will be tackled as separate PR over this branch)

Closes #3094

Type of change

(Please delete options that are not relevant. Remember to title the PR according to the type of change)

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (change restructuring the codebase without changing functionality)

How Has This Been Tested

(Please describe the tests that you ran to verify your changes. And ideally, reference tests)

The tests have been updated

Checklist

  • I have merged the original branch into my forked branch
  • I added relevant documentation
  • follows the style guidelines of this project
  • I did a self-review of my code
  • I made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)

@frascuchon frascuchon added this to the v1.10.0 milestone Jun 7, 2023
@frascuchon frascuchon linked an issue Jun 7, 2023 that may be closed by this pull request
@frascuchon frascuchon changed the title Rename admin to owner Support for owner, admin and annotator role system Jun 7, 2023
@codecov
Copy link

codecov bot commented Jun 7, 2023

Codecov Report

Patch coverage: 98.21% and project coverage change: -0.01 ⚠️

Comparison is base (89de83d) 90.94% compared to head (64374b6) 90.93%.

❗ Current head 64374b6 differs from pull request most recent head 2ce5485. Consider uploading reports for the commit 2ce5485 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3104      +/-   ##
===========================================
- Coverage    90.94%   90.93%   -0.01%     
===========================================
  Files          215      216       +1     
  Lines        11347    11354       +7     
===========================================
+ Hits         10319    10325       +6     
- Misses        1028     1029       +1     
Flag Coverage Δ
pytest 90.93% <98.21%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/argilla/server/seeds.py 0.00% <ø> (ø)
src/argilla/tasks/users/create.py 91.11% <ø> (-4.45%) ⬇️
src/argilla/server/policies.py 98.60% <96.72%> (-0.66%) ⬇️
src/argilla/client/client.py 94.53% <100.00%> (+0.66%) ⬆️
src/argilla/client/sdk/client.py 88.97% <100.00%> (+0.26%) ⬆️
src/argilla/server/apis/v0/handlers/users.py 100.00% <100.00%> (ø)
src/argilla/server/apis/v0/handlers/workspaces.py 88.33% <100.00%> (ø)
src/argilla/server/apis/v1/handlers/datasets.py 100.00% <100.00%> (ø)
src/argilla/server/apis/v1/handlers/fields.py 100.00% <100.00%> (ø)
src/argilla/server/apis/v1/handlers/questions.py 100.00% <100.00%> (ø)
... and 9 more

... and 11 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

frascuchon and others added 4 commits June 13, 2023 08:59
# Description

This PR brings changed to support 3 kinds of roles: 
- `owner`: full access (old `admin` role)
- `admin`: workspace-level operations (create/delete datasets, add
records,...)
-  `annotator`: same as before. Just for annotation purposes.


Most of the tests have been revisited regarding the `mocked_client`
fixture. I've also added variations o tests to support most roles as
possible for the tested functionality. Since a huge number of changes
have been included here, I will add more details in future PRs.


Refs #3094 

**Type of change**

(Please delete options that are not relevant. Remember to title the PR
according to the type of change)

- [x] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [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`)

Tests have been updated 

**Checklist**

- [x] I have merged the original branch into my forked branch
- [x] I added relevant documentation
- [ ] 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
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)

---------

Co-authored-by: Gabriel Martín Blázquez <gmartinbdev@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@frascuchon frascuchon modified the milestones: v1.10.0, v1.11.0 Jun 14, 2023
# Description

This PRs mainly adds a new users task command to update an existing user
(for now, only the user role can be used, but other fields like last
name or even the password can be updated through this command)

Also, some refactors have been applied:

- Remove the role_callback function, since `typer` tries to cast the
role into a valid `UserRole` value.
- The default user is defined with the `admin` role, instead of `owner`.
This still works for environments with one single user and workspace.


**Type of change**

(Please delete options that are not relevant. Remember to title the PR
according to the type of change)

- [x] New feature (non-breaking change which adds functionality)
- [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`)

New tests have been added

**Checklist**

- [x] I have merged the original branch into my forked branch
- [ ] 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
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)
@frascuchon frascuchon marked this pull request as ready for review June 16, 2023 13:11
@frascuchon frascuchon merged commit a99a308 into develop Jun 16, 2023
@frascuchon frascuchon deleted the 3094-support-for-owner-and-workspace-admin-roles branch June 16, 2023 13:35
gabrielmbmb added a commit that referenced this pull request Jun 19, 2023
# Description

As of the recent addition of the `owner` user at
#3104, once we merged
#3180, the unit tests were not
passing in `develop` due to the addition of the new role.

So on, we've refactored the `Workspace` unit tests for both the Python
client and the SDK to use the `owner` user defined in `conftest.py` as
the user to use to authenticate against the Argilla API and the one to
add/delete from the workspace/s if applicable.

Kudos to @gabrielmbmb for initially proposing this approach!

**Type of change**

- [X] Bug fix (non-breaking change which fixes an issue)
- [X] Refactor (change restructuring the codebase without changing
functionality)

**How Has This Been Tested**

- [X] Refactored unit tests to use `owner`
- [X] Remove the API calls with the factories: `WorkspaceFactory` and
`WorkspaceUserFactory`

**Checklist**

- [X] I have merged the original branch into my forked branch
- [X] follows the style guidelines of this project
- [X] I did a self-review of my code
- [X] My changes generate no new warnings
- [X] I have added tests that prove my fix is effective or that my
feature works

---------

Co-authored-by: gabrielmbmb <gmartinbdev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for owner and workspace admin roles
1 participant