-
Notifications
You must be signed in to change notification settings - Fork 30
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
Classifier: add the subjectID prop #2101
Conversation
Refactor Classifier to use hooks for auth change, project change and URL param changes.
ebdf831
to
f0b2190
Compare
Add subjectIDs as an optional parameter for subject selection. Use the subjects/selection endpoint if IDs are specified.
d0ee68f
to
c53ca9d
Compare
Add workflow.selectedSubjects as volatile storage for the subjectID prop.
c53ca9d
to
f5f3e34
Compare
524ca5a
to
31594a7
Compare
Update stubPanoptesJS to allow for mocking of the different subject endpoints. Mock the /subjects/selection endpoint for the specific subject selection tests.
Quick ReviewFunctionality looks good so far.
Let me do a code read to see if I can figure out answers to my own questions. |
There was a problem hiding this 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
Context: Engaging Crowds(?) wants to allow users to classify pre-selected Subjects in a pre-defined order, e.g. consecutive pages in a book.
This PR allows the Classifier to select specific subjects to Classify, by Subject ID. Without this PR, the Classifier would just pull a queue of random Subjects from the /queued
endpoint
- Man functionality: on the
lib-classifier
, the Subject(s) can be selected by ID via query string.?subject=111
for a single Subject?subject=111,222,333,444,555
for multiple Subjects
- Once the Classifier has run out pre-selected Subjects, it reverts to standard behaviour.
- Usually, this means that it pulls random Subjects from
/queued
- Minor quirk: you might encounter the same pre-selected Subject again in the randomly-generated queue.
- ❔ Not tested: what happens if the workflow doesn't use /queued, but is supposed to use /grouped instead? Code read looks fine though, since SubjectStore.advance() would just call self.populateQueue() without any arguments (i.e. normal behaviour)
- Usually, this means that it pulls random Subjects from
- New external dependency: a new Panoptes endpoint has been added,
/subjects/selection?workflow_id=...&ids=...
- e.g.
https://panoptes-staging.zooniverse.org/api/subjects/selection?workflow_id=693&ids=4218
orhttps://panoptes-staging.zooniverse.org/api/subjects/selection?workflow_id=693&ids=4218%2C4219%2C4220
- e.g.
- Error handling: classifier (correctly) crashes when encountering invalid Subject IDs.
- If an invalid subject ID is specified (either the Subject does not belong to the specified Workflow, or the subject ID is nonsense like
?subject=woofwoof
) then the /subjects/selection endpoint itself will return an 422 error. - When specifying a list of Subject IDs, then if ANY of the Subjects aren't valid, NONE of the Subjects are returned by /subjects/selection
- If an invalid subject ID is specified (either the Subject does not belong to the specified Workflow, or the subject ID is nonsense like
Functionality checks out, code read looks legit.
Testing
Tested on localhost using macOS 10+ Chrome 90
Subjects tested: all part of "I Fancy Cats"'s standard subject set on the standard workflow (693)
Testing Scenario 1: does the Classifier load the specified subject?
- Load
https://localhost:8080/?demo=true&workflow=693&subject=4218
- Confirm that the image loaded is Subject 4218.
- Confirm that the /subjects/selection endpoint is pinged with the correct workflow and subject ID.
- Reload page to ensure it wasn't pure luck that we didn't land on a randomly-selected Subject from queued that happens to be 4218.
- Repeat with Subject 4219 and 4220
Results: Looking good. 👍
Testing Scenario 2: does the Classifier load multiple specific subjects in order?
- Load
https://localhost:8080/?demo=true&workflow=693&subject=4218,4219,4220
- Confirm that the first image loaded is Subject 4218.
- Submit Classification. Confirm that the next Subject is 4219.
- Submit Classification. Confirm that the next Subject is 4220.
Results: looking good. 👍
Testing Scenario 3: does the Classifier return to standard behaviour after running out of preselected subjects?
- Repeat Scenario 1. Classify and submit.
- Next Subject should be random. Confirm that this corresponds with the first random Subject from /queued (check the Network tab)
- Repeat with Scenario 2. Classify and submit x3, then check next Subject should also be random.
Results: gooding look. 👍
Testing Scenario 4: does the Classifier refuse to load invalid Subjects?
- Try to load any of the following invalid URLs:
- https://localhost:8080/?demo=true&workflow=693&subject=73434 (Subject doesn't belong to Wf 693. Subject 73434 instead belongs to SSet 4457, Wf 3116, Proj 1807)
- https://localhost:8080/?demo=true&workflow=693&subject=woofwoof (nonsense Subject ID)
- https://localhost:8080/?demo=true&workflow=693&subject=4218,73434,4220 (Invalid subject in a list of valid subjects)
- Confirm that the Classifier just crashes altogether.
- Classifier page loads, but subject viewer + task area are empty.)
- Confirm that you're getting 422 responses from the /subjects/selection endpoint.
Results: kooling doog. 👍
Status
LGTM 👍 Stamp of approval!
I really would like to have documentation about all of the selection behaviors. |
Prior to #2101, the `Classifier` checked the logged-in user on every component update. This restores that behaviour by removing the `authClient` dependency from `useEffect`.
Refactor the
Classifier
component to use hooks and add thesubjectID
prop, which allows us to classify a specific subject. When a subject ID (or list of subject IDs) is specified, the subjects store requests subjects fromsubjects/selection
rather thansubjects/queued
.I've also updated
stubPanoptesJS
so that different responses can be specified for/subjects/queued
,/subjects/grouped
and/subjects/selection
. That's useful when you want to test that selection is using a specific endpoint.https://localhost:8080/?demo=true&workflow=693&subject=4237
https://localhost:8080/?demo=true&workflow=693&subject=4218
Package:
lib-classifier
Towards: #1876.
Closes: #2074.
Review Checklist
General
Components
Apps
yarn panic && yarn bootstrap
ordocker-compose up --build
and app works as expected?Publishing
Post-merging