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

Engaging Crowds: enable indexed subject selection #2148

Merged
merged 8 commits into from
May 14, 2021

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented May 4, 2021

Get indexed subject selection working for Engaging Crowds projects. Indexed selection shows you every subject from an indexed set in order. Setting this to draft because I think subjects.populateQueue() might still need some refactoring. The logic for subject selection was getting messy, so I've moved the selection strategy into its own helper function. I think that will fix 422: Unprocessable entity errors, which have been happening when subjects were requested with an invalid query. subjectSelectionStrategy should only return valid query parameters for each API endpoint.

Test URLs:
https://localhost:8080/?demo=true&project=12268&workflow=17077&subjectSet=92752&env=production
Load subject set 92752 and classify every subject from the first one(priority 129) to the last.

https://localhost:8080/?demo=true&project=12268&workflow=17077&subjectSet=92752&subject=58047423&env=production
Load subject set 92752 and classify every subject from a specified subject (priority 136) to the last.

In demo mode, you can skip quickly through that set by selecting 'Blank page' for every page.

https://localhost:8080?demo=true
Should continue to load I Fancy Cats with random subject selection.

Package:
lib-classifier

Closes #1876.

Review Checklist

General

  • Are the tests passing locally and on Travis?
  • Is the documentation up to date?

Components

Apps

  • Does it work in all major browsers: Firefox, Chrome, Edge, Safari?
  • Does it work on mobile?
  • Can you yarn panic && yarn bootstrap or docker-compose up --build and app works as expected?

Publishing

  • Is the changelog updated?
  • Are the dependencies updated for apps and libraries that are using the newly published library?

Post-merging

@eatyourgreens eatyourgreens force-pushed the indexed-subject-selection branch 2 times, most recently from 2764e5d to 1fb3b36 Compare May 5, 2021 09:14
@eatyourgreens eatyourgreens marked this pull request as ready for review May 5, 2021 09:16
@eatyourgreens eatyourgreens force-pushed the indexed-subject-selection branch 2 times, most recently from fdc70bc to fb41112 Compare May 5, 2021 11:01
@eatyourgreens eatyourgreens force-pushed the indexed-subject-selection branch 3 times, most recently from ac1df53 to ef2fbfe Compare May 5, 2021 13:57
@eatyourgreens eatyourgreens added the enhancement New feature or request label May 5, 2021
@eatyourgreens eatyourgreens force-pushed the indexed-subject-selection branch from ef2fbfe to 2583c95 Compare May 10, 2021 14:08
@shaunanoordin
Copy link
Member

Code read looks good 👍 I'll get to testing on Thursday.

getIndexedSubjects gets all subjects, in order, from a prioritised subject set, starting from an optional priority.
Add getIndexedSubjects to subjects.populateQueue(). Add subjects.last as a helper to get the last subject from the queue.
Add a helper which generates the URL and query params for each subject selection strategy: specific subjects; indexed, ordered subjects; subject groups; grouped random selection; random selection.
@eatyourgreens eatyourgreens force-pushed the indexed-subject-selection branch from cb650fe to 20417a7 Compare May 12, 2021 10:20
@eatyourgreens
Copy link
Contributor Author

eatyourgreens commented May 12, 2021

I've rebased this to bring in the latest changes to the project app. If you rebuild the classifier, then you should be able to use the subject picker, from the project home page, and go straight through to classifying your chosen subject. If you classify in demo mode, you should be able to verify that you get all of a set's subjects in sequence.
http://local.zooniverse.org:3000/projects/bogden/scarlets-and-blues?env=production&demo=true

Copy link
Member

@shaunanoordin shaunanoordin left a comment

Choose a reason for hiding this comment

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

PR Review

Package: lib-classifier
TL;DR: Classifier's subject selection logic has been reorganised, and also now has a clause for "indexed" subject sets.

This PR adds some functionality and cleans up how the Classifier fetches Subjects.

  • The "where should I get my Subject from?" logic in the Classifier has been organised into the subjectSelectionStrategy() function. (Personal note: noice 👍 )
  • In addition to the existing methods of selecting Subjects (1. default, use /queued endpoint, 2. workflow is 'grouped', use /queued and specify SSet + WF, 3. Subject Group Viewer, use /grouped endpoint, 4. list of specific Subjects, use /selection endpoint)...
  • ...a new method for been added, specifically for Workflows whose active Subject Set is "indexed".
  • ⚠️ Dev note: pay attention to the precedence of the subject selection. If a WF is 'grouped' AND is "indexed", the "is indexed" logic takes priority.

Testing

Tested on localhost + Chrome + macOS.

  • Primary goal is to run several different projects/workflows/subject sets through the Classifier to test that every distinct subject selection clause/scenario works correctly.
  • This can be confirmed by checking that the network is making requests to the correct endpoint (e.g. /queued or /selection) with the correct parameters (e.g. ?workflow for standard selection, ?workflow&subject_set for grouped)

Testing results:

  1. Default. Random subject from /queued?workflow_id - I Fancy Cats 👍
  2. Grouped Workflow. WF has the .grouped attribute, /queued?workflow_id&subject_set_id - Shaun's random test workflow 👍
  3. Subject Group Viewer. Super specific case, /grouped?num_columns&num_rows&workflow_id - Survos test 👍
  4. Indexed Subject Set. WF has subjects on the external Datasette indexing service, which provides a list of 6 Subjects, which then connects to /selection?ids=...6... - Scarlets & Blues 👍
  5. Indexed SSet with specific Subject ID. As (4), but with an additional specific subject ID - Scarlets & Blues 👍
  • Note to self: there are TWO network requests to /selection. The first is triggered before the requests to Datasette and contains that specified Subject ID, then the second contains the 6 Subject IDs from Datasette.
  • When I was doing the code read, I thought only the first call would trigger, so huh! I should re-read the code again to fully understand the flow. Still, this functions as expected, so the 👍 remains.

Status

LGTM! 👍 The new stuff works as expected, and the old stuff ain't broken.

I can think of additional test scenarios (e.g. what if I drop some parameters? Will it florp?) but I don't believe they're necessary to get this PR in. Let's go!

@github-actions github-actions bot added the approved This PR is approved for merging label May 13, 2021
@eatyourgreens eatyourgreens merged commit 9bfa439 into master May 14, 2021
@eatyourgreens eatyourgreens deleted the indexed-subject-selection branch May 14, 2021 08:12
@eatyourgreens
Copy link
Contributor Author

Note to self: there are TWO network requests to /selection. The first is triggered before the requests to Datasette and contains that specified Subject ID, then the second contains the 6 Subject IDs from Datasette.

The selector needs a subject priority in order to work (get all subjects greater than priority x.) The way I've done that is to get the specified subject from Panoptes, get its priority then request 10 IDs from Datasette, greater than that priority. There could well be a way to do this in Datasette with a single query, or maybe with nested queries?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved This PR is approved for merging enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Classifier: Enable subject selection by subject ID in the subjects store
2 participants