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

VV - Implement Classifier Tool/Task #6511

Merged
merged 3 commits into from
Dec 10, 2024
Merged

VV - Implement Classifier Tool/Task #6511

merged 3 commits into from
Dec 10, 2024

Conversation

kieftrav
Copy link
Contributor

@kieftrav kieftrav commented Dec 3, 2024

Package

  • lib-classifier

Describe your changes

Create the Volumetric Tool/Task and properly wire it into the Classifier. Also creates the basic structure for the Annotation, but that will be refactored/fleshed out in the follow up PR. Specifically, there is a missing VolumetricAnnotation.spec.js file that is missing and will be added in the next PR (along with the incorporation of the Volumetric Viewer's annotation model).

How to Review

  • All tests should pass
  • Volumetric Task should load in local Storybook
  • Loading up the Classifier locally with my staging Volumetric Viewer task should load up the TaskArea properly
  • Design review will be completed in a later PR when Sean's styles are incorporated fully
  • README should be descriptive and helpful

General

  • Tests are passing locally and on Github
  • Documentation is up to date and changelog has been updated if appropriate
  • You can yarn panic && yarn bootstrap or docker-compose up --build and FEM works as expected
  • FEM works in all major desktop browsers: Firefox, Chrome, Edge, Safari (Use Browserstack account as needed)
  • FEM works in a mobile browser

General UX

Example Staging Project: i-fancy-cats

  • All pages of a FEM project load: Home Page, Classify Page, and About Pages
  • Can submit a classification
  • Can sign-in and sign-out
  • The component is accessible

New Feature

  • The PR creator has listed user actions to use when testing the new feature
  • Unit tests are included for the new feature
  • A storybook story has been created or updated
    • Example of SlideTutorial component with docgen comments, and its story

Post-merge

  • This PR adds translations keys to English dictionary(s). See guidance for pulling new keys to Lokalise here.

@kieftrav kieftrav marked this pull request as draft December 3, 2024 16:07
@kieftrav kieftrav changed the title WIP: VV - ToolModel WIP: VV - Tool & Task Dec 3, 2024
@coveralls
Copy link

coveralls commented Dec 3, 2024

Coverage Status

coverage: 77.58% (+0.04%) from 77.545%
when pulling dfd24ce on vv-tool
into 0a09c9d on master.

@kieftrav kieftrav changed the title WIP: VV - Tool & Task VV - Implement Classifier Tool Dec 5, 2024
@kieftrav kieftrav marked this pull request as ready for review December 5, 2024 16:59
@kieftrav kieftrav changed the title VV - Implement Classifier Tool VV - Implement Classifier Tool/Task Dec 5, 2024
@goplayoutside3 goplayoutside3 self-assigned this Dec 6, 2024
Copy link
Contributor

@goplayoutside3 goplayoutside3 left a comment

Choose a reason for hiding this comment

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

I can run lib-classifier locally or app-project locally and see a viewer + task at https://local.zooniverse.org:3000/kieftrav/volumetric-viewer 👍

Two blocking things:

  1. I'm unable to run lib-classifier's Storybook on this branch. Every story errors with Error: Cannot find module 'ajv-formats'. Is that the case for you?
  2. The handling of disabled in VolumetricTask is hardcoded and therefore contradicts its Readme statement about disabling the task UI until the subject's json content is loaded.

Comment on lines 18 to 19
align-content: center;
display: block;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is display: block not flex, so align-content won't apply. Did you mean to include this change?

Copy link
Contributor Author

@kieftrav kieftrav Dec 9, 2024

Choose a reason for hiding this comment

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

So, when I revert this the alignment looks off. My understanding is that the align-content helps with the current element in the context of it's parent flex attribute. Could be wrong, but was trying to fix the visual issue you see in the screenshots below. Happy to revert if it should be handled in another way.

missing-align-content
with-align-content

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see. Through PR history it looks like the display: block was copy pasted from when the label text was a span instead of a Grommet Text. This alignment change is fine to keep in this PR, but I recommend removing display: block to avoid confusion during code read. TBH it doesn't even need the margin: 1em 0 either. That was probably an attempt to vertically align the text awhile back, now solved by align-content instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome - removed both and looks good.


<TaskInput
checked={true}
disabled={false}
Copy link
Contributor

Choose a reason for hiding this comment

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

The ReadMe for this components says "The volumetric task is disabled until the subject's JSON content is loaded". You've hardcoded disabled as false here. How is the task disabled while JSON content is loading? Did you mean to add that feature in a separate PR?

Copy link
Contributor Author

@kieftrav kieftrav Dec 9, 2024

Choose a reason for hiding this comment

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

I updated the README and code... I meant to disable the task until the Subject is loaded. This has been fixed/added and elaborated a bit more in my reply below.

</StyledInstructionText>

<TaskInput
checked={true}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this hardcoded as true because there's only ever one active tool in any volumetric project? If that's the case please include a brief code comment here because checked and index props for TaskInput were originally designed for multi-tool drawing tasks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - that's why. Added the comment.

Comment on lines +19 to +22
it("should show the classification count", function () {
render(<DefaultStory />)
expect(screen.getByText("InputStatus.drawn")).to.be.ok()
})
Copy link
Contributor

Choose a reason for hiding this comment

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

This works for now, but InputStatus.drawn also includes the variable count. A more robust test would look for count = 3 (because that's what you've hardcoded it as for now), and when the annotations feature is added for volumetric subjects, then you'd pass annotations to the VolumetricTask stories and look for the appropriate count number used in the stories.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup - agreed. That'll come in the next PR.

@@ -0,0 +1,23 @@
import cuid from "cuid"
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment just for awareness that if you'e going to continue using cuid it is a deprecated third-party package as documented in #6493. All of the other task models still use it so this is just an fyi.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup - thank you for the cross-reference visibility

return self.experimental_tools.includes('volumetricViewer')
return self.experimental_tools.includes('volumetricProject')
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed the label on your staging project's admin page is still VolumetricViewer. Are there still updates needed in the PFE codebase to align it with VolumetricProject?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope - these will be kept in sync when PFE PR #7227 merges & is deployed.

@kieftrav
Copy link
Contributor Author

kieftrav commented Dec 9, 2024

I can run lib-classifier locally or app-project locally and see a viewer + task at https://local.zooniverse.org:3000/kieftrav/volumetric-viewer 👍

Two blocking things:

  1. I'm unable to run lib-classifier's Storybook on this branch. Every story errors with Error: Cannot find module 'ajv-formats'. Is that the case for you?

No - I did a yarn panic && yarn bootstrap and it worked just fine to run yarn storybook within the lib-classifier directory... I did a quick search on the ajv-formats on NPM and it looks like URL/date formatting/parsing... Cruft from some other work maybe?

  1. The handling of disabled in VolumetricTask is hardcoded and therefore contradicts its Readme statement about disabling the task UI until the subject's json content is loaded.

Good catch. I added in a check for the subjectReadyState to get the Subject's loading state. This will also be the basis for the Annotation details that'll be pulled into the next PR.

Comment on lines 45 to 47
function VolumetricTask({ task }) {
const stores = useContext(MobXProviderContext)
const subjectReadyState = stores.classifierStore?.subjectViewer?.loadingState ?? asyncStates.loading
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
function VolumetricTask({ task }) {
const stores = useContext(MobXProviderContext)
const subjectReadyState = stores.classifierStore?.subjectViewer?.loadingState ?? asyncStates.loading
function VolumetricTask({ disabled = false, task }) {

disabled is already available as a prop from Tasks

No need to hook into context, you should use the disabled prop already provided. Examples are in SurveyTask, SimpleDropdownTask, TextFromSubjectTask, SingleChoiceTask, etc.

(Sorry if this shows up as a dupe notification, I just wanted to re-comment with code changes suggested)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got this change incorporated as well. Thanks!

Copy link
Contributor

@goplayoutside3 goplayoutside3 left a comment

Choose a reason for hiding this comment

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

Storybook looks good. See my two recent comments for non-blocking code clean up.

@github-actions github-actions bot added the approved This PR is approved for merging label Dec 9, 2024
@kieftrav kieftrav merged commit cd2796e into master Dec 10, 2024
7 checks passed
@kieftrav kieftrav deleted the vv-tool branch December 10, 2024 14:24
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants