Skip to content
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

Update docstring to comply with coding style and max column length #45

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/cloudai/_core/base_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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

Expand All @@ -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})"
28 changes: 11 additions & 17 deletions src/cloudai/_core/base_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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 = []

Expand Down
8 changes: 3 additions & 5 deletions src/cloudai/_core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
15 changes: 5 additions & 10 deletions src/cloudai/_core/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down