Lock Sapio Study in SS#5870
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #5870 +/- ##
===========================================
- Coverage 84.84% 84.83% -0.02%
===========================================
Files 1494 1494
Lines 33954 34004 +50
Branches 3615 3630 +15
===========================================
+ Hits 28809 28847 +38
- Misses 4297 4302 +5
- Partials 848 855 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I have a few general thoughts and suggestions, rather than comments about individual lines of code:
I hope that all makes sense, please let me know if you have any questions or would like to chat on Zoom. |
good points!
May ask the team for suggestions.
This worths discussions. The Acceptance criteria state: There are multiple entries to do the above actions. Implementing restrictions on controller/UI level may not be sufficient. It is easy to miss some of them. Future development may add new controllers to update study without realise the need of adding the restrictions. The consequence of that could cause the studies in Sapio and SS are not consistent. I think Implementing validation on model level provide a single point of enforcement and reduces the risk of missing an update path. Any harm of doing model level validations? One thing I can think of is the validations may only apply for certain fields, not block all fields for update.
|
There was a problem hiding this comment.
I have added some comments but avoided repeating the same comment everywhere.
- About "SequenceScape will not send or create Study data to the MLWH database for Sapio studies.": broadcast_with_warren macro will send the study to MLWH independent of how it is updated. Something like this might cover after_commit case: Register a handler instead of using the default:
broadcast_with_warren(handler: SapioAwareStudyHandler.new)
its def <<(message) method then either ignores the message or routes it to Warren.handler << message
where message.record would be a Study.
-
Also to cover after_touch case, override the rebroadcast method of Study.
-
I can't see how the story criteria item "not accession Sapio Study data to the EBI." is prevented by this PR.
| def validate_api_key(api_key) | ||
| ApiApplication.find_by!(key: api_key) | ||
| api_application = ApiApplication.find_by!(key: api_key) | ||
| Current.api_application = api_application |
There was a problem hiding this comment.
praise: this is very useful for the request scope.
note: We might have add an ApiApplication.integration_hub? to avoid checking against strings everywhere: Current.api_application.integration_hub?
StephenHulme
left a comment
There was a problem hiding this comment.
Lots of work's gone into this and it's looking good overall : )
I've added some suggestions around functions and accessioning.
| # so that it can be accessed in models and other places where the controller context is not available. | ||
|
|
||
| class Current < ActiveSupport::CurrentAttributes | ||
| attribute :api_application |
There was a problem hiding this comment.
I would very much like to remove the reliance on CurrentAttributes if at all possible. This is because it blurs the line between controller and model making maintenance much harder in the future.
|
|
||
| # This validation prevents any updates to a study that is managed in SAPIO | ||
| # unless the request is coming from Integration Hub | ||
| def prevent_updates_when_mastered_in_sapio |
There was a problem hiding this comment.
Could we change this to allow updates from the api? This solves several naming concerns and also removes the need to check against the request coming from the integration hub itself.
There was a problem hiding this comment.
Will Integration hub be the only user to use SS study API? What about other applications/users trying to call SS API, to update the study? How to prevent those cases if not checking if the request from Integration hub?
There was a problem hiding this comment.
Most likely, I think. Although there is a case to be made for principle of least priviledge, but Sequencescape doesn't currently support authorisation, compared to authentication.
| <% add :menu, "Study QC Reports" => study_reports_study_path(@study) -%> | ||
|
|
||
| <% if permitted_to_accession?(@study) & @study.samples_accessionable? %> | ||
| <% if permitted_to_accession?(@study) & @study.samples_accessionable? && !@study.mastered_in_sapio %> |
There was a problem hiding this comment.
I think the feature-flag check could be added to def samples_accessionable?, simplifying the code here and propagating to the rest of the accessioning functionality?
andrewsparkes
left a comment
There was a problem hiding this comment.
Looks really good!
Suggestion: For UAT ask the SSRs to test it, see if they can find any way to update the study or the samples in it that you might have missed!
| def new | ||
| @study = Study.find_by(id: params[:study_id]) | ||
|
|
||
| if @study&.ui_locked? |
There was a problem hiding this comment.
So to be clear, if the Study is now in Sapio the assumption is all Samples will be entered via Sapio too?
There was a problem hiding this comment.
And edited there, instead of via sample manifest re-uploads in SS?
Closes #
Changes proposed in this pull request
mastered_in_sapioInstructions for Reviewers
[All PRs] - Confirm PR template filled
[Feature Branches] - Review code
[Production Merges to
main]- Check story numbers included
- Check for debug code
- Check version