Skip to content

Commit

Permalink
Merge branch 'v1pylintfix' of github.com:juliaputko/SmartSim into pyl…
Browse files Browse the repository at this point in the history
…intssrf
  • Loading branch information
juliaputko committed Oct 31, 2024
2 parents cd7e3c5 + 78396cd commit 94f0608
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 47 deletions.
2 changes: 2 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Description

- Implement workaround for Tensorflow that allows RedisAI to build with GCC-14
- Add instructions for installing SmartSim on PML's Scylla
- Fix typos in documentation

Detailed Notes

Expand All @@ -64,6 +65,7 @@ Detailed Notes
have yet to be installed at a system-wide level. Scylla has
its own entry in the documentation.
([SmartSim-PR733](https://github.com/CrayLabs/SmartSim/pull/733))
- Fix typos in the `train_surrogate` tutorial documentation


### 0.8.0
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorials/ml_training/surrogate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

In this example, a neural network is trained to act like a surrogate model and to solve a
well-known physical problem, i.e. computing the steady state of heat diffusion. The training
dataset is constructed by running simualations *while* the model is being trained.
dataset is constructed by running simulations *while* the model is being trained.

The notebook also displays how the surrogate model prediction improves during training.
The notebook also displays how the surrogate model prediction improves during training.
2 changes: 1 addition & 1 deletion doc/tutorials/ml_training/surrogate/train_surrogate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"\n",
"In this notebook, a neural network is trained to act like a surrogate model and to solve a\n",
"well-known physical problem, i.e. computing the steady state of heat diffusion. The training\n",
"dataset is constructed by running simualations *while* the model is being trained.\n",
"dataset is constructed by running simulations *while* the model is being trained.\n",
"\n",
"## 2D Heat Diffusion and Steady State\n",
"Throughout this notebook, the heat equation will be solved on the two-dimensional domain $[0,1]\\times[0,1]$, setting the initial temperature to 0 K, except\n",
Expand Down
2 changes: 2 additions & 0 deletions smartsim/_core/_install/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class Device(enum.Enum):
CUDA12 = "cuda-12"
ROCM5 = "rocm-5"
ROCM6 = "rocm-6"
# TODO: check to see if this got overwritten/ gpu was removed
GPU = "gpu"

@classmethod
def from_str(cls, str_: str) -> "Device":
Expand Down
4 changes: 2 additions & 2 deletions smartsim/_core/entrypoints/dragon_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def execute_entrypoint(args: DragonClientEntrypointArgs) -> int:

requests.append(DragonShutdownRequest(immediate=False, frontend_shutdown=True))

# TODO: DragonConnector constructor needs a path
connector = DragonConnector()
# TODO: needs path
connector = DragonConnector(".")

for request in requests:
response = connector.send_request(request)
Expand Down
1 change: 1 addition & 0 deletions smartsim/_core/mli/client/protoclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import dragon.channels
from dragon.globalservices.api_setup import connect_to_infrastructure

# TODO: fix import for mpi4py.MPI, add in setup.py --> mpi4py
try:
from mpi4py import MPI # type: ignore[import-not-found]
except Exception:
Expand Down
6 changes: 3 additions & 3 deletions smartsim/_core/mli/infrastructure/control/dragon_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
import typing as t

import pytest
from smartsim.log import get_logger

dragon = pytest.importorskip("dragon")

# isort: off

Expand All @@ -43,6 +40,9 @@

# isort: on

from smartsim.log import get_logger

dragon = pytest.importorskip("dragon")

logger = get_logger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion smartsim/_core/shell/shell_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def __init__(self) -> None:
"""Initialize a new shell launcher."""
self._launched: dict[LaunchedJobID, sp.Popen[bytes]] = {}

def check_popen_inputs(self, shell_command: ShellLauncherCommand) -> None:
@staticmethod
def check_popen_inputs(shell_command: ShellLauncherCommand) -> None:
"""Validate that the contents of a shell command are valid.
:param shell_command: The command to validate
Expand Down
20 changes: 11 additions & 9 deletions smartsim/launchable/mpmd_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _check_entity(mpmd_pairs: t.List[MPMDPair]) -> None:
ret: SmartSimEntity | None = None
for mpmd_pair in mpmd_pairs:
if flag == 1:
if type(ret) == type(mpmd_pair.entity):
if isinstance(ret,type(mpmd_pair.entity)):
flag = 0
else:
raise SSUnsupportedError(
Expand Down Expand Up @@ -110,11 +110,13 @@ def get_launch_steps(self) -> LaunchCommands:

def __str__(self) -> str: # pragma: no cover
"""returns A user-readable string of a MPMD Job"""
fmt = lambda mpmd_pair: textwrap.dedent(
f"""\
== MPMD Pair ==
{mpmd_pair.entity}
{mpmd_pair.launch_settings}
"""
)
return "\n".join(map(fmt, self.mpmd_pairs))

def _fmt(mpmd_pair: MPMDPair) -> str:
return textwrap.dedent(
f"""\
== MPMD Pair ==
{mpmd_pair.entity}
{mpmd_pair.launch_settings}
"""
)
return "\n".join(map(_fmt, self.mpmd_pairs))
4 changes: 2 additions & 2 deletions smartsim/settings/arguments/launch/alps.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
logger = get_logger(__name__)
_as_aprun_command = make_shell_format_fn(run_command="aprun")

# pylint: disable=no-self-use


@dispatch(with_format=_as_aprun_command, to_launcher=ShellLauncher)
class AprunLaunchArguments(ShellLaunchArguments):
def _reserved_launch_args(self) -> set[str]:
@staticmethod
def _reserved_launch_args() -> set[str]:
"""Return reserved launch arguments.
:returns: The set of reserved launcher arguments
Expand Down
7 changes: 2 additions & 5 deletions smartsim/settings/arguments/launch/lsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@

logger = get_logger(__name__)

# ***************************************
# TODO: Remove pylint disable after merge
# ***************************************
# pylint: disable=no-self-use


def _as_jsrun_command(
Expand Down Expand Up @@ -76,7 +72,8 @@ def launcher_str(self) -> str:
"""
return LauncherType.LSF.value

def _reserved_launch_args(self) -> set[str]:
@staticmethod
def _reserved_launch_args() -> set[str]:
"""Return reserved launch arguments.
:returns: The set of reserved launcher arguments
Expand Down
7 changes: 2 additions & 5 deletions smartsim/settings/arguments/launch/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,15 @@

logger = get_logger(__name__)

# ***************************************
# TODO: Remove pylint disable after merge
# ***************************************
# pylint: disable=no-self-use

_as_mpirun_command = make_shell_format_fn("mpirun")
_as_mpiexec_command = make_shell_format_fn("mpiexec")
_as_orterun_command = make_shell_format_fn("orterun")


class _BaseMPILaunchArguments(ShellLaunchArguments):
def _reserved_launch_args(self) -> set[str]:
@staticmethod
def _reserved_launch_args() -> set[str]:
"""Return reserved launch arguments.
:returns: The set of reserved launcher arguments
Expand Down
7 changes: 2 additions & 5 deletions smartsim/settings/arguments/launch/pals.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
logger = get_logger(__name__)
_as_pals_command = make_shell_format_fn(run_command="mpiexec")

# ***************************************
# TODO: Remove pylint disable after merge
# ***************************************
# pylint: disable=no-self-use


@dispatch(with_format=_as_pals_command, to_launcher=ShellLauncher)
Expand All @@ -54,7 +50,8 @@ def launcher_str(self) -> str:
"""
return LauncherType.PALS.value

def _reserved_launch_args(self) -> set[str]:
@staticmethod
def _reserved_launch_args() -> set[str]:
"""Return reserved launch arguments.
:returns: The set of reserved launcher arguments
Expand Down
11 changes: 4 additions & 7 deletions smartsim/settings/arguments/launch/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@

logger = get_logger(__name__)

# ***************************************
# TODO: Remove pylint disable after merge
# ***************************************
# pylint: disable=no-self-use


def _as_srun_command(
args: ShellLaunchArguments,
Expand Down Expand Up @@ -78,7 +73,8 @@ def launcher_str(self) -> str:
"""
return LauncherType.SLURM.value

def _reserved_launch_args(self) -> set[str]:
@staticmethod
def _reserved_launch_args() -> set[str]:
"""Return reserved launch arguments.
:returns: The set of reserved launcher arguments
Expand Down Expand Up @@ -316,7 +312,8 @@ def format_comma_sep_env_vars(

return fmt_exported_env, compound_env

def _check_env_vars(self, env_vars: t.Mapping[str, str | None]) -> None:
@staticmethod
def _check_env_vars(env_vars: t.Mapping[str, str | None]) -> None:
"""Warn a user trying to set a variable which is set in the environment
Given Slurm's env var precedence, trying to export a variable which is already
Expand Down
14 changes: 9 additions & 5 deletions smartsim/settings/sge_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
# ***************************************
# TODO: Remove pylint disable after merge
# ***************************************
# pylint: disable=no-self-use,no-member

# pylint: disable=no-member
# TODO: 'BsubBatchArguments','SlurmBatchArguments',
# 'QsubBatchArguments' has no 'items' member

class SgeQsubBatchSettings(BatchSettings):
def __init__(
Expand Down Expand Up @@ -94,12 +95,14 @@ def resources(self, resources: t.Dict[str, t.Union[str, int]]) -> None:
self._sanity_check_resources(resources)
self._resources = resources.copy()

def set_hostlist(self, host_list: t.Union[str, t.List[str]]) -> None:
@staticmethod
def set_hostlist(host_list: t.Union[str, t.List[str]]) -> None:
raise LauncherUnsupportedFeature(
"SGE does not support requesting specific hosts in batch jobs"
)

def set_queue(self, queue: str) -> None:
@staticmethod
def set_queue(queue: str) -> None:
raise LauncherUnsupportedFeature("SGE does not support specifying queues")

def set_shebang(self, shebang: str) -> None:
Expand All @@ -124,7 +127,8 @@ def set_walltime(self, walltime: str) -> None:
if walltime:
self.set_resource("h_rt", walltime)

def set_nodes(self, num_nodes: t.Optional[int]) -> None:
@staticmethod
def set_nodes(num_nodes: t.Optional[int]) -> None:
"""Set the number of nodes, invalid for SGE
:param nodes: Number of nodes, any integer other than 0 is invalid
Expand Down

0 comments on commit 94f0608

Please sign in to comment.