-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add Barcodes to Existing Kits #590
base: master
Are you sure you want to change the base?
Conversation
…e-api into creates_barcodes_for_existing_kits
Create Working Branch
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'm following up by email
|
||
with Transaction() as t: | ||
admin_repo = AdminRepo(t) | ||
|
||
# First, do some basic sanitation | ||
errors = [] | ||
for barcode_list in barcodes: |
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's the expected len
of barcodes
, is it == len(number_of_kits)
? That's what I would expect, where the interpretation would be "use these samples for kit 0, use these samples for kit 1, etc", but it looks like the elements of barcodes
are == len(number_of_kits)
? Or should that be len(number_of_samples)
?
for barcode in barcode_list: | ||
diag = admin_repo.retrieve_diagnostics_by_barcode(barcode) | ||
if diag is not None: | ||
errors.append(f'Barcode {barcode} already exists') |
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 believe the test for existence, followed by creation, needs to occur within a lock, right?
|
||
# And verify that the barcodes don't already exist | ||
for barcode in barcode_list: | ||
diag = admin_repo.retrieve_diagnostics_by_barcode(barcode) |
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 a heavy weight request given how the result is used. I wonder whether admin_repo.exists_{barcode,kit,project}
would be valuable additions? If that is deferred, the cost of this request can be reduce by passing grab_kit=False
|
||
# First, make sure all of the Kit IDs are valid | ||
for kit_id in kit_ids: | ||
diag = kit_repo.get_kit_all_samples(kit_id) |
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.
Same comment here re: testing for existence
errors.append(f'Barcode {barcode} already exists') | ||
|
||
# And verify that the number of barcodes and kit IDs are equal | ||
if len(barcodes) != len(kit_ids): |
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 test should be performed before the checks against the database under the fail fast principle
# And verify that the number of barcodes and kit IDs are equal | ||
if len(barcodes) != len(kit_ids): | ||
errors.append("Unequal number of Kit IDs and Barcodes") | ||
|
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.
Can a test for generate_barcodes is True and len(barcodes) > 0
be included? That would be erroneous, right?
message=error_str | ||
), 422 | ||
|
||
diag = admin_repo.add_barcodes_to_kits(kit_ids, barcodes) |
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 think this should be in a try/except given that create_kits
is above
1, | ||
3, | ||
'foo', | ||
[sample_1_barcodes, sample_2_barcodes, sample_3_barcodes], |
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'm puzzled by this, and not sure this works as intended. What's provided are not the barcode IDs, but UUIDs? I was expecting the interface to consume barcodes as we print on the tubes?
|
||
kit = tmi['created'][0] | ||
# Assert that the provided barcodes are present | ||
self.assertEqual(kit['sample_barcodes'][0], sample_1_barcodes[0]) |
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.
These aren't barcodes though
This PR addresses two related needs:
The corresponding microsetta-admin PR is biocore/microsetta-admin#110