-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test-data-generation): generate deck configuration protocols (#1…
…5111) # Overview Generate Python protocols from Hypothesis-generated Deck Configurations. Closes [RQA-2617](https://opentrons.atlassian.net/browse/RQA-2617 ) # Test Plan - [x] Run analysis on a few of the generated Python protocols and ensure they are valid Python # Changelog - Create `ast_helpers.py` which is an abstraction layer that handles creating [Python ast nodes](https://docs.python.org/3.10/library/ast.html#node-classes). - Create `generation_phases` dir. Logic inside the directory, utilizes `ast_helpers.py` to map the test data logic to ast nodes - Create `setup_phase.py` which defines the boilerplate code that every protocol needs: importing the opentrons, package, creating requirements dictionary, creating run function - Create `load_phase.py` which evaluated the Deck Configuration and generates the `load_*` calls to load in labware, modules, and fixtures to the protocol - Create `call_phase.py` which makes calls to loaded entities to ensure analysis recognizes them as being on the deck - Create `python_protocol_generator.py` which calls `generate_ast` on all of the `ast_helpers` and wires up the created nodes. Also handles calling into the `astor` package to generate the python code - Added different Makefile targets to run generated tests in a more verbose mode # Review requests Is there a better way, than the `phase` logic, to handle figuring out what python statements to generate? # Risk assessment Low [RQA-2617]: https://opentrons.atlassian.net/browse/RQA-2617?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
1 parent
0db2732
commit 8f9a8cc
Showing
16 changed files
with
914 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ion/src/test_data_generation/deck_configuration/strategy/deck_configuration_strategies.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"""Test data generation for deck configuration tests.""" | ||
import typing | ||
from hypothesis import assume, strategies as st | ||
from test_data_generation.deck_configuration.datashapes import ( | ||
DeckConfiguration, | ||
PossibleSlotContents as PSC, | ||
) | ||
|
||
from test_data_generation.deck_configuration.strategy.helper_strategies import ( | ||
a_deck_by_columns, | ||
) | ||
|
||
DeckConfigurationStrategy = typing.Callable[..., st.SearchStrategy[DeckConfiguration]] | ||
|
||
|
||
@st.composite | ||
def a_deck_configuration_with_invalid_fixture_in_col_2( | ||
draw: st.DrawFn, | ||
) -> DeckConfiguration: | ||
"""Generate a deck with an invalid fixture in column 2.""" | ||
POSSIBLE_FIXTURES = [ | ||
PSC.LABWARE_SLOT, | ||
PSC.TEMPERATURE_MODULE, | ||
PSC.HEATER_SHAKER_MODULE, | ||
PSC.TRASH_BIN, | ||
PSC.MAGNETIC_BLOCK_MODULE, | ||
] | ||
INVALID_FIXTURES = [ | ||
PSC.HEATER_SHAKER_MODULE, | ||
PSC.TRASH_BIN, | ||
PSC.TEMPERATURE_MODULE, | ||
] | ||
|
||
deck = draw(a_deck_by_columns(col_2_contents=POSSIBLE_FIXTURES)) | ||
|
||
num_invalid_fixtures = len( | ||
[ | ||
True | ||
for slot in deck.column_by_number("2").slots | ||
if slot.contents.is_one_of(INVALID_FIXTURES) | ||
] | ||
) | ||
assume(num_invalid_fixtures > 0) | ||
|
||
return deck | ||
|
||
|
||
DECK_CONFIGURATION_STRATEGIES: typing.Dict[str, DeckConfigurationStrategy] = { | ||
f.__name__: f | ||
for f in [ | ||
a_deck_configuration_with_invalid_fixture_in_col_2, | ||
] | ||
} |
81 changes: 0 additions & 81 deletions
81
...-data-generation/src/test_data_generation/deck_configuration/strategy/final_strategies.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.