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

PUT request for changing a task's text do not save on the backend #2212

Closed
CKrawczyk opened this issue Mar 6, 2017 · 3 comments · Fixed by #2289
Closed

PUT request for changing a task's text do not save on the backend #2212

CKrawczyk opened this issue Mar 6, 2017 · 3 comments · Fixed by #2289

Comments

@CKrawczyk
Copy link

When changing just the text for a task the changes don't save on the backend (e.g. refreshing the pages causes the changes to go away).

Example request made by the lab when changing a task's main text from test 2 to test (everything looks normal to me):

Request URL:https://www.zooniverse.org/api/workflows/2576
Request Method:PUT
Status Code:200 

Request Headers:
  :authority:www.zooniverse.org
  :method:PUT
  :path:/api/workflows/2576
  :scheme:https
  accept:application/vnd.api+json; version=1
  accept-encoding:gzip, deflate, sdch, br
  accept-language:en-US,en;q=0.8
  cache-control:no-cache
  content-length:302
  content-type:application/json
  if-match:"2a53e15416ba166e48bbd39fb608fc49"
  origin:https://www.zooniverse.org
  pragma:no-cache
  referer:https://www.zooniverse.org/lab/3174/workflow/2576

Request Payload: {"workflows":{"tasks":{"T0":{"help":"","type":"single","answers":[],"question":"test"},"T1":{"help":"","type":"drawing","tools":[{"type":"point","color":"#00ff00","label":"Tool name","details":[{"help":"","type":"text","instruction":"Enter an instruction."}]}],"instruction":"Explain what to draw."}}}}

Response: {"workflows":[{"id":"2576","display_name":"new worfklow title","tasks":{"T0":{"help":"","type":"single","answers":[],"question":"test "},"T1":{"help":"","type":"drawing","tools":[{"type":"point","color":"#00ff00","label":"Tool name","details":[{"help":"","type":"text","instruction":"Enter an instruction."}]}],"instruction":"Explain what to draw."}},"classifications_count":0,"subjects_count":0,"created_at":"2016-09-14T08:26:58.470Z","updated_at":"2017-02-14T13:49:34.200Z","finished_at":null,"first_task":"T0","primary_language":"en","version":"5.8","content_language":"en","prioritized":false,"grouped":false,"pairwise":false,"retirement":{"criteria":"classification_count","options":{"count":15}},"retired_set_member_subjects_count":0,"href":"/workflows/2576","active":true,"aggregation":{},"nero_config":{},"configuration":{},"public_gold_standard":false,"completeness":0.0,"links":{"project":"3174","attached_images":{"href":"/workflows/2576/attached_images","type":"attached_images"},"classifications_export":{"href":"/workflows/2576/classifications_export","type":"classifications_exports"}}}],"links":{"workflows.project":{"href":"/projects/{workflows.project}","type":"projects"},"workflows.subject_sets":{"href":"/subject_sets?workflow_id={workflows.id}","type":"subject_sets"},"workflows.tutorial_subject":{"href":"/subjects/{workflows.tutorial_subject}","type":"tutorial_subjects"},"workflows.attached_images":{"href":"/workflows/{workflows.id}/attached_images","type":"media"},"workflows.classifications_export":{"href":"/workflows/{workflows.id}/classifications_export","type":"media"}},"meta":{"workflows":{"page":1,"page_size":20,"count":1,"include":[],"page_count":1,"previous_page":null,"next_page":null,"first_href":"/workflows","previous_href":null,"next_href":null,"last_href":"/workflows"}}}

And when refreshing the lab page the following request is made:

Request URL:https://www.zooniverse.org/api/workflows/2576
Request Method:GET
Status Code:200 

Request Headers:
  :authority:www.zooniverse.org
  :method:GET
  :path:/api/workflows/2576
  :scheme:https
  accept:application/vnd.api+json; version=1
  accept-encoding:gzip, deflate, sdch, br
  accept-language:en-US,en;q=0.8
  cache-control:no-cache
  content-type:application/json
  pragma:no-cache
  referer:https://www.zooniverse.org/lab/3174/workflow/2576

Response: {"workflows":[{"id":"2576","display_name":"new worfklow title","tasks":{"T0":{"help":"","type":"single","answers":[],"question":"test 2"},"T1":{"help":"","type":"drawing","tools":[{"type":"point","color":"#00ff00","label":"Tool name","details":[{"help":"","type":"text","instruction":"Enter an instruction."}]}],"instruction":"Explain what to draw."}},"classifications_count":0,"subjects_count":0,"created_at":"2016-09-14T08:26:58.470Z","updated_at":"2017-02-14T13:49:34.200Z","finished_at":null,"first_task":"T0","primary_language":"en","version":"5.7","content_language":"en","prioritized":false,"grouped":false,"pairwise":false,"retirement":{"criteria":"classification_count","options":{"count":15}},"retired_set_member_subjects_count":0,"href":"/workflows/2576","active":true,"aggregation":{},"nero_config":{},"configuration":{},"public_gold_standard":false,"completeness":0.0,"links":{"project":"3174","attached_images":{"href":"/workflows/2576/attached_images","type":"attached_images"},"classifications_export":{"href":"/workflows/2576/classifications_export","type":"classifications_exports"}}}],"links":{"workflows.project":{"href":"/projects/{workflows.project}","type":"projects"},"workflows.subject_sets":{"href":"/subject_sets?workflow_id={workflows.id}","type":"subject_sets"},"workflows.tutorial_subject":{"href":"/subjects/{workflows.tutorial_subject}","type":"tutorial_subjects"},"workflows.attached_images":{"href":"/workflows/{workflows.id}/attached_images","type":"media"},"workflows.classifications_export":{"href":"/workflows/{workflows.id}/classifications_export","type":"media"}},"meta":{"workflows":{"page":1,"page_size":20,"count":1,"include":[],"page_count":1,"previous_page":null,"next_page":null,"first_href":"/workflows?id=2576","previous_href":null,"next_href":null,"last_href":"/workflows?id=2576"}}}

Note that the Response for Task T0s question key is not the same between the PUT and GET requests.

If more things change on the workflows besides the task text (e.g. adding a new task) the changes save as expected. This same behavior is see when updating a workflow's task text with the python-client as well.

@adammcmaster
Copy link
Contributor

Just noting this bug was previously discussed on Slack but none of us actually opened an issue for it. Example with the python client:

>>> w.tasks['T0']['question']
u'que?'
>>> w.tasks['T0']['question'] = 'huh?'
>>> w.save()
>>> w.tasks['T0']['question']
u'que?'
>>> w.first_task
u'T0'
>>> w.first_task = 'T1'
>>> w.save()
>>> w.first_task
u'T1'
>>> w.tasks['T0']['question']
u'huh?'

@camallen
Copy link
Contributor

camallen commented Mar 6, 2017

@zwolf you got time to have look at this?

@camallen
Copy link
Contributor

Just noting that i think this is caused by the resource not having it's updated at changed and the serializer response is cached for based on tihs. The data is all being set ok the backend but we'er serializing old data.

You can check this by making your workflow active / inactive to force the updated_at timestamp to be changed. I've got a reverted PR that broke other things that should fix this issue on it's own #2169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants