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: update update_response endpoint to replace values #3711

Merged
merged 7 commits into from
Sep 6, 2023

Conversation

gabrielmbmb
Copy link
Member

Description

After discussing with @damianpumar, we both agreed to update the PUT /api/v1/responses/{response_id} endpoint to behave like a real PUT endpoint replacing the values stored in the database with the values received in the request.

Therefore, this PR updates the PUT /api/v1/responses/{response_id} endpoint to do a complete update of the Response.values (replace the dict), as before the endpoint was behaving like a PATCH endpoint. In addition, the PR updates the validation of the responses given for the RankingQuestion when the status!=submitted allowing the following response to be valid (missing rank in some options, which means the user has not ranked this options yet):

{
    "values": {
        "ranking": {
            "value": [
                {"value": "option-a", "rank": 1},
                {"value": "option-b", "rank": 2},
                {"value": "option-c"},
                {"value": "option-d"}
            ]
        }
    },
    "status": "draft"
}

Type of change

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

How Has This Been Tested

In a local development environment:

  • Sending a request to PUT /api/v1/responses/{response_id} updates the response for a record (overwrites Response.values)
  • Sending a request to PUT /api/v1/responses/{response_id} and the above JSON payload, the server accepts it and returns 200

Checklist

  • I added relevant documentation
  • I followed 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 filled out the contributor form (see text above)
  • 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 Sep 5, 2023
@gabrielmbmb gabrielmbmb added this to the v1.16.0 milestone Sep 5, 2023
@gabrielmbmb gabrielmbmb self-assigned this Sep 5, 2023
@gabrielmbmb gabrielmbmb changed the title feat: update PUT /api/v1/responses/{response_id} endpoint feat: update update_response endpoint to replace values Sep 5, 2023
@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Patch coverage is 100.00% of modified lines.

Files Changed Coverage
src/argilla/server/contexts/datasets.py ø
src/argilla/server/models/mixins.py 100.00%
src/argilla/server/models/questions.py 100.00%

📢 Thoughts on this report? Let us know!.

@github-actions
Copy link

github-actions bot commented Sep 5, 2023

The URL of the deployed environment for this PR is https://argilla-quickstart-pr-3711-ki24f765kq-no.a.run.app

@gabrielmbmb gabrielmbmb merged commit 745ad13 into develop Sep 6, 2023
17 checks passed
@gabrielmbmb gabrielmbmb deleted the feature/update-response-endpoints branch September 6, 2023 09:17
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.

1 participant