-
Notifications
You must be signed in to change notification settings - Fork 33
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-061: Send Pool XP export message #4147
Conversation
|
||
def create | ||
Rails.logger.debug "DEBUG: In ExportPoolXpToTractionController create" | ||
# TODO: do we need to check the tube barcode is valid here? |
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.
TODO found
Rails.logger.debug "DEBUG: In ExportPoolXpToTractionController create" | ||
# TODO: do we need to check the tube barcode is valid here? | ||
Delayed::Job.enqueue ExportPoolXpToTractionJob.new(barcode) | ||
# TODO: check if job queuing was successful or not and return appropriate status |
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.
TODO found
# TODO: do we need to check the tube barcode is valid here? | ||
Delayed::Job.enqueue ExportPoolXpToTractionJob.new(barcode) | ||
# TODO: check if job queuing was successful or not and return appropriate status | ||
# TODO: how to know if job successfully queued? |
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.
TODO found
Delayed::Job.enqueue ExportPoolXpToTractionJob.new(barcode) | ||
# TODO: check if job queuing was successful or not and return appropriate status | ||
# TODO: how to know if job successfully queued? | ||
# TODO: does rendering something here send something back to Limber? |
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.
TODO found
|
||
def connection_params | ||
connection_params = { | ||
host: configatron.amqp.isg.host, |
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.
ExportPoolXpToTractionJob#connection_params calls 'configatron.amqp' 5 times
boxBarcode: "Unspecified" | ||
}, | ||
request: { | ||
costCode: project.project_cost_code, |
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 it worth doing project&.project_cost_code
... not sure if tube.projects
is able to return nil. If so actually, would need to do tube.projects&.first
as well 🤔
Similar question with tube.studies.first
and study.uuid
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.
Hmm this is a tricky one. costCode is a required field and so is the study UUID. So if they were nil
there's not a lot I could do to send the message and it might be better for that to bubble up to create an error log, rather than hide it in safe-chaining.
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.
OK gotcha. You could throw an explicit exception for it rather than let the nil pointer happen? So you could say something useful like 'expected data is not present - costcode'.
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.
Yes fair. If we leave it as is, the exception will say something about not being able to get attribute project_cost_code on nil object. If I do the safe-chaining as you suggest and it gets to the point where it's going to encode the message using Avro, you'll get a useful message back from fastavro
about the field in the message not being allowed to be null.
Co-authored-by: KatyTaylor <kt17@sanger.ac.uk>
Co-authored-by: KatyTaylor <kt17@sanger.ac.uk>
config/config.rb
Outdated
configatron.amqp.isg.password = 'development' | ||
configatron.amqp.isg.exchange = 'sequencescape' | ||
|
||
configatron.amqp.schemas.registry_url = 'http://redpanda.uat.psd.sanger.ac.uk/subjects/' |
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 we want local config to be dependent on the UAT instance? Maybe it's not dependent...
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 had considered this when I made this choice and I don't know that there are any simple and easy answers. If I make it dependent on a local instance of RedPanda, that adds dependencies to Sequencescape when we already have so many. Although thinking about it again, you would only be able to run a local instance while on the VPN when you rely on UAT's RedPanda. Thoughts?
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.
If you don't have a connection to UAT's RedPanda, what will happen? If it breaks Sequencescape completely, I think that's not OK. If it just means this particular feature doesn't work, that's not too bad.
Similarly, I don't want a local RedPanda instance to be a requirement for developing SS locally... but if it was required for just this feature, wouldn't be too bad.
Would either of these work?
- Skip the check against the schema if one is not available? (in local only)
- Have a dummy schema in a file in the codebase that it uses in local only
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 added a cache to the system, which it probably should have had to start with. This means that you would need to connect to the UAT RedPanda the first time you trigger one of these jobs, but then you'd have a cached file of the schema to use in future calls. Of course, if you know the schema, you can also just dump it in the appropriately named cache file. I added some info to the README about this.
|
||
def preflight_errors(barcode) | ||
# Check that the tube exists | ||
tube = Tube.with_barcode(barcode).first |
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 important, but again could change to the following
tube = Tube.with_barcode(barcode).first | |
tube = Tube.find_by_barcode(barcode) |
@@ -1,7 +1,6 @@ | |||
# frozen_string_literal: true | |||
|
|||
require 'spec_helper' | |||
require 'rails_helper' |
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.
What happened with these deleted 'rails_helper' lines?
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 read that you only need spec_helper
during specs. rails_helper
is implicitly part of that require
. Correct me if you know otherwise.
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.
Finished reviewing! Only thing that needs working out I think is the schema dependency bit. Everything else was small.
before_action :login_required, except: [:create] | ||
skip_before_action :verify_authenticity_token | ||
|
||
def create |
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::V2::Bioscan::ExportPoolXpToTractionController#create has approx 6 statements
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.
Addition of caching looks good I think!
Just pointed out a typo 😆
data/avro_schema_cache/.gitignore
Outdated
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 didn't know you could have .gitignore files in subdirectories 🤯
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.
Ah yeah, you can have them anywhere and they only apply to the files at the same level as them or lower.
Co-authored-by: KatyTaylor <kt17@sanger.ac.uk>
Code Climate has analyzed commit 2a714b4 and detected 19 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 97.2% (50% is the threshold). This pull request will bring the total coverage in the repository to 86.7% (0.1% change). View more on Code Climate. |
Closes #4085
Changes proposed in this pull request
Instructions for Reviewers
[All PRs] - Confirm PR template filled
[Feature Branches] - Review code