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

feat: add draft status to Response #3033

Merged
merged 18 commits into from
Jun 2, 2023
Merged

Conversation

gabrielmbmb
Copy link
Member

@gabrielmbmb gabrielmbmb commented May 30, 2023

Description

I've added a new possible status for the Response model called draft. As this is a new possible status, I've also updated the GET /api/v1/me/datasets/:dataset_id/metrics endpoint to return also the count of responses with their status equal to draft.

In addition, I've removed the SubmittedResponseCreate and DiscardedResponseCreate classes and the discriminated union in which they were being used (ResponseCreate), and instead I've created a pydantic.BaseModel class called ResponseCreate.

Also, I've refactored the functions for getting the count of the responses based on their status:

  • count_responses_by_dataset_id_and_user_id now accepts an optional response_status argument
  • count_submitted_responses_by_dataset_id_and_user_id and count_discarded_responses_by_dataset_id_and_user_id have been removed.

Finally, I've updated the unit tests for the endpoints GET /api/v1/me/datasets/:dataset_id/metrics, GET /api/v1/me/datasets/:dataset_id/records and POST /api/v1/records/:record_id/responses.

Closes #3008

Type of change

  • New feature (non-breaking change which adds functionality)
  • Refactor

How Has This Been Tested

All the relevant unit tests for these changes have been updated and re-executed.

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/)

@gabrielmbmb gabrielmbmb added type: enhancement Indicates new feature requests area: api Indicates that an issue or pull request is related to the Fast API server or REST endpoints labels May 30, 2023
@gabrielmbmb gabrielmbmb added this to the v1.9.0 milestone May 30, 2023
@gabrielmbmb gabrielmbmb requested a review from frascuchon May 30, 2023 14:30
@gabrielmbmb
Copy link
Member Author

I'll update some unit tests that I've missed from src/argilla/server/api/v1/test_records.py

@gabrielmbmb gabrielmbmb force-pushed the feat/response-status-draft branch from 5b42ba3 to 38f4e2d Compare May 30, 2023 15:37
@codecov
Copy link

codecov bot commented May 31, 2023

Codecov Report

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

Comparison is base (3bee501) 90.81% compared to head (415c1c8) 90.81%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3033      +/-   ##
===========================================
- Coverage    90.81%   90.81%   -0.01%     
===========================================
  Files          208      208              
  Lines        11181    11179       -2     
===========================================
- Hits         10154    10152       -2     
  Misses        1027     1027              
Flag Coverage Δ
pytest 90.81% <100.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
src/argilla/server/apis/v1/handlers/datasets.py 100.00% <ø> (ø)
src/argilla/server/contexts/datasets.py 96.27% <100.00%> (ø)
src/argilla/server/models/models.py 97.84% <100.00%> (+0.01%) ⬆️
src/argilla/server/schemas/v1/datasets.py 100.00% <100.00%> (ø)
src/argilla/server/schemas/v1/records.py 100.00% <100.00%> (ø)

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

@@ -101,7 +101,7 @@ def create_multi_label_selection_questions(dataset: "Dataset") -> None:
),
],
)
def test_create_record_response(
def test_create_record_response_with_valid_values(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the new test name, we should parameterize also the status and create responses with partial values (this is a difference between submitted and draft)

Copy link
Member

@frascuchon frascuchon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super!!!

Just adding some tests regarding draft responses with partial values (which should be created correctly)

@gabrielmbmb gabrielmbmb merged commit 48724ab into develop Jun 2, 2023
@gabrielmbmb gabrielmbmb deleted the feat/response-status-draft branch June 2, 2023 12:13
davidberenstein1957 pushed a commit that referenced this pull request Jun 5, 2023
# Description

I've added a new possible status for the `Response` model called
`draft`. As this is a new possible status, I've also updated the `GET
/api/v1/me/datasets/:dataset_id/metrics` endpoint to return also the
count of responses with their status equal to `draft`.

In addition, I've removed the `SubmittedResponseCreate` and
`DiscardedResponseCreate` classes and the discriminated union in which
they were being used (`ResponseCreate`), and instead I've created a
`pydantic.BaseModel` class called `ResponseCreate`.

Also, I've refactored the functions for getting the count of the
responses based on their status:

- `count_responses_by_dataset_id_and_user_id` now accepts an optional
`response_status` argument
- `count_submitted_responses_by_dataset_id_and_user_id` and
`count_discarded_responses_by_dataset_id_and_user_id` have been removed.

Finally, I've updated the unit tests for the endpoints `GET
/api/v1/me/datasets/:dataset_id/metrics`, `GET
/api/v1/me/datasets/:dataset_id/records` and `POST
/api/v1/records/:record_id/responses`.

Closes #3008

**Type of change**

- [x] New feature (non-breaking change which adds functionality)
- [x] Refactor 

**How Has This Been Tested**

All the relevant unit tests for these changes have been updated and
re-executed.
 
**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/)

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Francisco Aranda <[email protected]>
davidberenstein1957 pushed a commit that referenced this pull request Jun 7, 2023
# Description

I've added a new possible status for the `Response` model called
`draft`. As this is a new possible status, I've also updated the `GET
/api/v1/me/datasets/:dataset_id/metrics` endpoint to return also the
count of responses with their status equal to `draft`.

In addition, I've removed the `SubmittedResponseCreate` and
`DiscardedResponseCreate` classes and the discriminated union in which
they were being used (`ResponseCreate`), and instead I've created a
`pydantic.BaseModel` class called `ResponseCreate`.

Also, I've refactored the functions for getting the count of the
responses based on their status:

- `count_responses_by_dataset_id_and_user_id` now accepts an optional
`response_status` argument
- `count_submitted_responses_by_dataset_id_and_user_id` and
`count_discarded_responses_by_dataset_id_and_user_id` have been removed.

Finally, I've updated the unit tests for the endpoints `GET
/api/v1/me/datasets/:dataset_id/metrics`, `GET
/api/v1/me/datasets/:dataset_id/records` and `POST
/api/v1/records/:record_id/responses`.

Closes #3008

**Type of change**

- [x] New feature (non-breaking change which adds functionality)
- [x] Refactor 

**How Has This Been Tested**

All the relevant unit tests for these changes have been updated and
re-executed.
 
**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/)

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Francisco Aranda <[email protected]>
alvarobartt added a commit that referenced this pull request Sep 14, 2023
# Description

This PR replaces the pre-defined `Literal`s for the response status in
both the Python SDK and the Python client, so as to use an `Enum`
instead. Besides that, also the `draft` status has been included as it
was previously missing, but as of
#3033 it was included in the
API and as of #3541 it was
also included in the UI.

Closes #3745 

**Type of change**

- [X] Bug fix (non-breaking change which fixes an issue)
- [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] Added `draft` as another use-case of the `ResponseSchema` unit
tests
- [x] Added responses with `draft` status in `from_argilla` 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
- [x] 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)
- [x] I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Indicates that an issue or pull request is related to the Fast API server or REST endpoints type: enhancement Indicates new feature requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

draft status support
2 participants