Skip to content

Commit bd45608

Browse files
Provide the log_obj_size option in every Executor (#716)
* Provide the log_obj_size option in every Executor * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 4458c86 commit bd45608

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

executorlib/executor/flux.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from executorlib.standalone.inputcheck import (
55
check_command_line_argument_lst,
66
check_init_function,
7+
check_log_obj_size,
78
check_oversubscribe,
89
check_plot_dependency_graph,
910
check_pmi,
@@ -246,6 +247,7 @@ class FluxClusterExecutor(BaseExecutor):
246247
plot_dependency_graph (bool): Plot the dependencies of multiple future objects without executing them. For
247248
debugging purposes and to get an overview of the specified dependencies.
248249
plot_dependency_graph_filename (str): Name of the file to store the plotted graph in.
250+
log_obj_size (bool): Enable debug mode which reports the size of the communicated objects.
249251
250252
Examples:
251253
```
@@ -282,6 +284,7 @@ def __init__(
282284
refresh_rate: float = 0.01,
283285
plot_dependency_graph: bool = False,
284286
plot_dependency_graph_filename: Optional[str] = None,
287+
log_obj_size: bool = False,
285288
):
286289
"""
287290
The executorlib.FluxClusterExecutor leverages either the message passing interface (MPI), the SLURM workload
@@ -323,6 +326,7 @@ def __init__(
323326
plot_dependency_graph (bool): Plot the dependencies of multiple future objects without executing them. For
324327
debugging purposes and to get an overview of the specified dependencies.
325328
plot_dependency_graph_filename (str): Name of the file to store the plotted graph in.
329+
log_obj_size (bool): Enable debug mode which reports the size of the communicated objects.
326330
327331
"""
328332
default_resource_dict: dict = {
@@ -338,6 +342,7 @@ def __init__(
338342
resource_dict.update(
339343
{k: v for k, v in default_resource_dict.items() if k not in resource_dict}
340344
)
345+
check_log_obj_size(log_obj_size=log_obj_size)
341346
if not plot_dependency_graph:
342347
import pysqa # noqa
343348

executorlib/executor/slurm.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from executorlib.executor.base import BaseExecutor
44
from executorlib.standalone.inputcheck import (
55
check_init_function,
6+
check_log_obj_size,
67
check_plot_dependency_graph,
78
check_refresh_rate,
89
validate_number_of_cores,
@@ -58,6 +59,7 @@ class SlurmClusterExecutor(BaseExecutor):
5859
plot_dependency_graph (bool): Plot the dependencies of multiple future objects without executing them. For
5960
debugging purposes and to get an overview of the specified dependencies.
6061
plot_dependency_graph_filename (str): Name of the file to store the plotted graph in.
62+
log_obj_size (bool): Enable debug mode which reports the size of the communicated objects.
6163
6264
Examples:
6365
```
@@ -94,6 +96,7 @@ def __init__(
9496
refresh_rate: float = 0.01,
9597
plot_dependency_graph: bool = False,
9698
plot_dependency_graph_filename: Optional[str] = None,
99+
log_obj_size: bool = False,
97100
):
98101
"""
99102
The executorlib.SlurmClusterExecutor leverages either the message passing interface (MPI), the SLURM workload
@@ -135,6 +138,7 @@ def __init__(
135138
plot_dependency_graph (bool): Plot the dependencies of multiple future objects without executing them. For
136139
debugging purposes and to get an overview of the specified dependencies.
137140
plot_dependency_graph_filename (str): Name of the file to store the plotted graph in.
141+
log_obj_size (bool): Enable debug mode which reports the size of the communicated objects.
138142
139143
"""
140144
default_resource_dict: dict = {
@@ -150,6 +154,7 @@ def __init__(
150154
resource_dict.update(
151155
{k: v for k, v in default_resource_dict.items() if k not in resource_dict}
152156
)
157+
check_log_obj_size(log_obj_size=log_obj_size)
153158
if not plot_dependency_graph:
154159
import pysqa # noqa
155160

executorlib/standalone/inputcheck.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,21 @@ def validate_number_of_cores(
194194

195195

196196
def check_file_exists(file_name: Optional[str]):
197+
"""
198+
Check if file exists and raise a ValueError if it does not or file_name is None.
199+
"""
197200
if file_name is None:
198201
raise ValueError("file_name is not set.")
199202
if not os.path.exists(file_name):
200203
raise ValueError("file_name is not written to the file system.")
204+
205+
206+
def check_log_obj_size(log_obj_size: bool) -> None:
207+
"""
208+
Check if log_obj_size is True and raise a ValueError if it is.
209+
"""
210+
if log_obj_size:
211+
raise ValueError(
212+
"log_obj_size is not supported for the executorlib.SlurmClusterExecutor and executorlib.FluxClusterExecutor."
213+
"Please use log_obj_size=False instead of log_obj_size=True."
214+
)

tests/test_standalone_inputcheck.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
check_hostname_localhost,
1919
check_pysqa_config_directory,
2020
check_file_exists,
21+
check_log_obj_size,
2122
validate_number_of_cores,
2223
)
2324

@@ -119,3 +120,7 @@ def test_validate_number_of_cores(self):
119120
),
120121
int,
121122
)
123+
124+
def test_check_log_obj_size(self):
125+
with self.assertRaises(ValueError):
126+
check_log_obj_size(log_obj_size=True)

0 commit comments

Comments
 (0)