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

Y24-396: Refactor Automatic State Changers #2044

Merged

Conversation

StephenHulme
Copy link
Contributor

@StephenHulme StephenHulme commented Nov 1, 2024

Closes #2002

Changes proposed in this pull request

  • Refactor labware state changers to be specialised by labware and use mixins for alternative behaviour
    • Solves bug where a tube thinks it's a plate and calls the contents_for method of DefaultStateChanger which was originally designed for plates and not tubes
  • Refactor and add state changer unit tests

Instructions 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

@StephenHulme
Copy link
Contributor Author

Will likely conflict with #2034, probably best to let that be merged in first, then refactor as required.

Copy link
Member

@andrewsparkes andrewsparkes left a comment

Choose a reason for hiding this comment

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

Think this needs discussion re: tube aggregation
Plus I'm also touching this file in the tuberacks story Y24-099 to add a tube rack state changer.


api.work_completion.create!(submissions: in_prog_submissions, target: v2_labware.uuid, user: user_uuid)
def labware
raise 'Tubes are not supported by API V1'
Copy link
Member

Choose a reason for hiding this comment

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

That can't be true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not a path that appears to be used in the current iteration - I'm hoping it will be removed with @sdjmchattie's v1 API removal changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 7ca499d

spec/models/state_changers_spec.rb Outdated Show resolved Hide resolved
@StephenHulme StephenHulme changed the base branch from develop to y24-088-tuberacks-epic November 29, 2024 14:30
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 88.09524% with 5 lines in your changes missing coverage. Please review.

Project coverage is 80.97%. Comparing base (db9b440) to head (8bd6061).
Report is 184 commits behind head on y24-088-tuberacks-epic.

Files with missing lines Patch % Lines
app/models/state_changers.rb 87.80% 5 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                     @@
##           y24-088-tuberacks-epic    #2044      +/-   ##
==========================================================
+ Coverage                   80.78%   80.97%   +0.19%     
==========================================================
  Files                         482      483       +1     
  Lines                       18295    18499     +204     
  Branches                      269      269              
==========================================================
+ Hits                        14780    14980     +200     
- Misses                       3513     3517       +4     
  Partials                        2        2              
Flag Coverage Δ
javascript 74.23% <ø> (ø)
pull_request 80.82% <88.09%> (+0.03%) ⬆️
push 80.68% <88.09%> (+<0.01%) ⬆️
ruby 91.30% <88.09%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@andrewsparkes andrewsparkes left a comment

Choose a reason for hiding this comment

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

Looks really good, I just don't like the tube aggregation references

@StephenHulme
Copy link
Contributor Author

Further refactoring required after #2099 is merged in

@StephenHulme
Copy link
Contributor Author

This is ready for review again.

Copy link
Member

@andrewsparkes andrewsparkes left a comment

Choose a reason for hiding this comment

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

Minor questions.
Otherwise a big improvement, thanks.

app/models/state_changers.rb Show resolved Hide resolved
spec/models/state_changers_spec.rb Outdated Show resolved Hide resolved

# if all the tubes are already in the target state expect contents to be empty
# TODO: I'm not sure this is correct behaviour, it should probably raise an error
# or a validation should catch that the state change is not needed
Copy link
Member

Choose a reason for hiding this comment

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

I've seen this before in code on the sequencescape side. It gets an api call for a state change but then has code that works out nothing needs doing. Waste of an api call.
Not sure how that even gets triggered though. If there's a button that triggers a state change that isn't needed, then the button should not be visible (i.e. validation like you said).
Maybe someone decided it was too expensive to pull all the information into Limber and instead let SS decide?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this was an existing comment in the code, it was just indented as part of the refactoring

@@ -271,14 +271,20 @@ def stub_v2_tag_layout_templates(templates)
end

# Builds the basic v2 tube finding query.
def stub_v2_tube(tube, stub_search: true, custom_query: nil, custom_includes: nil)
def stub_v2_tube(tube, stub_search: true, custom_query: nil, custom_includes: false) # rubocop:todo Metrics/AbcSize
Copy link
Member

Choose a reason for hiding this comment

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

I tend to use rubocop:disable / enable over todo if I am happy with the code and have no intention of coming back to it(!)

@StephenHulme StephenHulme merged commit de4adc5 into y24-088-tuberacks-epic Jan 22, 2025
16 checks passed
@StephenHulme StephenHulme deleted the y24-396-refactor-state-changes-using-mixins branch January 22, 2025 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Y24-396 - [BUG] Cancelling a PBMC tube
2 participants