-
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-190 Milestone 1: API v1 -> v2 Migration #1884
Conversation
Only just found out about it and it looks like it hasn't been done by anyone in recent times.
It's used by sub-classes so they need to be fixed first
…mium-pipelines Y24-190-2: Use SS API v2 for barcode printers
Y24-190-3: Use v2 transfers and transfer templates
Y24-190-3: Use API v2 StateChange resource
|
||
# This returns an array of well location to pool pairs. The 'walker' is responsible for actually doing the walking | ||
# of the wells that are acceptable, and it calls back with the location of the well being processed. | ||
def group_wells(plate) |
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.
Identical blocks of code found in 2 locations. Consider refactoring.
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.
This is because we are supporting v1 as well until this work is complete.
|
||
# Performs the coercion of this instance so that it behaves appropriately given the direction | ||
# and walking algorithm information. | ||
def coerce |
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.
Identical blocks of code found in 2 locations. Consider refactoring.
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.
This is because we are supporting v1 as well until this work is complete.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1884 +/- ##
===========================================
+ Coverage 77.46% 77.96% +0.50%
===========================================
Files 455 459 +4
Lines 17275 17688 +413
Branches 229 229
===========================================
+ Hits 13382 13791 +409
- Misses 3891 3895 +4
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Looks good, no red flags, and appreciate the comments 👍
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.
Again minor comments :) can all be ignored. It hasn't been my more thorough code review but a scan over everything looks good and a big step forward. Thanks
end | ||
end | ||
``` | ||
|
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.
Clear 👍
end | ||
end | ||
|
||
def tubes_from_transfer | ||
@transfer | ||
create_transfer! |
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.
Just curious, how come you call the method here instead of using @create_transfer
which I think should already exist and is not nil?
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.
@create_transfer
is the memoized backing store for the method. When you implement getters, you should use them at all times if possible. Not doing so can cause hard to debug issues where the getter is supposed to be managing access to the backing store. The only reason the other mention in this file is not using the method is that you cannot check for a nil
value if it is always populated by the getter method.
I don't think we really need to check for a nil
value, but I didn't want to get too deep into the weeds and cause a bug myself. The first time you try to get the transfer via the method, it would be called anyway, so why would you need to check if it's been called? I'm not sure.
# TODO: {Y24-190} Work out a way to call the `create!` method on TagLayoutTemplate model in Sequencescape | ||
# using the V2 API. I think either we need to misuse the PATCH method with some kind of | ||
# attributes telling Sequencescape to run the `create!` method, or we need to create a new | ||
# endpoint associated with a TagLayoutTemplate that will run the `create!` method. | ||
api |
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.
Could you add a comment just to make it super clear that api
here is still currently using the SS V1 API
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.
api
is always SS V1 throughout Limber. We never access the V2 api via a variable called api
.
@@ -80,6 +80,10 @@ | |||
outer_requests: quad_a_requests | |||
) | |||
end | |||
let(:child_plate_a_create_args) do | |||
{ user_id: user.id, asset_id: child_plate_a.id, metadata: { stock_barcode: "* #{child_plate_a.barcode.machine}" } } |
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.
Whats the *
for?
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.
No idea. It gets appended in the code so I have to append it in the test as well.
@@ -304,7 +305,8 @@ | |||
'custom_metadatum_collection-uuid', | |||
body: json(:v1_custom_metadatum_collection, uuid: 'custom_metadatum_collection-uuid') | |||
) | |||
stub_api_get('user-uuid', body: user) | |||
stub_api_get('user-uuid', body: v1_user) |
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.
Do you know if there is a reason the V1 User endpoint still needs to be used in this Class?
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.
Not really, no. Removing the line does make the test fail though because the endpoint does get queried:
WebMock::NetConnectNotAllowedError:
Real HTTP connections are disabled. Unregistered request: GET http://example.com:3000/user-uuid
# ./app/models/labware_metadata.rb:21:in `update!'
# ./app/models/labware_creators/quadrant_stamp_base.rb:39:in `block in create_labware!'
# ./app/models/labware_creators/multi_stamp.rb:40:in `create_labware!'
# ./app/models/labware_creators/quadrant_stamp_base.rb:38:in `create_labware!'
# ./app/models/labware_creators/base.rb:56:in `save'
# ./app/models/labware_creators/base.rb:52:in `save!'
# ./spec/models/labware_creators/quadrant_stamp_primer_panel_spec.rb:328:in `block (4 levels) in <top (required)>'
# 'Sequencescape::Api::V2::' and returns the given value or else true. | ||
receiving_class = "Sequencescape::Api::V2::#{klass}".constantize | ||
return_value ||= true | ||
allow(receiving_class).to receive(:create!).and_return(return_value) |
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.
Does it need to intercept any create
(or save
above) without the bang too?
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.
I did intercept create
without the!
and it never gets called in our code so I stopped doing it. I suspect I'll find some case soon that needs it, but I didn't see the point in stubbing something we're not calling. I will be easy to add if it's needed at the time. I have this file open as a permanent fixture during the Limber migration.
@@ -4,61 +4,38 @@ | |||
require './app/controllers/robots_controller' | |||
|
|||
RSpec.describe RobotsController, type: :controller, robots: true do | |||
has_a_working_api |
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.
Is this referring to the V1
api? Is it worth adding a comment saying this can be removed once the update to V2 api is complete (if that is the plan?)
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.
Yeah it does some very dodgy stuff to make V1 APIs be stubbed all over the place. Removal is the plan. This is literally everywhere in the unit tests. It's part of my overall plan to clean up all traces of V1, but there's not much point in adding comments as I'm aware and will just be removing the comments 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.
(I've also experimented with removing them when I think the API is no longer needed in some tests and it always highlights how much more v1 is still to be removed because the tests fail)
I applaud your determination to get through these pull requests! 122 changes files and a diff of over 4,000 lines is enough to put most off. Much appreciated. |
# Conflicts: # app/frontend/javascript/shared/resources.js # app/sequencescape/sequencescape/api/v2/tube.rb
"options": { | ||
} | ||
}, | ||
{ |
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.
Similar blocks of code found in 12 locations. Consider refactoring.
"options": { | ||
} | ||
}, | ||
{ |
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.
Similar blocks of code found in 3 locations. Consider refactoring.
"options": { | ||
} | ||
}, | ||
{ |
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.
Similar blocks of code found in 2 locations. Consider refactoring.
"options": { | ||
} | ||
}, | ||
{ |
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.
Similar blocks of code found in 2 locations. Consider refactoring.
# Conflicts: # spec/models/labware_creators/plate_split_to_tube_racks_spec.rb
Code Climate has analyzed commit c841bbb and detected 22 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 93.2% (50% is the threshold). This pull request will bring the total coverage in the repository to 91.1% (0.0% change). View more on Code Climate. |
Milestone 1 for #1772
Changes proposed in this pull request
Note that these changes were tested by the Integration Suite after deployment to UAT: https://gitlab.internal.sanger.ac.uk/psd/integration-suite/-/pipelines/300247/builds
Instructions for Reviewers
[All PRs] - Confirm PR template filled
[Feature Branches] - Review code