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

Add Barcodes to Existing Kits #590

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open

Conversation

cassidysymons
Copy link
Collaborator

@cassidysymons cassidysymons commented Dec 16, 2024

This PR addresses two related needs:

  1. It allows an admin to add barcodes to existing kits, either by providing barcodes or allowing the system to generate novel barcodes.
  2. It enhances the kit creation process by allowing the admin to create kits with a mix of admin-provided barcodes (e.g. matrix tubes with pre-determined barcodes) and system-generated barcodes.

The corresponding microsetta-admin PR is biocore/microsetta-admin#110

Copy link
Member

@wasade wasade left a 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:
Copy link
Member

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)?

Comment on lines +288 to +291
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')
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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):
Copy link
Member

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")

Copy link
Member

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)
Copy link
Member

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],
Copy link
Member

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])
Copy link
Member

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

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.

3 participants