executorlib 0.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- executorlib-0.0.8/LICENSE +29 -0
- executorlib-0.0.8/MANIFEST.in +1 -0
- executorlib-0.0.8/PKG-INFO +230 -0
- executorlib-0.0.8/README.md +154 -0
- executorlib-0.0.8/executorlib/__init__.py +248 -0
- executorlib-0.0.8/executorlib/_version.py +21 -0
- executorlib-0.0.8/executorlib/backend/__init__.py +0 -0
- executorlib-0.0.8/executorlib/backend/cache_parallel.py +57 -0
- executorlib-0.0.8/executorlib/backend/cache_serial.py +6 -0
- executorlib-0.0.8/executorlib/backend/interactive_parallel.py +99 -0
- executorlib-0.0.8/executorlib/backend/interactive_serial.py +74 -0
- executorlib-0.0.8/executorlib/base/__init__.py +0 -0
- executorlib-0.0.8/executorlib/base/executor.py +167 -0
- executorlib-0.0.8/executorlib/cache/__init__.py +0 -0
- executorlib-0.0.8/executorlib/cache/backend.py +75 -0
- executorlib-0.0.8/executorlib/cache/executor.py +121 -0
- executorlib-0.0.8/executorlib/cache/queue_spawner.py +109 -0
- executorlib-0.0.8/executorlib/cache/shared.py +249 -0
- executorlib-0.0.8/executorlib/cache/subprocess_spawner.py +65 -0
- executorlib-0.0.8/executorlib/interactive/__init__.py +0 -0
- executorlib-0.0.8/executorlib/interactive/executor.py +329 -0
- executorlib-0.0.8/executorlib/interactive/flux.py +135 -0
- executorlib-0.0.8/executorlib/interactive/shared.py +657 -0
- executorlib-0.0.8/executorlib/interactive/slurm.py +109 -0
- executorlib-0.0.8/executorlib/standalone/__init__.py +21 -0
- executorlib-0.0.8/executorlib/standalone/command.py +14 -0
- executorlib-0.0.8/executorlib/standalone/hdf.py +116 -0
- executorlib-0.0.8/executorlib/standalone/inputcheck.py +201 -0
- executorlib-0.0.8/executorlib/standalone/interactive/__init__.py +0 -0
- executorlib-0.0.8/executorlib/standalone/interactive/backend.py +98 -0
- executorlib-0.0.8/executorlib/standalone/interactive/communication.py +213 -0
- executorlib-0.0.8/executorlib/standalone/interactive/spawner.py +174 -0
- executorlib-0.0.8/executorlib/standalone/plot.py +134 -0
- executorlib-0.0.8/executorlib/standalone/queue.py +19 -0
- executorlib-0.0.8/executorlib/standalone/serialize.py +82 -0
- executorlib-0.0.8/executorlib/standalone/thread.py +42 -0
- executorlib-0.0.8/executorlib.egg-info/PKG-INFO +230 -0
- executorlib-0.0.8/executorlib.egg-info/SOURCES.txt +65 -0
- executorlib-0.0.8/executorlib.egg-info/dependency_links.txt +1 -0
- executorlib-0.0.8/executorlib.egg-info/requires.txt +29 -0
- executorlib-0.0.8/executorlib.egg-info/top_level.txt +1 -0
- executorlib-0.0.8/pyproject.toml +74 -0
- executorlib-0.0.8/setup.cfg +4 -0
- executorlib-0.0.8/setup.py +8 -0
- executorlib-0.0.8/tests/test_backend_serial.py +85 -0
- executorlib-0.0.8/tests/test_cache_executor_interactive.py +33 -0
- executorlib-0.0.8/tests/test_cache_executor_mpi.py +44 -0
- executorlib-0.0.8/tests/test_cache_executor_pysqa_flux.py +49 -0
- executorlib-0.0.8/tests/test_cache_executor_serial.py +193 -0
- executorlib-0.0.8/tests/test_cache_hdf.py +105 -0
- executorlib-0.0.8/tests/test_cache_shared.py +109 -0
- executorlib-0.0.8/tests/test_dependencies_executor.py +259 -0
- executorlib-0.0.8/tests/test_executor_backend_flux.py +169 -0
- executorlib-0.0.8/tests/test_executor_backend_mpi.py +143 -0
- executorlib-0.0.8/tests/test_executor_backend_mpi_noblock.py +83 -0
- executorlib-0.0.8/tests/test_flux_executor.py +160 -0
- executorlib-0.0.8/tests/test_integration_pyiron_workflow.py +237 -0
- executorlib-0.0.8/tests/test_local_executor.py +524 -0
- executorlib-0.0.8/tests/test_local_executor_future.py +143 -0
- executorlib-0.0.8/tests/test_pysqa_subprocess.py +45 -0
- executorlib-0.0.8/tests/test_shared_backend.py +118 -0
- executorlib-0.0.8/tests/test_shared_communication.py +103 -0
- executorlib-0.0.8/tests/test_shared_executorbase.py +23 -0
- executorlib-0.0.8/tests/test_shared_input_check.py +121 -0
- executorlib-0.0.8/tests/test_shared_thread.py +15 -0
- executorlib-0.0.8/tests/test_shell_executor.py +149 -0
- executorlib-0.0.8/tests/test_shell_interactive.py +129 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022, Jan Janssen
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include LICENSE
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: executorlib
|
|
3
|
+
Version: 0.0.8
|
|
4
|
+
Summary: Scale serial and MPI-parallel python functions over hundreds of compute nodes all from within a jupyter notebook or serial python process.
|
|
5
|
+
Author-email: Jan Janssen <janssen@lanl.gov>
|
|
6
|
+
License: BSD 3-Clause License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2022, Jan Janssen
|
|
9
|
+
All rights reserved.
|
|
10
|
+
|
|
11
|
+
Redistribution and use in source and binary forms, with or without
|
|
12
|
+
modification, are permitted provided that the following conditions are met:
|
|
13
|
+
|
|
14
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
15
|
+
list of conditions and the following disclaimer.
|
|
16
|
+
|
|
17
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
18
|
+
this list of conditions and the following disclaimer in the documentation
|
|
19
|
+
and/or other materials provided with the distribution.
|
|
20
|
+
|
|
21
|
+
* Neither the name of the copyright holder nor the names of its
|
|
22
|
+
contributors may be used to endorse or promote products derived from
|
|
23
|
+
this software without specific prior written permission.
|
|
24
|
+
|
|
25
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
26
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
27
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
28
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
29
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
30
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
31
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
32
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
33
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
34
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
35
|
+
|
|
36
|
+
Project-URL: Homepage, https://github.com/pyiron/executorlib
|
|
37
|
+
Project-URL: Documentation, https://executorlib.readthedocs.io
|
|
38
|
+
Project-URL: Repository, https://github.com/pyiron/executorlib
|
|
39
|
+
Keywords: pyiron
|
|
40
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
41
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
42
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
43
|
+
Classifier: Intended Audience :: Science/Research
|
|
44
|
+
Classifier: Operating System :: OS Independent
|
|
45
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
46
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
47
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
48
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
49
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
50
|
+
Requires-Python: <3.14,>=3.9
|
|
51
|
+
Description-Content-Type: text/markdown
|
|
52
|
+
License-File: LICENSE
|
|
53
|
+
Requires-Dist: cloudpickle<=3.1.1,>=2.0.0
|
|
54
|
+
Requires-Dist: pyzmq<=26.2.0,>=25.0.0
|
|
55
|
+
Provides-Extra: cache
|
|
56
|
+
Requires-Dist: h5py<=3.12.1,>=3.6.0; extra == "cache"
|
|
57
|
+
Provides-Extra: graph
|
|
58
|
+
Requires-Dist: pygraphviz<=1.14,>=1.10; extra == "graph"
|
|
59
|
+
Requires-Dist: networkx<=3.4.2,>=2.8.8; extra == "graph"
|
|
60
|
+
Provides-Extra: graphnotebook
|
|
61
|
+
Requires-Dist: pygraphviz<=1.14,>=1.10; extra == "graphnotebook"
|
|
62
|
+
Requires-Dist: networkx<=3.4.2,>=2.8.8; extra == "graphnotebook"
|
|
63
|
+
Requires-Dist: ipython<=8.31.0,>=7.33.0; extra == "graphnotebook"
|
|
64
|
+
Provides-Extra: mpi
|
|
65
|
+
Requires-Dist: mpi4py<=4.0.1,>=3.1.4; extra == "mpi"
|
|
66
|
+
Provides-Extra: submission
|
|
67
|
+
Requires-Dist: pysqa==0.2.3; extra == "submission"
|
|
68
|
+
Requires-Dist: h5py<=3.12.1,>=3.6.0; extra == "submission"
|
|
69
|
+
Provides-Extra: all
|
|
70
|
+
Requires-Dist: mpi4py<=4.0.1,>=3.1.4; extra == "all"
|
|
71
|
+
Requires-Dist: pysqa==0.2.3; extra == "all"
|
|
72
|
+
Requires-Dist: h5py<=3.12.1,>=3.6.0; extra == "all"
|
|
73
|
+
Requires-Dist: pygraphviz<=1.14,>=1.10; extra == "all"
|
|
74
|
+
Requires-Dist: networkx<=3.4.2,>=2.8.8; extra == "all"
|
|
75
|
+
Requires-Dist: ipython<=8.31.0,>=7.33.0; extra == "all"
|
|
76
|
+
|
|
77
|
+
# executorlib
|
|
78
|
+
[](https://github.com/pyiron/executorlib/actions/workflows/unittest-openmpi.yml)
|
|
79
|
+
[](https://coveralls.io/github/pyiron/executorlib?branch=main)
|
|
80
|
+
[](https://mybinder.org/v2/gh/pyiron/executorlib/HEAD?labpath=notebooks%2Fexamples.ipynb)
|
|
81
|
+
|
|
82
|
+
Up-scale python functions for high performance computing (HPC) with executorlib.
|
|
83
|
+
|
|
84
|
+
## Key Features
|
|
85
|
+
* **Up-scale your Python functions beyond a single computer.** - executorlib extends the [Executor interface](https://docs.python.org/3/library/concurrent.futures.html#executor-objects)
|
|
86
|
+
from the Python standard library and combines it with job schedulers for high performance computing (HPC) including
|
|
87
|
+
the [Simple Linux Utility for Resource Management (SLURM)](https://slurm.schedmd.com) and [flux](http://flux-framework.org).
|
|
88
|
+
With this combination executorlib allows users to distribute their Python functions over multiple compute nodes.
|
|
89
|
+
* **Parallelize your Python program one function at a time** - executorlib allows users to assign dedicated computing
|
|
90
|
+
resources like CPU cores, threads or GPUs to one Python function call at a time. So you can accelerate your Python
|
|
91
|
+
code function by function.
|
|
92
|
+
* **Permanent caching of intermediate results to accelerate rapid prototyping** - To accelerate the development of
|
|
93
|
+
machine learning pipelines and simulation workflows executorlib provides optional caching of intermediate results for
|
|
94
|
+
iterative development in interactive environments like jupyter notebooks.
|
|
95
|
+
|
|
96
|
+
## Examples
|
|
97
|
+
The Python standard library provides the [Executor interface](https://docs.python.org/3/library/concurrent.futures.html#executor-objects)
|
|
98
|
+
with the [ProcessPoolExecutor](https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor) and the
|
|
99
|
+
[ThreadPoolExecutor](https://docs.python.org/3/library/concurrent.futures.html#threadpoolexecutor) for parallel
|
|
100
|
+
execution of Python functions on a single computer. executorlib extends this functionality to distribute Python
|
|
101
|
+
functions over multiple computers within a high performance computing (HPC) cluster. This can be either achieved by
|
|
102
|
+
submitting each function as individual job to the HPC job scheduler - [HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html) -
|
|
103
|
+
or by requesting a compute allocation of multiple nodes and then distribute the Python functions within this - allocation -
|
|
104
|
+
[HPC Allocation Mode](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html). Finally, to accelerate the
|
|
105
|
+
development process executorlib also provides a - [Local Mode](https://executorlib.readthedocs.io/en/latest/1-local.html) -
|
|
106
|
+
to use the executorlib functionality on a single workstation for testing. Starting with the [Local Mode](https://executorlib.readthedocs.io/en/latest/1-local.html)
|
|
107
|
+
set by setting the backend parameter to local - `backend="local"`:
|
|
108
|
+
```python
|
|
109
|
+
from executorlib import Executor
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
with Executor(backend="local") as exe:
|
|
113
|
+
future_lst = [exe.submit(sum, [i, i]) for i in range(1, 5)]
|
|
114
|
+
print([f.result() for f in future_lst])
|
|
115
|
+
```
|
|
116
|
+
In the same way executorlib can also execute Python functions which use additional computing resources, like multiple
|
|
117
|
+
CPU cores, CPU threads or GPUs. For example if the Python function internally uses the Message Passing Interface (MPI)
|
|
118
|
+
via the [mpi4py](https://mpi4py.readthedocs.io) Python libary:
|
|
119
|
+
```python
|
|
120
|
+
from executorlib import Executor
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def calc(i):
|
|
124
|
+
from mpi4py import MPI
|
|
125
|
+
|
|
126
|
+
size = MPI.COMM_WORLD.Get_size()
|
|
127
|
+
rank = MPI.COMM_WORLD.Get_rank()
|
|
128
|
+
return i, size, rank
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
with Executor(backend="local") as exe:
|
|
132
|
+
fs = exe.submit(calc, 3, resource_dict={"cores": 2})
|
|
133
|
+
print(fs.result())
|
|
134
|
+
```
|
|
135
|
+
The additional `resource_dict` parameter defines the computing resources allocated to the execution of the submitted
|
|
136
|
+
Python function. In addition to the compute cores `cores`, the resource dictionary can also define the threads per core
|
|
137
|
+
as `threads_per_core`, the GPUs per core as `gpus_per_core`, the working directory with `cwd`, the option to use the
|
|
138
|
+
OpenMPI oversubscribe feature with `openmpi_oversubscribe` and finally for the [Simple Linux Utility for Resource
|
|
139
|
+
Management (SLURM)](https://slurm.schedmd.com) queuing system the option to provide additional command line arguments
|
|
140
|
+
with the `slurm_cmd_args` parameter - [resource dictionary](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#resource-dictionary)
|
|
141
|
+
This flexibility to assign computing resources on a per-function-call basis simplifies the up-scaling of Python programs.
|
|
142
|
+
Only the part of the Python functions which benefit from parallel execution are implemented as MPI parallel Python
|
|
143
|
+
funtions, while the rest of the program remains serial.
|
|
144
|
+
|
|
145
|
+
The same function can be submitted to the [SLURM](https://slurm.schedmd.com) queuing by just changing the `backend`
|
|
146
|
+
parameter to `slurm_submission`. The rest of the example remains the same, which highlights how executorlib accelerates
|
|
147
|
+
the rapid prototyping and up-scaling of HPC Python programs.
|
|
148
|
+
```python
|
|
149
|
+
from executorlib import Executor
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def calc(i):
|
|
153
|
+
from mpi4py import MPI
|
|
154
|
+
|
|
155
|
+
size = MPI.COMM_WORLD.Get_size()
|
|
156
|
+
rank = MPI.COMM_WORLD.Get_rank()
|
|
157
|
+
return i, size, rank
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
with Executor(backend="slurm_submission") as exe:
|
|
161
|
+
fs = exe.submit(calc, 3, resource_dict={"cores": 2})
|
|
162
|
+
print(fs.result())
|
|
163
|
+
```
|
|
164
|
+
In this case the [Python simple queuing system adapter (pysqa)](https://pysqa.readthedocs.io) is used to submit the
|
|
165
|
+
`calc()` function to the [SLURM](https://slurm.schedmd.com) job scheduler and request an allocation with two CPU cores
|
|
166
|
+
for the execution of the function - [HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html). In the background the [sbatch](https://slurm.schedmd.com/sbatch.html)
|
|
167
|
+
command is used to request the allocation to execute the Python function.
|
|
168
|
+
|
|
169
|
+
Within a given [SLURM](https://slurm.schedmd.com) allocation executorlib can also be used to assign a subset of the
|
|
170
|
+
available computing resources to execute a given Python function. In terms of the [SLURM](https://slurm.schedmd.com)
|
|
171
|
+
commands, this functionality internally uses the [srun](https://slurm.schedmd.com/srun.html) command to receive a subset
|
|
172
|
+
of the resources of a given queuing system allocation.
|
|
173
|
+
```python
|
|
174
|
+
from executorlib import Executor
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def calc(i):
|
|
178
|
+
from mpi4py import MPI
|
|
179
|
+
|
|
180
|
+
size = MPI.COMM_WORLD.Get_size()
|
|
181
|
+
rank = MPI.COMM_WORLD.Get_rank()
|
|
182
|
+
return i, size, rank
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
with Executor(backend="slurm_allocation") as exe:
|
|
186
|
+
fs = exe.submit(calc, 3, resource_dict={"cores": 2})
|
|
187
|
+
print(fs.result())
|
|
188
|
+
```
|
|
189
|
+
In addition, to support for [SLURM](https://slurm.schedmd.com) executorlib also provides support for the hierarchical
|
|
190
|
+
[flux](http://flux-framework.org) job scheduler. The [flux](http://flux-framework.org) job scheduler is developed at
|
|
191
|
+
[Larwence Livermore National Laboratory](https://computing.llnl.gov/projects/flux-building-framework-resource-management)
|
|
192
|
+
to address the needs for the up-coming generation of Exascale computers. Still even on traditional HPC clusters the
|
|
193
|
+
hierarchical approach of the [flux](http://flux-framework.org) is beneficial to distribute hundreds of tasks within a
|
|
194
|
+
given allocation. Even when [SLURM](https://slurm.schedmd.com) is used as primary job scheduler of your HPC, it is
|
|
195
|
+
recommended to use [SLURM with flux](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html#slurm-with-flux)
|
|
196
|
+
as hierarchical job scheduler within the allocations.
|
|
197
|
+
|
|
198
|
+
## Documentation
|
|
199
|
+
* [Installation](https://executorlib.readthedocs.io/en/latest/installation.html)
|
|
200
|
+
* [Minimal](https://executorlib.readthedocs.io/en/latest/installation.html#minimal)
|
|
201
|
+
* [MPI Support](https://executorlib.readthedocs.io/en/latest/installation.html#mpi-support)
|
|
202
|
+
* [Caching](https://executorlib.readthedocs.io/en/latest/installation.html#caching)
|
|
203
|
+
* [HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/installation.html#hpc-submission-mode)
|
|
204
|
+
* [HPC Allocation Mode](https://executorlib.readthedocs.io/en/latest/installation.html#hpc-allocation-mode)
|
|
205
|
+
* [Visualisation](https://executorlib.readthedocs.io/en/latest/installation.html#visualisation)
|
|
206
|
+
* [For Developers](https://executorlib.readthedocs.io/en/latest/installation.html#for-developers)
|
|
207
|
+
* [Local Mode](https://executorlib.readthedocs.io/en/latest/1-local.html)
|
|
208
|
+
* [Basic Functionality](https://executorlib.readthedocs.io/en/latest/1-local.html#basic-functionality)
|
|
209
|
+
* [Parallel Functions](https://executorlib.readthedocs.io/en/latest/1-local.html#parallel-functions)
|
|
210
|
+
* [Performance Optimization](https://executorlib.readthedocs.io/en/latest/1-local.html#performance-optimization)
|
|
211
|
+
* [HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html)
|
|
212
|
+
* [SLURM](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html#slurm)
|
|
213
|
+
* [Flux](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html#flux)
|
|
214
|
+
* [HPC Allocation Mode](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html)
|
|
215
|
+
* [SLURM](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html#slurm)
|
|
216
|
+
* [SLURM with Flux](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html#slurm-with-flux)
|
|
217
|
+
* [Flux](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html#flux)
|
|
218
|
+
* [Trouble Shooting](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html)
|
|
219
|
+
* [Filesystem Usage](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#filesystem-usage)
|
|
220
|
+
* [Firewall Issues](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#firewall-issues)
|
|
221
|
+
* [Message Passing Interface](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#message-passing-interface)
|
|
222
|
+
* [Python Version](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#python-version)
|
|
223
|
+
* [Resource Dictionary](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#resource-dictionary)
|
|
224
|
+
* [SSH Connection](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#ssh-connection)
|
|
225
|
+
* [Developer](https://executorlib.readthedocs.io/en/latest/4-developer.html)
|
|
226
|
+
* [Communication](https://executorlib.readthedocs.io/en/latest/4-developer.html#communication)
|
|
227
|
+
* [External Executables](https://executorlib.readthedocs.io/en/latest/4-developer.html#external-executables)
|
|
228
|
+
* [License](https://executorlib.readthedocs.io/en/latest/4-developer.html#license)
|
|
229
|
+
* [Modules](https://executorlib.readthedocs.io/en/latest/4-developer.html#modules)
|
|
230
|
+
* [Interface](https://executorlib.readthedocs.io/en/latest/api.html)
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# executorlib
|
|
2
|
+
[](https://github.com/pyiron/executorlib/actions/workflows/unittest-openmpi.yml)
|
|
3
|
+
[](https://coveralls.io/github/pyiron/executorlib?branch=main)
|
|
4
|
+
[](https://mybinder.org/v2/gh/pyiron/executorlib/HEAD?labpath=notebooks%2Fexamples.ipynb)
|
|
5
|
+
|
|
6
|
+
Up-scale python functions for high performance computing (HPC) with executorlib.
|
|
7
|
+
|
|
8
|
+
## Key Features
|
|
9
|
+
* **Up-scale your Python functions beyond a single computer.** - executorlib extends the [Executor interface](https://docs.python.org/3/library/concurrent.futures.html#executor-objects)
|
|
10
|
+
from the Python standard library and combines it with job schedulers for high performance computing (HPC) including
|
|
11
|
+
the [Simple Linux Utility for Resource Management (SLURM)](https://slurm.schedmd.com) and [flux](http://flux-framework.org).
|
|
12
|
+
With this combination executorlib allows users to distribute their Python functions over multiple compute nodes.
|
|
13
|
+
* **Parallelize your Python program one function at a time** - executorlib allows users to assign dedicated computing
|
|
14
|
+
resources like CPU cores, threads or GPUs to one Python function call at a time. So you can accelerate your Python
|
|
15
|
+
code function by function.
|
|
16
|
+
* **Permanent caching of intermediate results to accelerate rapid prototyping** - To accelerate the development of
|
|
17
|
+
machine learning pipelines and simulation workflows executorlib provides optional caching of intermediate results for
|
|
18
|
+
iterative development in interactive environments like jupyter notebooks.
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
The Python standard library provides the [Executor interface](https://docs.python.org/3/library/concurrent.futures.html#executor-objects)
|
|
22
|
+
with the [ProcessPoolExecutor](https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor) and the
|
|
23
|
+
[ThreadPoolExecutor](https://docs.python.org/3/library/concurrent.futures.html#threadpoolexecutor) for parallel
|
|
24
|
+
execution of Python functions on a single computer. executorlib extends this functionality to distribute Python
|
|
25
|
+
functions over multiple computers within a high performance computing (HPC) cluster. This can be either achieved by
|
|
26
|
+
submitting each function as individual job to the HPC job scheduler - [HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html) -
|
|
27
|
+
or by requesting a compute allocation of multiple nodes and then distribute the Python functions within this - allocation -
|
|
28
|
+
[HPC Allocation Mode](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html). Finally, to accelerate the
|
|
29
|
+
development process executorlib also provides a - [Local Mode](https://executorlib.readthedocs.io/en/latest/1-local.html) -
|
|
30
|
+
to use the executorlib functionality on a single workstation for testing. Starting with the [Local Mode](https://executorlib.readthedocs.io/en/latest/1-local.html)
|
|
31
|
+
set by setting the backend parameter to local - `backend="local"`:
|
|
32
|
+
```python
|
|
33
|
+
from executorlib import Executor
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
with Executor(backend="local") as exe:
|
|
37
|
+
future_lst = [exe.submit(sum, [i, i]) for i in range(1, 5)]
|
|
38
|
+
print([f.result() for f in future_lst])
|
|
39
|
+
```
|
|
40
|
+
In the same way executorlib can also execute Python functions which use additional computing resources, like multiple
|
|
41
|
+
CPU cores, CPU threads or GPUs. For example if the Python function internally uses the Message Passing Interface (MPI)
|
|
42
|
+
via the [mpi4py](https://mpi4py.readthedocs.io) Python libary:
|
|
43
|
+
```python
|
|
44
|
+
from executorlib import Executor
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def calc(i):
|
|
48
|
+
from mpi4py import MPI
|
|
49
|
+
|
|
50
|
+
size = MPI.COMM_WORLD.Get_size()
|
|
51
|
+
rank = MPI.COMM_WORLD.Get_rank()
|
|
52
|
+
return i, size, rank
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
with Executor(backend="local") as exe:
|
|
56
|
+
fs = exe.submit(calc, 3, resource_dict={"cores": 2})
|
|
57
|
+
print(fs.result())
|
|
58
|
+
```
|
|
59
|
+
The additional `resource_dict` parameter defines the computing resources allocated to the execution of the submitted
|
|
60
|
+
Python function. In addition to the compute cores `cores`, the resource dictionary can also define the threads per core
|
|
61
|
+
as `threads_per_core`, the GPUs per core as `gpus_per_core`, the working directory with `cwd`, the option to use the
|
|
62
|
+
OpenMPI oversubscribe feature with `openmpi_oversubscribe` and finally for the [Simple Linux Utility for Resource
|
|
63
|
+
Management (SLURM)](https://slurm.schedmd.com) queuing system the option to provide additional command line arguments
|
|
64
|
+
with the `slurm_cmd_args` parameter - [resource dictionary](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#resource-dictionary)
|
|
65
|
+
This flexibility to assign computing resources on a per-function-call basis simplifies the up-scaling of Python programs.
|
|
66
|
+
Only the part of the Python functions which benefit from parallel execution are implemented as MPI parallel Python
|
|
67
|
+
funtions, while the rest of the program remains serial.
|
|
68
|
+
|
|
69
|
+
The same function can be submitted to the [SLURM](https://slurm.schedmd.com) queuing by just changing the `backend`
|
|
70
|
+
parameter to `slurm_submission`. The rest of the example remains the same, which highlights how executorlib accelerates
|
|
71
|
+
the rapid prototyping and up-scaling of HPC Python programs.
|
|
72
|
+
```python
|
|
73
|
+
from executorlib import Executor
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def calc(i):
|
|
77
|
+
from mpi4py import MPI
|
|
78
|
+
|
|
79
|
+
size = MPI.COMM_WORLD.Get_size()
|
|
80
|
+
rank = MPI.COMM_WORLD.Get_rank()
|
|
81
|
+
return i, size, rank
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
with Executor(backend="slurm_submission") as exe:
|
|
85
|
+
fs = exe.submit(calc, 3, resource_dict={"cores": 2})
|
|
86
|
+
print(fs.result())
|
|
87
|
+
```
|
|
88
|
+
In this case the [Python simple queuing system adapter (pysqa)](https://pysqa.readthedocs.io) is used to submit the
|
|
89
|
+
`calc()` function to the [SLURM](https://slurm.schedmd.com) job scheduler and request an allocation with two CPU cores
|
|
90
|
+
for the execution of the function - [HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html). In the background the [sbatch](https://slurm.schedmd.com/sbatch.html)
|
|
91
|
+
command is used to request the allocation to execute the Python function.
|
|
92
|
+
|
|
93
|
+
Within a given [SLURM](https://slurm.schedmd.com) allocation executorlib can also be used to assign a subset of the
|
|
94
|
+
available computing resources to execute a given Python function. In terms of the [SLURM](https://slurm.schedmd.com)
|
|
95
|
+
commands, this functionality internally uses the [srun](https://slurm.schedmd.com/srun.html) command to receive a subset
|
|
96
|
+
of the resources of a given queuing system allocation.
|
|
97
|
+
```python
|
|
98
|
+
from executorlib import Executor
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def calc(i):
|
|
102
|
+
from mpi4py import MPI
|
|
103
|
+
|
|
104
|
+
size = MPI.COMM_WORLD.Get_size()
|
|
105
|
+
rank = MPI.COMM_WORLD.Get_rank()
|
|
106
|
+
return i, size, rank
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
with Executor(backend="slurm_allocation") as exe:
|
|
110
|
+
fs = exe.submit(calc, 3, resource_dict={"cores": 2})
|
|
111
|
+
print(fs.result())
|
|
112
|
+
```
|
|
113
|
+
In addition, to support for [SLURM](https://slurm.schedmd.com) executorlib also provides support for the hierarchical
|
|
114
|
+
[flux](http://flux-framework.org) job scheduler. The [flux](http://flux-framework.org) job scheduler is developed at
|
|
115
|
+
[Larwence Livermore National Laboratory](https://computing.llnl.gov/projects/flux-building-framework-resource-management)
|
|
116
|
+
to address the needs for the up-coming generation of Exascale computers. Still even on traditional HPC clusters the
|
|
117
|
+
hierarchical approach of the [flux](http://flux-framework.org) is beneficial to distribute hundreds of tasks within a
|
|
118
|
+
given allocation. Even when [SLURM](https://slurm.schedmd.com) is used as primary job scheduler of your HPC, it is
|
|
119
|
+
recommended to use [SLURM with flux](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html#slurm-with-flux)
|
|
120
|
+
as hierarchical job scheduler within the allocations.
|
|
121
|
+
|
|
122
|
+
## Documentation
|
|
123
|
+
* [Installation](https://executorlib.readthedocs.io/en/latest/installation.html)
|
|
124
|
+
* [Minimal](https://executorlib.readthedocs.io/en/latest/installation.html#minimal)
|
|
125
|
+
* [MPI Support](https://executorlib.readthedocs.io/en/latest/installation.html#mpi-support)
|
|
126
|
+
* [Caching](https://executorlib.readthedocs.io/en/latest/installation.html#caching)
|
|
127
|
+
* [HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/installation.html#hpc-submission-mode)
|
|
128
|
+
* [HPC Allocation Mode](https://executorlib.readthedocs.io/en/latest/installation.html#hpc-allocation-mode)
|
|
129
|
+
* [Visualisation](https://executorlib.readthedocs.io/en/latest/installation.html#visualisation)
|
|
130
|
+
* [For Developers](https://executorlib.readthedocs.io/en/latest/installation.html#for-developers)
|
|
131
|
+
* [Local Mode](https://executorlib.readthedocs.io/en/latest/1-local.html)
|
|
132
|
+
* [Basic Functionality](https://executorlib.readthedocs.io/en/latest/1-local.html#basic-functionality)
|
|
133
|
+
* [Parallel Functions](https://executorlib.readthedocs.io/en/latest/1-local.html#parallel-functions)
|
|
134
|
+
* [Performance Optimization](https://executorlib.readthedocs.io/en/latest/1-local.html#performance-optimization)
|
|
135
|
+
* [HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html)
|
|
136
|
+
* [SLURM](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html#slurm)
|
|
137
|
+
* [Flux](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html#flux)
|
|
138
|
+
* [HPC Allocation Mode](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html)
|
|
139
|
+
* [SLURM](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html#slurm)
|
|
140
|
+
* [SLURM with Flux](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html#slurm-with-flux)
|
|
141
|
+
* [Flux](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html#flux)
|
|
142
|
+
* [Trouble Shooting](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html)
|
|
143
|
+
* [Filesystem Usage](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#filesystem-usage)
|
|
144
|
+
* [Firewall Issues](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#firewall-issues)
|
|
145
|
+
* [Message Passing Interface](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#message-passing-interface)
|
|
146
|
+
* [Python Version](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#python-version)
|
|
147
|
+
* [Resource Dictionary](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#resource-dictionary)
|
|
148
|
+
* [SSH Connection](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#ssh-connection)
|
|
149
|
+
* [Developer](https://executorlib.readthedocs.io/en/latest/4-developer.html)
|
|
150
|
+
* [Communication](https://executorlib.readthedocs.io/en/latest/4-developer.html#communication)
|
|
151
|
+
* [External Executables](https://executorlib.readthedocs.io/en/latest/4-developer.html#external-executables)
|
|
152
|
+
* [License](https://executorlib.readthedocs.io/en/latest/4-developer.html#license)
|
|
153
|
+
* [Modules](https://executorlib.readthedocs.io/en/latest/4-developer.html#modules)
|
|
154
|
+
* [Interface](https://executorlib.readthedocs.io/en/latest/api.html)
|