-
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
Runtime value checking for LaunchSettings and BatchSettings #740
base: v1.0
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## smartsim-refactor #740 +/- ##
=====================================================
- Coverage 40.45% 37.90% -2.56%
=====================================================
Files 110 109 -1
Lines 7326 6583 -743
=====================================================
- Hits 2964 2495 -469
+ Misses 4362 4088 -274
|
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 great so far! Just some initial feedback for you to take a look at while we expand this out into {Batch,Launch}Arguments
classes as well!
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.
Awesome work as always! One larger suggestion is to move the setter testing to the associated launcher and scheduler test files!
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.
Couple of small nits, but otherwise looks about ready to go!!
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.
Some small comments! One larger comment is that the arguments/launch modules haven't been given runtime value checks, consider adding to this PR! Unless this is only the batch PR
@@ -126,6 +126,18 @@ def __init__( | |||
"""The launcher type""" |
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.
In the modules arguments/launch/... there is a spelling error where Overwriting is written as Overwritting - could you fix this in this PR?
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.
cant find this error
@@ -126,6 +126,18 @@ def __init__( | |||
"""The launcher type""" | |||
except ValueError: | |||
raise ValueError(f"Invalid launcher type: {launcher}") | |||
|
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.
I notice that there hasnt been Value Checking added to arguments/launch/ modules, but all Value checking has been added to batch modules, is launch_setting value checking also going into this PR?
def test_batch_arguments_type_set_smts(): | ||
bs = BatchSettings(batch_scheduler="lsf", env_vars={"ENV": "VAR"}) | ||
with pytest.raises(TypeError, match="smts argument was not of type int"): | ||
bs.batch_args.set_smts("invalid") |
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 using pytest.parameterize (I spelt it so wrong) but tests look great!
acd56da
to
d83d7cd
Compare
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.
Similar question to Amanda about whether or not we want to cover smartsim.settings.arguments.*
in this PR as well, and a couple of small nits, but otherwise looks about ready to go on my end!
if key in self._batch_args and key != self._batch_args[key]: | ||
logger.warning(f"Overwriting argument '{key}' with value '{value}'") |
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.
Just sanity checking, should this be
if key in self._batch_args and key != self._batch_args[key]: | |
logger.warning(f"Overwriting argument '{key}' with value '{value}'") | |
if key in self._batch_args and value != self._batch_args[key]: | |
logger.warning(f"Overwriting argument '{key}' with value '{value}'") |
?
if key in self._batch_args and key != self._batch_args[key]: | ||
logger.warning(f"Overwriting argument '{key}' with value '{value}'") |
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.
Ditto here
if key in self._batch_args and key != self._batch_args[key]: | |
logger.warning(f"Overwriting argument '{key}' with value '{value}'") | |
if key in self._batch_args and value != self._batch_args[key]: | |
logger.warning(f"Overwriting argument '{key}' with value '{value}'") |
?
if key in self._batch_args and key != self._batch_args[key]: | ||
logger.warning(f"Overwriting argument '{key}' with value '{value}'") |
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.
One more here
if key in self._batch_args and key != self._batch_args[key]: | |
logger.warning(f"Overwriting argument '{key}' with value '{value}'") | |
if key in self._batch_args and value != self._batch_args[key]: | |
logger.warning(f"Overwriting argument '{key}' with value '{value}'") |
?
@@ -224,5 +224,5 @@ def set(self, key: str, value: str | None) -> None: | |||
) | |||
return | |||
if key in self._launch_args and key != self._launch_args[key]: |
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.
Not technically part of this PR, but I think this should also read
if key in self._launch_args and key != self._launch_args[key]: | |
if key in self._launch_args and value != self._launch_args[key]: |
?
@@ -71,7 +71,7 @@ def set(self, key: str, value: str | None) -> None: | |||
""" | |||
set_check_input(key, value) | |||
if key in self._launch_args and key != self._launch_args[key]: |
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 somehow got past a previous review
if key in self._launch_args and key != self._launch_args[key]: | |
if key in self._launch_args and value != self._launch_args[key]: |
?
@@ -349,5 +351,5 @@ def set(self, key: str, value: str | None) -> None: | |||
) | |||
return | |||
if key in self._launch_args and key != self._launch_args[key]: |
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.
Whoops! I lied!! Last one for real
if key in self._launch_args and key != self._launch_args[key]: | |
if key in self._launch_args and value != self._launch_args[key]: |
@@ -140,6 +152,16 @@ def env_vars(self) -> StringArgument: | |||
@env_vars.setter | |||
def env_vars(self, value: t.Dict[str, str | None]) -> None: | |||
"""Set the environment variables.""" | |||
|
|||
if not ( | |||
isinstance(value, t.Dict) |
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.
Nit: for runtime checks (and static checks with python>=3.9), it is generally preferred to use dict
over t.Dict
isinstance(value, t.Dict) | |
isinstance(value, dict) |
|
||
if launch_args is not None: | ||
if not ( | ||
isinstance(launch_args, t.Dict) |
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.
Ditto pedantic "dict
v t.Dict
" nit
isinstance(launch_args, t.Dict) | |
isinstance(launch_args, dict) |
and all( | ||
isinstance(key, str) and isinstance(val, (str, type(None))) | ||
for key, val in value.items() | ||
) | ||
): | ||
raise TypeError("env_vars argument was not of type dict of str and str") |
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.
Minor nit: runtime check takes a dict[str, str | None]
, but the error message claims to only take a dict[str, str]
and all( | |
isinstance(key, str) and isinstance(val, (str, type(None))) | |
for key, val in value.items() | |
) | |
): | |
raise TypeError("env_vars argument was not of type dict of str and str") | |
and all( | |
isinstance(key, str) and isinstance(val, (str, type(None))) | |
for key, val in value.items() | |
) | |
): | |
raise TypeError("env_vars argument was not of type dict of str and str or None") |
and all( | ||
isinstance(key, str) and isinstance(val, (str, type(None))) | ||
for key, val in value.items() | ||
) | ||
): | ||
raise TypeError("env_vars argument was not of type dict of str and str") |
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.
Ditto dict[str, str | None]
vs dict[str, str]
discrepancy
and all( | |
isinstance(key, str) and isinstance(val, (str, type(None))) | |
for key, val in value.items() | |
) | |
): | |
raise TypeError("env_vars argument was not of type dict of str and str") | |
and all( | |
isinstance(key, str) and isinstance(val, (str, type(None))) | |
for key, val in value.items() | |
) | |
): | |
raise TypeError("env_vars argument was not of type dict of str and str or None") |
No description provided.