Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces two new components MesmerForm and PolarisForm that contain workflow specific forms so that those jobs can be parameterized. The behavior for mesmer is unchanged, which polaris can now pick what segmentation model to use and which channels to use segmentation.
Each Form component updates the jobForm object in the Predict component. We now send the jobForm object to the /predict route, which unpacks the form to send to the consumer. As we expand the supported workflows and the contents of the jobForm varies more, we'll need to revisit how the route handles the jobForm contents.
I've also refactored the ChannelForm to simplify the state for selected channels. Previously, there were four collaborating variables that tracked the selected channels including:
{ nuclei: 'red', cytoplasm: 'green' }
['red, 'green', 'blue']
{ red: 0, green: 1, blue: 2}
['nuclei', 'cytoplasm']
These variables had to be transformed between each other with complex expression like
Object.keys(channels).reduce((r, c) => Object.assign(r, { [channels[c]]: parseInt((r[channels[c]] || '').concat(c)) }), {})
andrequiredChannels.map(c => channelValues[targetChannels[c]])
.I've refactored these variables into just requiredChannels
['nuclei', 'cytoplasm']
and selectedChannels[0, 1]
which records which channel index should be used for each required channel. The selectedChannels are more similar to the data submitted to the api and is transformed with a simple expressionselectedChannels.join(',')
to yield0,1
. I've also moved ['red', 'green', 'blue'] to an internal detail of the ChannelDropdown component as it is only used in display text.