Skip to content

Commit 160aef2

Browse files
move to src layout. remove get_bridge_instance.
1 parent e249347 commit 160aef2

File tree

6 files changed

+22
-38
lines changed

6 files changed

+22
-38
lines changed

setup.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
import os
3131

32-
from setuptools import setup
32+
from setuptools import setup, find_packages
3333

3434

3535
def find_version(*file_paths):
@@ -51,7 +51,7 @@ def readme():
5151
return f.read()
5252

5353

54-
version = find_version("deisa", "__version__.py")
54+
version = find_version("src/deisa/dask", "__version__.py")
5555

5656
setup(name='deisa',
5757
version=version,
@@ -74,14 +74,21 @@ def readme():
7474

7575
keywords='deisa in-situ',
7676

77-
packages=['deisa'],
77+
package_dir={'': 'src'},
78+
packages=find_packages(where="src"),
7879

7980
install_requires=[
80-
"dask",
81+
'dask',
8182
'distributed'
8283
],
8384

84-
tests_require=["pytest", "numpy"],
85+
extras_require={
86+
"test": [
87+
"pytest",
88+
"numpy",
89+
"deisa-common @ git+https://github.com/deisa-project/common@main"
90+
]
91+
},
8592
test_suite='test',
8693

8794
classifiers=[
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# SPDX-License-Identifier: MIT
44
###################################################################################################
55

6-
from deisa.deisa import *
6+
from .deisa import *

deisa/deisa.py renamed to src/deisa/dask/deisa.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,6 @@
4444
from distributed import Client, Future
4545

4646

47-
def get_bridge_instance(dask_scheduler_address: str | Client, mpi_comm_size: int, mpi_rank: int,
48-
arrays_metadata: dict[str, dict], **kwargs):
49-
"""
50-
Get an instance of the Bridge class to establish a connection between MPI and Dask.
51-
52-
This function facilitates the creation of a `Bridge` instance that acts as
53-
a communication layer between the MPI processes and the Dask scheduler. It
54-
requires MPI-related parameters, Dask scheduler address, and metadata about
55-
the arrays being utilized.
56-
57-
:param dask_scheduler_address: Address of the Dask scheduler or an instance
58-
of dask.distributed.Client to connect to.
59-
:param mpi_comm_size: Size of the MPI communicator.
60-
:param mpi_rank: Rank of the MPI process within the communicator.
61-
:param arrays_metadata: Metadata for arrays managed in the bridge. It should
62-
indicate characteristics and configuration details about the arrays.
63-
:param kwargs: Additional optional arguments to configure the Bridge instance.
64-
:return: An instance of Bridge configured to mediate communication between MPI
65-
and Dask.
66-
"""
67-
return Bridge(dask_scheduler_address, mpi_comm_size, mpi_rank, arrays_metadata, **kwargs)
68-
69-
7047
class Bridge:
7148
def __init__(self, dask_scheduler_address: str | Client, mpi_comm_size: int, mpi_rank: int,
7249
arrays_metadata: dict[str, dict], **kwargs):
@@ -163,7 +140,7 @@ def publish_data(self, array_name: str, data: np.ndarray, iteration: int):
163140
# TODO: what to do if error ?
164141

165142

166-
class Deisa(object):
143+
class Deisa:
167144
SLIDING_WINDOW_THREAD_PREFIX = "deisa_sliding_window_callback_"
168145

169146
def __init__(self, dask_scheduler_address: str | Client, mpi_comm_size: int, nb_workers: int):

test/TestSimulator.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2727
# POSSIBILITY OF SUCH DAMAGE.
2828
# =============================================================================
29+
2930
import numpy as np
31+
from deisa.common import BridgeInterface
32+
from deisa.dask import Bridge
3033
from distributed import Client
3134

32-
from deisa import get_bridge_instance
33-
3435

3536
class TestSimulation:
3637
__test__ = False
@@ -47,8 +48,8 @@ def __init__(self, client: Client, global_grid_size: tuple, mpi_parallelism: tup
4748
assert global_grid_size[1] % mpi_parallelism[1] == 0, "cannot compute local grid size for y dimension"
4849

4950
self.nb_mpi_ranks = mpi_parallelism[0] * mpi_parallelism[1]
50-
self.bridges = [get_bridge_instance(client, self.nb_mpi_ranks, rank, arrays_metadata) for rank in
51-
range(self.nb_mpi_ranks)]
51+
self.bridges: list[BridgeInterface] = [Bridge(client, self.nb_mpi_ranks, rank, arrays_metadata) for rank in
52+
range(self.nb_mpi_ranks)]
5253

5354
def __gen_data(self, noise_level: int = 0) -> np.ndarray:
5455
# Create coordinate grid

test/test_deisa.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from distributed import Client, LocalCluster, Queue, Variable
4040

4141
from TestSimulator import TestSimulation
42-
from deisa.deisa import Deisa
42+
from deisa.dask import Deisa
4343

4444

4545
@pytest.mark.parametrize('global_shape', [(32, 32), (32, 16), (16, 32)])
@@ -155,7 +155,7 @@ def test_deisa_ctor_scheduler_file_error(self):
155155

156156

157157
class TestUsingDaskCluster:
158-
@pytest.fixture(scope="class")
158+
@pytest.fixture(scope="function")
159159
def env_setup(self):
160160
cluster = LocalCluster(n_workers=2, threads_per_worker=1, processes=False)
161161
client = Client(cluster)
@@ -240,7 +240,6 @@ def test_get_dask_array(self, global_grid_size: tuple, mpi_parallelism: tuple, n
240240

241241
client, cluster = env_setup
242242

243-
scheduler_address = cluster.scheduler_address
244243
nb_mpi_ranks = mpi_parallelism[0] * mpi_parallelism[1]
245244
nb_workers = len(cluster.workers)
246245

@@ -485,7 +484,7 @@ def window_callback(window: list[da.Array], timestep: int):
485484

486485
def exception_handler(array_name, e):
487486
print(f"exception_handler. array_name={array_name}, e={e}", flush=True, file=sys.stderr)
488-
# pytest.fail(str(e))
487+
# pytest.fail(str(e)) # TODO
489488

490489
deisa.register_sliding_window_callback("my_array", window_callback,
491490
window_size=1,

0 commit comments

Comments
 (0)