-
Notifications
You must be signed in to change notification settings - Fork 8
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
Y24-268 - Create a presenter for automated submission for WGS branch on Adp Lig plate #1982
Open
StephenHulme
wants to merge
21
commits into
develop
Choose a base branch
from
y24-268-adp-lig-plate-automated-submission
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d8c4a08
feat: add wgs branch initial plate purpose
StephenHulme db07ab5
Merge branch 'develop' into y24-268-adp-lig-plate-automated-submission
StephenHulme 9e5cf02
wip: lcmt
StephenHulme 3478941
refactor: allow combining of sidebar elements using a parent container
StephenHulme 856acef
fix: change choose-workflow message when there is an active workflow
StephenHulme 1823148
feat: create a new PermissiveSubmissionPlatePresenter and state machine
StephenHulme fc0507b
fix: allow plates to be passed in PermissiveSubmissionPlatePresenter
StephenHulme 9ffc791
style: clean-up comments
StephenHulme 531230d
style: clean-up another comment
StephenHulme 2f2b8a2
fix: add temporary request options
StephenHulme d15c05e
refactor: pull out submission behviour into a separate module
StephenHulme 9d5ad09
fix: allow new presenter to be independent of SubmissionPlatePresenter
StephenHulme 25c46ff
tests: add tests for PermissiveSubmissionPlatePresenter
StephenHulme 06a88de
style: lint
StephenHulme 29150e1
Merge branch 'develop' into y24-268-adp-lig-plate-automated-submission
StephenHulme 13bb548
style: remove old comment
StephenHulme a132f2d
style: update documentation comments
StephenHulme af888f7
tests: it_behaves_like a stock presenter becomes it allows state change
StephenHulme a154da1
fix: only allow a new submission if none are currently active or pending
StephenHulme dd447a1
fix: clean up display of existing submissions card
StephenHulme 44817ff
fix: keep it simple by generalising the workflows message
StephenHulme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
app/models/concerns/presenters/statemachine/permissive_submission.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# frozen_string_literal: true | ||
|
||
require_dependency 'presenters/statemachine' | ||
module Presenters::Statemachine | ||
# | ||
# Presenters::Statemachine::PermissiveSubmission can be included in a class to | ||
# provide a state machine with the following behaviour: | ||
# - When plates are 'passed', a combined default and submission sidebar will | ||
# be displayed. This sidebar allows the user to build a submission for the | ||
# plate, while still allowing child plates to be created. | ||
# - When plates are 'pending', only the default sidebar will be displayed, | ||
# allowing the user to create the child plates. | ||
# - In all other states the default sidebar will be used. | ||
# - In all states the library passing is not permitted. | ||
# | ||
# Typically this state machine should be used in conjunction with an input | ||
# plate purpose. {file:docs/purposes_yaml_files.md See the purposes yaml configuration.} | ||
# Purposes with input_plate set to true use the PlatePurpose::Input class in sequencescape. | ||
# These plates show the following states: | ||
# Pending: No submission made, or some wells with samples have no submissions | ||
# Passed: Submissions made, and the plate is ready to proceed | ||
# Cancelled/Failed: Seen when all requests out of the plate have these states. | ||
# | ||
# Other states: Typically not seen in standard scenarios. | ||
module PermissiveSubmission | ||
extend ActiveSupport::Concern | ||
included do | ||
include Shared | ||
|
||
# The state machine for plates which has knock-on effects on the plates that can be created | ||
state_machine :state, initial: :pending do | ||
StateTransitions.inject(self) | ||
|
||
# These are the states, which are really the only things we need ... | ||
state :pending do | ||
include StateAllowsChildCreation | ||
include DoesNotAllowLibraryPassing | ||
def sidebar_partial | ||
'default' | ||
end | ||
end | ||
|
||
state :started do | ||
include StateAllowsChildCreation | ||
include DoesNotAllowLibraryPassing | ||
end | ||
|
||
state :processed_1 do | ||
include StateAllowsChildCreation | ||
include DoesNotAllowLibraryPassing | ||
end | ||
|
||
state :processed_2 do | ||
include StateAllowsChildCreation | ||
include DoesNotAllowLibraryPassing | ||
end | ||
|
||
state :processed_3 do | ||
include StateAllowsChildCreation | ||
include DoesNotAllowLibraryPassing | ||
end | ||
|
||
state :processed_4 do | ||
include StateAllowsChildCreation | ||
include DoesNotAllowLibraryPassing | ||
end | ||
|
||
state :passed do | ||
include StateAllowsChildCreation | ||
include DoesNotAllowLibraryPassing | ||
|
||
def sidebar_partial | ||
'submission_default' | ||
end | ||
end | ||
|
||
state :qc_complete, human_name: 'QC Complete' do | ||
include StateAllowsChildCreation | ||
include DoesNotAllowLibraryPassing | ||
end | ||
|
||
state :cancelled do | ||
include StateDoesNotAllowChildCreation | ||
include DoesNotAllowLibraryPassing | ||
end | ||
|
||
state :failed do | ||
include StateDoesNotAllowChildCreation | ||
include DoesNotAllowLibraryPassing | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
# Include in a presenter to add support for creating a submission | ||
module Presenters::SubmissionBehaviour | ||
def each_submission_option | ||
purpose_config.submission_options.each do |button_text, options| | ||
submission_options = options.to_hash | ||
submission_options[:asset_groups] = asset_groups | ||
submission_options[:labware_barcode] = labware.labware_barcode.human | ||
yield button_text, SequencescapeSubmission.new(submission_options) | ||
end | ||
end | ||
|
||
def submissions | ||
labware.direct_submissions | ||
end | ||
|
||
def pending_submissions? | ||
submissions.any? { |submission| submission.building_in_progress?(ready_buffer: 20.seconds) } | ||
end | ||
|
||
# Determine whether the Choose Workflow buttons should be displayed | ||
def allow_new_submission? | ||
# No more than one submission of a type can be active at time for a given labware. | ||
# Prevent new submissions if any are currently in progress, as the submission type | ||
# is currently not available. | ||
submissions_in_progress = pending_submissions? || active_submissions? | ||
submissions_in_progress == false | ||
end | ||
|
||
private | ||
|
||
def asset_groups | ||
@asset_groups ||= | ||
labware | ||
.wells | ||
.compact_blank | ||
.group_by(&:order_group) | ||
.map { |_, wells| { assets: wells.map(&:uuid), autodetect_studies: true, autodetect_projects: true } } | ||
end | ||
|
||
def active_submissions? | ||
submissions.any?(&:ready?) | ||
end | ||
end |
43 changes: 43 additions & 0 deletions
43
app/models/presenters/permissive_submission_plate_presenter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
module Presenters | ||
# | ||
# The PermissiveSubmissionPlatePresenter is used when a pipeline needs to | ||
# branch, but also needs to allow plates to be created in advance. Currently | ||
# this is only used for the EMSeq pipeline's split to the WGS branch (and it | ||
# is hoped that other use cases will be avoided in future). It presents the | ||
# user with a selection of workflows, and allows them to generate | ||
# corresponding Sequencescape submissions. Once these submissions are passed, | ||
# the plate behaves like a standard stock plate. Otherwise it includes aspects | ||
# of the PermissivePresenter and allows plates to be created even when the | ||
# plate is pending. | ||
# | ||
# Submission options are defined by the submission_options config in the | ||
# purposes/*.yml file. Structure is: | ||
# <button text>: | ||
# template_name: <submission template name> | ||
# request_options: | ||
# <request_option_key>: <request_option_value> | ||
# ... | ||
class PermissiveSubmissionPlatePresenter < PlatePresenter | ||
include Presenters::Statemachine::PermissiveSubmission | ||
include Presenters::SubmissionBehaviour | ||
|
||
validates_with Validators::SuboptimalValidator | ||
validates_with Validators::ActiveRequestValidator | ||
|
||
self.allow_well_failure_in_states = [] | ||
|
||
# Stock style class causes well state to inherit from plate state. | ||
self.style_class = 'stock' | ||
|
||
self.summary_items = { | ||
'Barcode' => :barcode, | ||
'Number of wells' => :number_of_wells, | ||
'Plate type' => :purpose_name, | ||
'Current plate state' => :state, | ||
'Input plate barcode' => :input_barcode, | ||
'Created on' => :created_on | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<%= sidebar do %> | ||
<%= render 'logged_out_warning' %> | ||
<%= render "plates/sidebars/#{@presenter.sidebar_partial}", presenter: @presenter %> | ||
<% end %> |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
'submission_default'
shows the newly combined sidebar