From e5e5aff7032122c8e6aac0c54d42240db9eeab58 Mon Sep 17 00:00:00 2001 From: Taekyung Heo <7621438+TaekyungHeo@users.noreply.github.com> Date: Tue, 28 May 2024 13:20:47 -0700 Subject: [PATCH] Update docstring to comply with coding style and max column length --- src/cloudai/_core/base_job.py | 11 +++-------- src/cloudai/_core/base_runner.py | 28 +++++++++++----------------- src/cloudai/_core/runner.py | 8 +++----- src/cloudai/_core/test_template.py | 15 +++++---------- 4 files changed, 22 insertions(+), 40 deletions(-) diff --git a/src/cloudai/_core/base_job.py b/src/cloudai/_core/base_job.py index 00167ef0..c8ee014f 100644 --- a/src/cloudai/_core/base_job.py +++ b/src/cloudai/_core/base_job.py @@ -22,8 +22,7 @@ class BaseJob: Attributes id (int): The unique identifier of the job. test (Test): The test instance associated with this job. - terminated_by_dependency (bool): Flag to indicate if the job was - terminated due to a dependency. + terminated_by_dependency (bool): Flag to indicate if the job was terminated due to a dependency. """ def __init__(self, job_id: int, test: Test): @@ -42,8 +41,7 @@ def increment_iteration(self): """ Increment the iteration count of the associated test. - This method should be called when the job completes an iteration and is - ready to proceed to the next one. + This method should be called when the job completes an iteration and is ready to proceed to the next one. """ self.test.current_iteration += 1 @@ -54,7 +52,4 @@ def __repr__(self) -> str: Returns str: String representation of the job. """ - return ( - f"BaseJob(id={self.id}, test={self.test.name}, " - f"terminated_by_dependency={self.terminated_by_dependency})" - ) + return f"BaseJob(id={self.id}, test={self.test.name}, terminated_by_dependency={self.terminated_by_dependency})" diff --git a/src/cloudai/_core/base_runner.py b/src/cloudai/_core/base_runner.py index 1abd2747..3831b95a 100644 --- a/src/cloudai/_core/base_runner.py +++ b/src/cloudai/_core/base_runner.py @@ -45,9 +45,8 @@ class BaseRunner(ABC): jobs (List[BaseJob]): List to track jobs created by the runner. test_to_job_map (Dict[Test, BaseJob]): Mapping from tests to their jobs. logger (logging.Logger): Logger for the runner. - shutting_down (bool): A flag indicating whether a shutdown process has been - initiated, preventing the start of new tests and ensuring - a graceful termination of all running tests. + shutting_down (bool): A flag indicating whether a shutdown process has been initiated, preventing the start of + new tests and ensuring a graceful termination of all running tests. """ def __init__( @@ -113,15 +112,14 @@ def signal_handler( """ Respond to termination-related signals (e.g., SIGINT) by initiating a graceful shutdown of the application. - This method logs the received signal and then triggers the asynchronous - shutdown process, which involves terminating all outstanding jobs in a - controlled manner. + This method logs the received signal and then triggers the asynchronous shutdown process, which involves + terminating all outstanding jobs in a controlled manner. Args: signum (int): The signal number indicating the type of signal received. - frame (Optional[FrameType]): The current stack frame when the signal - was received, or None if not applicable. This parameter is typically - not used directly but is necessary for signal handler functions. + frame (Optional[FrameType]): The current stack frame when the signal was received, or None if not + applicable. This parameter is typically not used directly but is necessary for signal handler + functions. Returns: None @@ -231,12 +229,10 @@ def find_dependency_free_tests(self) -> List[Test]: """ Find tests that have no 'start_post_comp' or 'start_post_init' dependencies. - Tests with only 'end_post_comp' dependencies or no dependencies at all - are considered dependency-free. + Tests with only 'end_post_comp' dependencies or no dependencies at all are considered dependency-free. Returns - List[Test]: A list of tests that are ready to run without waiting for - other tests to start or complete. + List[Test]: A list of tests that are ready to run without waiting for other tests to start or complete. """ dependency_free_tests = [] for test in self.test_scenario.tests: @@ -253,8 +249,7 @@ def get_job_output_path(self, test: Test) -> str: do not exist. Args: - test (Test): The test instance for which to generate the output - directory path. + test (Test): The test instance for which to generate the output directory path. Returns: str: The path to the job's output directory. @@ -348,8 +343,7 @@ async def handle_dependencies(self, completed_job: BaseJob) -> List[Task]: completed_job (BaseJob): The job that has just been completed. Returns: - List[asyncio.Task]: A list of asyncio.Task objects created for handling - the dependencies. + List[asyncio.Task]: A list of asyncio.Task objects created for handling the dependencies. """ tasks = [] diff --git a/src/cloudai/_core/runner.py b/src/cloudai/_core/runner.py index d755ecea..25c5784f 100644 --- a/src/cloudai/_core/runner.py +++ b/src/cloudai/_core/runner.py @@ -24,13 +24,11 @@ class Runner: """ A wrapper class that creates and manages a specific runner instance based on the system's scheduler type. - This class facilitates the initialization of the appropriate runner - (StandaloneRunner or SlurmRunner) based on the scheduler specified in the - system configuration. + This class facilitates the initialization of the appropriate runner (StandaloneRunner or SlurmRunner) based on the + scheduler specified in the system configuration. Attributes: - _runners (Dict[str, Type[BaseRunner]]): A mapping from system - types to their corresponding runner classes. + _runners (Dict[str, Type[BaseRunner]]): A mapping from system types to their corresponding runner classes. runner (BaseRunner): The specific runner instance for the system. logger (logging.Logger): Logger for the runner activities. diff --git a/src/cloudai/_core/test_template.py b/src/cloudai/_core/test_template.py index 7ad6008f..3c9875ce 100644 --- a/src/cloudai/_core/test_template.py +++ b/src/cloudai/_core/test_template.py @@ -35,16 +35,11 @@ class TestTemplate: env_vars (Dict[str, Any]): Default environment variables. cmd_args (Dict[str, Any]): Default command-line arguments. logger (logging.Logger): Logger for the test template. - install_strategy (InstallStrategy): Strategy for installing test - prerequisites. - command_gen_strategy (CommandGenStrategy): Strategy for generating - execution commands. - job_id_retrieval_strategy (JobIdRetrievalStrategy): Strategy for - retrieving job IDs. - report_generation_strategy (ReportGenerationStrategy): Strategy for - generating reports. - grading_strategy (GradingStrategy): Strategy for grading performance - based on test outcomes. + install_strategy (InstallStrategy): Strategy for installing test prerequisites. + command_gen_strategy (CommandGenStrategy): Strategy for generating execution commands. + job_id_retrieval_strategy (JobIdRetrievalStrategy): Strategy for retrieving job IDs. + report_generation_strategy (ReportGenerationStrategy): Strategy for generating reports. + grading_strategy (GradingStrategy): Strategy for grading performance based on test outcomes. """ __test__ = False