Skip to content
Snippets Groups Projects
Commit d64ab5bc authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

Merge branch 'retry-doc-strings' into 'towards-conventional-doc-strings'

Restructure doc strings

See merge request mpsd-cs/mpsd-software-environments!13
parents 1c3897b1 50e69fc1
No related branches found
No related tags found
3 merge requests!19Move linux-debian11 into main,!13Restructure doc strings,!11Making docstrings comply with numpydoc
Pipeline #368428 passed
...@@ -14,6 +14,7 @@ This function builds toolchains for MPSD-HPC at the appropriate directory, \n ...@@ -14,6 +14,7 @@ This function builds toolchains for MPSD-HPC at the appropriate directory, \n
for given system architecture and MPSD software stack version.\n for given system architecture and MPSD software stack version.\n
The toolchains The toolchains
are built using the bash script spack_setup.sh, and the results are logged. """ are built using the bash script spack_setup.sh, and the results are logged. """
config_vars = { config_vars = {
"cmd_log_file": "install.log", "cmd_log_file": "install.log",
"build_log_file": ( "build_log_file": (
...@@ -28,8 +29,9 @@ config_vars = { ...@@ -28,8 +29,9 @@ config_vars = {
# Helper class to change directory via context manager # Helper class to change directory via context manager
class os_chdir: class os_chdir:
""" """
The os_chdir class is a context manager that The os_chdir class is a context manager.
changes the current directory to a specified directory
It changes the current directory to a specified directory
and returns to the original directory after execution. and returns to the original directory after execution.
""" """
...@@ -47,20 +49,26 @@ class os_chdir: ...@@ -47,20 +49,26 @@ class os_chdir:
def setup_log_cmd( def setup_log_cmd(
mpsd_release: str, script_dir: str, msg: str = None, *args, **kwargs mpsd_release: str, script_dir: str, msg: str = None, *args, **kwargs
) -> None: ) -> None:
"""The setup_log_cmd function logs the command used to build the """
toolchains, along with information about the software environment installer Log the command used to build the toolchains.
branch, the Spack environments branch, and the commit hashes of each. It
also logs steps taken in install process using the optional message It also logs information about the software environment installer branch,
argument. the Spack environments branch, and the commit hashes of each.
It also logs steps taken
Args: in the install process using the optional message argument.
mpsd_release (str): The name of the release to install toolchains for.
script_dir (str): The path to the directory where the scripts are located. Parameters
msg (str, optional): An optional message to log in the command log file. ----------
- mpsd_release : str
Returns: The name of the release to install toolchains for.
None - script_dir : str
The path to the directory where the scripts are located.
- msg : str, optional
An optional message to log in the command log file.
Returns
-------
- None
""" """
release_base_dir = script_dir / mpsd_release release_base_dir = script_dir / mpsd_release
...@@ -125,15 +133,14 @@ def create_dir_structure(mpsd_release: str, script_dir: Path) -> None: ...@@ -125,15 +133,14 @@ def create_dir_structure(mpsd_release: str, script_dir: Path) -> None:
the specified release and clones the Spack environments repository if it the specified release and clones the Spack environments repository if it
doesn't exist. doesn't exist.
Args Parameters
---- ----------
- mpsd_release: A string representing the MPSD release version. - mpsd_release: A string representing the MPSD release version.
- script_dir: A Path object representing the path to the scripts directory. - script_dir: A Path object representing the path to the scripts directory.
Returns Returns
------- -------
- None - None
""" """
# Create the directory structure for the release # Create the directory structure for the release
release_base_dir = script_dir / mpsd_release release_base_dir = script_dir / mpsd_release
...@@ -169,28 +176,26 @@ def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, Lis ...@@ -169,28 +176,26 @@ def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, Lis
Get information about the specified release, such as the branch and commit hash Get information about the specified release, such as the branch and commit hash
of the Spack environments repository and the available toolchains. of the Spack environments repository and the available toolchains.
Args Parameters
---- ----------
mpsd_release : str mpsd_release : str
the name of the release to get information for. The name of the release to get information for.
script_dir : pathlib.Path script_dir : pathlib.Path
the base directory where releases are stored. The base directory where releases are stored.
Returns Returns
------- -------
spe_branch : str spe_branch : str
the name of the branch for the Spack environments repository. The name of the branch for the Spack environments repository.
spe_commit_hash : str spe_commit_hash : str
the commit hash for the Spack environments repository. The commit hash for the Spack environments repository.
available_toolchains : list available_toolchains : list
a list of strings representing the available A list of strings representing the available toolchains for the release.
toolchains for the release.
Raises Raises
------ ------
FileNotFoundError : FileNotFoundError
If the release directory does not exist. Run `create_dir_structure()` If the release directory does not exist. Run `create_dir_structure()` first.
first.
""" """
# Get the info for release # Get the info for release
release_base_dir = script_dir / mpsd_release release_base_dir = script_dir / mpsd_release
...@@ -219,21 +224,26 @@ def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, Lis ...@@ -219,21 +224,26 @@ def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, Lis
def prepare_environment(mpsd_release: str, script_dir: Path) -> List[str]: def prepare_environment(mpsd_release: str, script_dir: Path) -> List[str]:
""" """
Creates Create the directory structure for the given MPSD release.
- Creates the directory structure for the given MPSD release and clones the
spack-environments repository. It does the following steps:
- Determines the branch and commit hash of the spack-environments repository and Clones the spack-environments repository.
the available toolchains. Determines the branch and commit hash of the spack-environments repository
- Logs the command usage. and the available toolchains.
Logs the command usage.
Args:
- mpsd_release (str): The name of the MPSD release to prepare the environment for. Parameters
- script_dir (pathlib.Path): The base directory to create the release folder and ----------
clone the spack-environments repository into. mpsd_release : str
The name of the MPSD release to prepare the environment for.
Returns: script_dir : pathlib.Path
- available_toolchains (list): A list of available toolchains for the given MPSD The base directory to create the release folder and
release. clone the spack-environments repository into.
Returns
-------
available_toolchains : list
A list of available toolchains for the given MPSD release.
""" """
create_dir_structure(mpsd_release, script_dir) create_dir_structure(mpsd_release, script_dir)
spe_branch, spe_commit_hash, available_toolchains = get_release_info( spe_branch, spe_commit_hash, available_toolchains = get_release_info(
...@@ -252,30 +262,36 @@ def install_environment( ...@@ -252,30 +262,36 @@ def install_environment(
force_reinstall: bool = False, force_reinstall: bool = False,
enable_build_cache: bool = False, enable_build_cache: bool = False,
) -> None: ) -> None:
"""Installs the specified MPSD release and toolchains to the specified """
directory using Spack. Install the specified MPSD release and toolchains.
Args:
mpsd_release: A string representing the MPSD release version.
toolchains: A list of strings representing the toolchains to install
(e.g., "foss2021a-mpi", "global_generic", "ALL").
script_dir: A Path object representing the path to the directory where
the release and toolchains will be installed.
force_reinstall: A boolean indicating whether to force a reinstallation
even if the release and toolchains already exist. Defaults to False.
enable_build_cache: A boolean indicating whether to build the build The function installs the toolchain to the specified directory, using Spack.
cache when installing toolchains. Defaults to False.
Raises: Parameters
ValueError: If a requested toolchain is not available in the specified release. ----------
mpsd_release : str
A string representing the MPSD release version.
toolchains : list of str
A list of strings representing the toolchains to install
(e.g., "foss2021a-mpi", "global_generic", "ALL").
script_dir : pathlib.Path
A Path object representing the path to the directory where
the release and toolchains will be installed.
force_reinstall : bool, optional
A boolean indicating whether to force a reinstallation
even if the release and toolchains already exist. Defaults to False.
enable_build_cache : bool, optional
A boolean indicating whether to build the build cache
when installing toolchains. Defaults to False.
Returns: Raises
None ------
ValueError
If a requested toolchain is not available in the specified release.
Returns
-------
None
""" """
print( print(
f"Installing release {mpsd_release} with toolchains {toolchains} " f"Installing release {mpsd_release} with toolchains {toolchains} "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment