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

DPL-717: Don't filter for fit to pick #753

Merged
merged 14 commits into from
Apr 27, 2023

Conversation

sdjmchattie
Copy link
Contributor

Closes #740

Changes proposed in this pull request:

  • Set whether fit to pick should be filtered for or not per plate type.
  • Create methods that pick all samples for a plate when fit to pick filter is set to false.

@sdjmchattie sdjmchattie self-assigned this Apr 24, 2023
@sdjmchattie sdjmchattie marked this pull request as draft April 24, 2023 15:51
@codecov
Copy link

codecov bot commented Apr 24, 2023

Codecov Report

Merging #753 (1b34aef) into develop (f86230e) will decrease coverage by 0.05%.
The diff coverage is 93.10%.

@@             Coverage Diff             @@
##           develop     #753      +/-   ##
===========================================
- Coverage    92.33%   92.28%   -0.05%     
===========================================
  Files          107      107              
  Lines         3287     3320      +33     
  Branches       261      267       +6     
===========================================
+ Hits          3035     3064      +29     
- Misses         208      210       +2     
- Partials        44       46       +2     
Impacted Files Coverage Δ
lighthouse/helpers/mongo.py 92.45% <73.33%> (-7.55%) ⬇️
...hthouse/classes/messages/sequencescape_messages.py 78.12% <100.00%> (ø)
lighthouse/config/defaults.py 100.00% <100.00%> (ø)
lighthouse/config/test.py 100.00% <100.00%> (ø)
lighthouse/constants/config.py 100.00% <100.00%> (ø)
lighthouse/helpers/plates.py 91.60% <100.00%> (-0.07%) ⬇️
lighthouse/routes/common/plates.py 90.00% <100.00%> (+2.50%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@sdjmchattie sdjmchattie marked this pull request as ready for review April 25, 2023 09:55
body = create_post_body(barcode, plate_type, fit_to_pick_samples)
plate_configs = app.config["SS_PLATE_CONFIG"]
if plate_type not in plate_configs:
return bad_request(f"POST request 'type' must be from the list: {', '.join(plate_configs)}")
Copy link
Contributor

Choose a reason for hiding this comment

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

plate_configs is a dict, not a list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes perhaps I should be more explicit, though in Python, any iteration of a dictionary without specifying a method on it just iterates the keys.

"""
try:
samples_collection: Collection = cast(Eve, app).data.driver.db.samples
query = {FIELD_LH_SOURCE_PLATE_UUID: source_plate_uuid}
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe throw exception if source_plate_uuid is null, because the query {"lh_source_plate_uuid: null} is valid, but we dont want that to happen.

Copy link
Contributor Author

@sdjmchattie sdjmchattie Apr 26, 2023

Choose a reason for hiding this comment

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

It can't happen because the type hinting explicitly specifies that the value is a string that cannot be None but I will add the check because I think this is something that could easily slip up in future. I can't add a test for it because mypy will complain that I'm passing a None value to a method that doesn't accept None.

When I remove the None check before calling this method, mypy fails the checks with the following:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, looks good

with app.app_context():
result = get_all_samples_for_source_plate("source plate uuid does not exist")

assert result == []
Copy link
Contributor

Choose a reason for hiding this comment

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

We can add a test when the argument is None

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've done this and pushed up the change. I think we probably should revert that last commit though. Look at it and tell me what you think. mypy is already protecting from this issue occurring through the typing system.

Note that we are ignoring the type hinting which already prevents a None value being submitted, but this belt and braces.  Because mypy won't normally let you pass None as a value, we have to suppress mypy during testing so that we can force a None value in.
emrojo
emrojo previously approved these changes Apr 27, 2023
@sdjmchattie sdjmchattie merged commit c515e20 into develop Apr 27, 2023
@sdjmchattie sdjmchattie deleted the dpl-717-dont-filter-fit-to-pick branch April 27, 2023 10:40
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.

DPL-717-1: Create a new endpoint for creating entities for Lighthouse deep-well plates in Sequencescape
2 participants