Feature: Separate pyplate.py into Multiple Files #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Due to the length of the main implementation file, pyplate.py, it seemed well worth it to distribute the various classes across separate files. Most classes were given their own files, but some (e.g. Recipe/RecipeStep and Plate/PlateSlicer) were kept in the same file if they were closely coupled.
To achieve this separation, some circular references across classes needed to be handled. The instances of this were:
Unit and Container -> Resolved by removing the ability to pass a
Container
instance as an input toUnit.convert_from_storage_to_standard_format()
Container and Plate/PlateSlicer -> Resolved by using
if typing.TYPE_CHECKING
and importing the modules at runtime only in the functions where they are used (e.g.Container.transfer()
andContainer._transfer_slice()
).Moreover, for many of the unit test files and example files, the import statements were changed to reference the overall pyplate module rather than the specific file, pyplate.pyplate.