-
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
Engaging Crowds: enable indexed subject selection #2148
Conversation
2764e5d
to
1fb3b36
Compare
fdc70bc
to
fb41112
Compare
ac1df53
to
ef2fbfe
Compare
ef2fbfe
to
2583c95
Compare
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.
cb650fe
to
20417a7
Compare
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. |
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
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".
- For this PR, a SSet is "indexed" if it and its WF have the correct metadata. (i.e., subject_set.metadata.indexFields = [...], and workflow.grouped = true)
- ❕ Advanced: this may have an interplay with Engaging Crowds: switch to Datasette for subject browse & search #2132 , in which the "is this indexed?" question is answered by querying an external indexing service.
⚠️ 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:
- Default. Random subject from
/queued?workflow_id
- I Fancy Cats 👍 - Grouped Workflow. WF has the .grouped attribute,
/queued?workflow_id&subject_set_id
- Shaun's random test workflow 👍 - Subject Group Viewer. Super specific case,
/grouped?num_columns&num_rows&workflow_id
- Survos test 👍 - 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 👍 - 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!
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? |
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 thinkThe logic for subject selection was getting messy, so I've moved the selection strategy into its own helper function. I think that will fixsubjects.populateQueue()
might still need some refactoring.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
Components
Apps
yarn panic && yarn bootstrap
ordocker-compose up --build
and app works as expected?Publishing
Post-merging