-
Notifications
You must be signed in to change notification settings - Fork 37
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
Ensemble.files refactor #746
base: smartsim-refactor
Are you sure you want to change the base?
Ensemble.files refactor #746
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## smartsim-refactor #746 +/- ##
=====================================================
+ Coverage 40.45% 47.79% +7.33%
=====================================================
Files 110 109 -1
Lines 7326 6576 -750
=====================================================
+ Hits 2964 3143 +179
+ Misses 4362 3433 -929
|
Question for @juliaputko ! In application.py you placed the TODO about 2 months ago in the remove dead attrs in application PR, is this safe to remove now?
|
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.
lookin great! You can also add a '''match="error message"''' to pytest to make sure you are failing on the right valueerror/type error that you are expecting. Up to you!
:param tag: Tag to use for find and replacement | ||
""" | ||
self.operations.append( | ||
EnsembleConfigureOperation(src, file_parameters, dest, tag) |
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 we change the order of these so that it matches the configure method?
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.
also I dont know if file_parameters is the best name for what is going in? This is a mapping of the items that need to be found and replaced right?
@@ -424,8 +431,8 @@ def build_jobs(self, settings: LaunchSettings) -> tuple[Job, ...]: | |||
:raises TypeError: if the ids argument is not type LaunchSettings | |||
:raises ValueError: if the LaunchSettings provided are empty | |||
""" | |||
if not isinstance(settings, LaunchSettings): | |||
raise TypeError("ids argument was not of type LaunchSettings") | |||
# if not isinstance(settings, LaunchSettings): |
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.
remove commented lines?
|
||
pytestmark = pytest.mark.group_a | ||
|
||
# TODO missing test for _filter |
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.
address todo?
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.
Looks good. As an outsider to the core refactor, I went through and focused on the docstrings and how clear they were to me. Added some suggestions that may/may not be included based on your opinions.
|
||
|
||
class EnsembleCopyOperation(EnsembleGenerationProtocol): | ||
"""Ensemble Copy Operation""" |
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.
Consider describing the functionality.
"""
A file generation operation used to specify parameters
for copying a file into a location accessible to the Ensemble.
"""
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.
better description than my three words eep! will change
""" | ||
check_src_and_dest_path(src, dest) | ||
self.src = src | ||
"""Path to source""" |
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.
Consider being explicit Path to the file that will be copied
def __init__( | ||
self, src: pathlib.Path, dest: t.Optional[pathlib.Path] = None | ||
) -> None: | ||
"""Initialize a EnsembleCopyOperation object |
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 is the result if the destination path is not supplied. Should this behavior be specified in this docstring?
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.
yes I will specify
"""Initialize a EnsembleSymlinkOperation object | ||
|
||
:param src: Path to source | ||
:param dest: Path to destination |
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 is the result if the destination path is not supplied. Should this behavior be specified in this docstring?
""" | ||
check_src_and_dest_path(src, dest) | ||
self.src = src | ||
"""Path to source""" |
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.
Consider being explicit: Path to the file that will be symlink'ed
class Ensemble(entity.CompoundEntity): | ||
"""An Ensemble is a builder class that parameterizes the creation of multiple | ||
"""An Ensemble is a builder class to parameterize the creation of multiple |
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.
omit "an ensemble..."
"""An Ensemble is a builder class to parameterize the creation of multiple | |
"""A builder class used to create parameterized versions of an Application. |
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.
if we say "i don't know what a builder class is" after reading the description, do we need more information?
file: EnsembleConfigureOperation, | ||
permutation_strategy: strategies.PermutationStrategyType, | ||
) -> list[FileSet]: | ||
"""Generate all possible permutations of file parameters using the provided strategy, |
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.
"""Generate all possible permutations of file parameters using the provided strategy, | |
"""Generate the permutations of file parameters using the provided strategy, |
no need to say all possible
since that is implied in using the provided strategy
- i wouldn't expect you to generate only some of the possibilities or you'd give me a new strategy that does that...
"""Generate all possible permutations of file parameters using the provided strategy, | ||
and create FileSet objects. | ||
|
||
This method applies the provided permutation strategy to the file's parameters, |
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.
avoid repeating the same thing as the first sentence of the docstring.
File and execution argument parameters are distributed using the supplied strategy. When a permutation limit is specified, the .... fill in unknown behavior here ... <maybe>permutations returned are randomly sampled from the complete set of permutations</maybe>
def _attach_files( | ||
self, app: Application, file_set_tuple: tuple[FileSet, ...] | ||
) -> None: | ||
"""Attach files to an Application. |
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.
nitpick: again, we're attaching the operations, not the files themselves
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.
all nitpicks welcome always!
if not isinstance(settings, LaunchSettings): | ||
raise TypeError("ids argument was not of type LaunchSettings") | ||
# if not isinstance(settings, LaunchSettings): | ||
# raise TypeError("ids argument was not of type LaunchSettings") | ||
apps = self._create_applications() | ||
if not apps: | ||
raise ValueError("There are no members as part of this ensemble") |
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.
Consider "The ensemble has no members."
Attaching files to an Application and Ensemble has been refactored.
There is now two operations files, an operations.py file that holds the tools to attach files to an Application and an ensemble_operations.py file that holds the tools to attach files to an Ensemble. These two operation files are covered in individual test files: test_operations.py and test_ensemble_operations.py.
Additionally, building the file operation commands in the Generator has been refactored to support the removal of EntityFiles and replacement of the operations.FileSysOpSet. Tests for generator.py have been updated in test_generator.py.
Additionally, the function Ensemble._create_applications has been reworked to support the new Ensemble.files type.
Files to investigate:
smartsim/generation/operations/ensemble_operations.py
smartsim/generation/operations/operations.py
smartsim/generation/operations/utils/helpers.py
smartsim/builders/ensemble.py
smartsim/entity/application.py