Skip to content

Commit 1d7c50a

Browse files
committed
Refactor to have max line size to 120.
1 parent ceaaa56 commit 1d7c50a

File tree

8 files changed

+69
-165
lines changed

8 files changed

+69
-165
lines changed

autosubmit/performance/base_performance.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ class PerformanceMetricInfo(NamedTuple):
4747
class BasePerformance(ABC):
4848
"""Base class for performance metrics calculation"""
4949

50-
_mail_notifier = MailNotifier(
51-
BasicConfig()
52-
) # Default MailNotifier with BasicConfig
50+
_mail_notifier = MailNotifier(BasicConfig()) # Default MailNotifier with BasicConfig
5351

5452
def __init__(self, autosubmit_config: Optional[AutosubmitConfig] = None):
5553
"""
@@ -61,9 +59,7 @@ def __init__(self, autosubmit_config: Optional[AutosubmitConfig] = None):
6159
self._autosubmit_config = autosubmit_config
6260

6361
@abstractmethod
64-
def compute_and_check_performance_metrics(
65-
self, job: "Job"
66-
) -> list[PerformanceMetricInfo]:
62+
def compute_and_check_performance_metrics(self, job: "Job") -> list[PerformanceMetricInfo]:
6763
"""
6864
Compute performance metrics for a job.
6965

autosubmit/performance/factory_performance.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525

2626
class PerformanceFactory:
2727

28-
def create_performance(
29-
self, job: "Job", config: AutosubmitConfig
30-
) -> BasePerformance:
28+
def create_performance(self, job: "Job", config: AutosubmitConfig) -> BasePerformance:
3129
"""
3230
Factory method to create a performance metric calculator for a job.
3331
@@ -64,9 +62,7 @@ def create_performance(
6462
return self._create_performance_by_type(f"{job.section}_{project}", config)
6563

6664
@staticmethod
67-
def _create_performance_by_type(
68-
job_type: str, config: AutosubmitConfig
69-
) -> BasePerformance:
65+
def _create_performance_by_type(job_type: str, config: AutosubmitConfig) -> BasePerformance:
7066
"""
7167
Create a performance calculator based on the job type.
7268

autosubmit/performance/type_job/SIM/SIM_performance.py

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
# along with Autosubmit. If not, see <http://www.gnu.org/licenses/>.
1717

1818
from typing import TYPE_CHECKING
19-
from autosubmit.performance.base_performance import (
20-
BasePerformance,
21-
PerformanceMetricInfo,
22-
)
19+
from autosubmit.performance.base_performance import BasePerformance,PerformanceMetricInfo
2320

2421
if TYPE_CHECKING:
2522
from autosubmit.job.job import Job
@@ -35,9 +32,7 @@ class SIMPerformance(BasePerformance):
3532

3633
# Errors management for each metric
3734

38-
def _manage_errors_computation_SYPD(
39-
start_timestamp, finish_timestamp, chunk_size, chunk_size_unit
40-
):
35+
def _manage_errors_computation_SYPD(start_timestamp, finish_timestamp, chunk_size, chunk_size_unit):
4136
"""
4237
Manage errors in the computation of SYPD.
4338
@@ -51,37 +46,23 @@ def _manage_errors_computation_SYPD(
5146
ValueError: If any of the parameters are invalid.
5247
"""
5348

54-
if not (
55-
start_timestamp and finish_timestamp and chunk_size and chunk_size_unit
56-
):
57-
raise ValueError(
58-
"Job must have start_time_timestamp, finish_time_timestamp, parameters ['EXPERIMENT']['CHUNKSIZE'] and parameters ['EXPERIMENT']['CHUNKSIZEUNIT'] set."
59-
)
49+
if not (start_timestamp and finish_timestamp and chunk_size and chunk_size_unit):
50+
raise ValueError("Job must have start_time_timestamp, finish_time_timestamp, parameters ['EXPERIMENT']['CHUNKSIZE'] and parameters ['EXPERIMENT']['CHUNKSIZEUNIT'] set.")
6051

6152
if not isinstance(start_timestamp, int):
62-
raise TypeError(
63-
"start_timestamp must be an integer representing Unix timestamp."
64-
)
53+
raise TypeError("start_timestamp must be an integer representing Unix timestamp.")
6554

6655
if not isinstance(finish_timestamp, int):
67-
raise TypeError(
68-
"finish_timestamp must be an integer representing Unix timestamp."
69-
)
56+
raise TypeError("finish_timestamp must be an integer representing Unix timestamp.")
7057

7158
if not isinstance(chunk_size, str):
72-
raise TypeError(
73-
"chunk_size must be a string representing the size of the chunk (e.g., '12')."
74-
)
59+
raise TypeError("chunk_size must be a string representing the size of the chunk (e.g., '12').")
7560

7661
if not isinstance(chunk_size_unit, str):
77-
raise TypeError(
78-
"chunk_size_unit must be a string representing the unit of the chunk size (e.g., 'month')."
79-
)
62+
raise TypeError("chunk_size_unit must be a string representing the unit of the chunk size (e.g., 'month').")
8063

8164
if not chunk_size.isdigit() or int(chunk_size) <= 0:
82-
raise ValueError(
83-
"chunk_size must be a positive numeric string (e.g., '12')."
84-
)
65+
raise ValueError("chunk_size must be a positive numeric string (e.g., '12').")
8566

8667
# Computation and check of SYPD
8768

@@ -102,9 +83,7 @@ def compute_sypd_from_job(job: "Job") -> float:
10283
chunk_size = job.parameters["EXPERIMENT"]["CHUNKSIZE"]
10384
chunk_size_unit = job.parameters["EXPERIMENT"]["CHUNKSIZEUNIT"]
10485

105-
SIMPerformance._manage_errors_computation_SYPD(
106-
start_timestamp, finish_timestamp, chunk_size, chunk_size_unit
107-
)
86+
SIMPerformance._manage_errors_computation_SYPD(start_timestamp, finish_timestamp, chunk_size, chunk_size_unit)
10887

10988
duration_seconds = finish_timestamp - start_timestamp
11089

@@ -150,9 +129,7 @@ def compute_and_check_SYPD_threshold(self, job: "Job") -> PerformanceMetricInfo:
150129

151130
# Computation and check of performance metrics
152131

153-
def compute_and_check_performance_metrics(
154-
self, job: "Job"
155-
) -> list[PerformanceMetricInfo]:
132+
def compute_and_check_performance_metrics(self, job: "Job") -> list[PerformanceMetricInfo]:
156133
"""
157134
Compute the performance metrics for a job and check if it is under a threshold.
158135

autosubmit/performance/type_job/SIM/project/SIM_DestinE.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ class SIMDestinEPerformance(SIMPerformance):
3131

3232
SYPD_THRESHOLD: float = 2 # Threshold for SYPD to consider a job as "fast"
3333

34-
def compute_and_check_performance_metrics(
35-
self, job: "Job"
36-
) -> list[PerformanceMetricInfo]:
34+
def compute_and_check_performance_metrics(self, job: "Job") -> list[PerformanceMetricInfo]:
3735
"""
3836
Compute the performance metrics for a SIM DestinE job and check if it is under a threshold.
3937

test/unit/performance/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def mock_smtp(mocker):
100100

101101

102102
@pytest.fixture
103-
def mock_mail_notifier(mock_basic_config):
103+
def mock_mail_notifier(mock_basic_config) -> MailNotifier:
104104
"""
105105
Fixture to create a MailNotifier instance with mocked BasicConfig.
106106
"""

0 commit comments

Comments
 (0)