Multiclass-interface 1.2__py3-none-any.whl → 1.3__py3-none-any.whl
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.
- {Multiclass_interface-1.2.dist-info → Multiclass_interface-1.3.dist-info}/METADATA +1 -1
- {Multiclass_interface-1.2.dist-info → Multiclass_interface-1.3.dist-info}/RECORD +8 -8
- multiclass_interface/mpi_interface.py +19 -11
- multiclass_interface/tests/test_mpi.py +22 -4
- multiclass_interface/version.py +2 -2
- {Multiclass_interface-1.2.dist-info → Multiclass_interface-1.3.dist-info}/LICENSE +0 -0
- {Multiclass_interface-1.2.dist-info → Multiclass_interface-1.3.dist-info}/WHEEL +0 -0
- {Multiclass_interface-1.2.dist-info → Multiclass_interface-1.3.dist-info}/top_level.txt +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
multiclass_interface/__init__.py,sha256=1kI9Vxsap_8eap6kldNHhIWLEVBT2DLWl2UbTOTnVN0,114
|
|
2
|
-
multiclass_interface/mpi_interface.py,sha256=
|
|
2
|
+
multiclass_interface/mpi_interface.py,sha256=r5SHfPTCjdWPN-f67TSRSCKK_u-PR04XuRQm5QuVpQ8,6088
|
|
3
3
|
multiclass_interface/multi_object_list.py,sha256=GmLKWUsu9Vf3Qcy7SlhxqPW_yDw2pzo2EFkkF8R94Dg,2022
|
|
4
4
|
multiclass_interface/multiprocess_interface.py,sha256=S0gO9u4mQrbhpxarKMD0i7M35EVC9vaKjp3Ls4Y26KU,8169
|
|
5
|
-
multiclass_interface/version.py,sha256=
|
|
5
|
+
multiclass_interface/version.py,sha256=7O1PGoJcqqJmSLSLxWC8nLMMOiyBtDvjEB-_j8t9ZkU,406
|
|
6
6
|
multiclass_interface/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
multiclass_interface/tests/my_test_cls.py,sha256=KDcM0zcwwFAcXJhHdl0KHd45MaqHvR8mxHdoUqmbC_E,826
|
|
8
|
-
multiclass_interface/tests/test_mpi.py,sha256=
|
|
8
|
+
multiclass_interface/tests/test_mpi.py,sha256=owgXwmZCBVO5OuvfLMw8CfBwf1-AnkUzEMf-K8w_mvc,2826
|
|
9
9
|
multiclass_interface/tests/test_multiclass_list.py,sha256=W7w5wiA3-_wgL9lOCRDsCijikJiHVrp5RqBYwJzWxp4,515
|
|
10
10
|
multiclass_interface/tests/test_multiprocessinterface.py,sha256=u2BVzoq7YB7L4jwKiveyQheCgQ2O7CGg5nQl9M1rTzM,3165
|
|
11
|
-
Multiclass_interface-1.
|
|
12
|
-
Multiclass_interface-1.
|
|
13
|
-
Multiclass_interface-1.
|
|
14
|
-
Multiclass_interface-1.
|
|
15
|
-
Multiclass_interface-1.
|
|
11
|
+
Multiclass_interface-1.3.dist-info/LICENSE,sha256=oApPkWzMlqIJF9EOB2gV6yvdsm6a2-AW94wuayHIz70,1094
|
|
12
|
+
Multiclass_interface-1.3.dist-info/METADATA,sha256=7X0ixA52VcgeabWazLe7K75XoSX6nuzj2Zv6BdUen6Q,1580
|
|
13
|
+
Multiclass_interface-1.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
14
|
+
Multiclass_interface-1.3.dist-info/top_level.txt,sha256=LOL3xjSUkjW6thjDr0IMvgkitnbsNokahxl-HjgOJG4,21
|
|
15
|
+
Multiclass_interface-1.3.dist-info/RECORD,,
|
|
@@ -35,6 +35,7 @@ MPIClassInterfaceAttributes = {
|
|
|
35
35
|
|
|
36
36
|
LOOP_UNTIL_CLOSE = True
|
|
37
37
|
TERMINATE_ON_CLOSE = True
|
|
38
|
+
COLLECTIVE_MPI = True
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
class MPIClassInterface():
|
|
@@ -53,10 +54,9 @@ class MPIClassInterface():
|
|
|
53
54
|
self.object = Dummy()
|
|
54
55
|
self.closed = False
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
elif LOOP_UNTIL_CLOSE:
|
|
57
|
+
self.use_rank = np.array([True] * size)
|
|
58
|
+
self.use_rank[len(args_lst):] = False
|
|
59
|
+
if rank > 0 and COLLECTIVE_MPI and LOOP_UNTIL_CLOSE:
|
|
60
60
|
self.work_loop()
|
|
61
61
|
|
|
62
62
|
def __enter__(self):
|
|
@@ -133,13 +133,18 @@ class MPIClassInterface():
|
|
|
133
133
|
def __getattribute__(self, name):
|
|
134
134
|
if name in MPIClassInterfaceAttributes:
|
|
135
135
|
return object.__getattribute__(self, name)
|
|
136
|
-
elif rank > 0:
|
|
136
|
+
elif COLLECTIVE_MPI and rank > 0:
|
|
137
137
|
self.work_loop()
|
|
138
138
|
return lambda *args, **kwargs: 1
|
|
139
|
+
elif not self.use_rank[rank]:
|
|
140
|
+
raise ChildProcessError('MPI worker not used')
|
|
139
141
|
|
|
140
142
|
def wrap(*args, **kwargs):
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
if COLLECTIVE_MPI:
|
|
144
|
+
inp = [self.get_input(name, i, args, kwargs) for i in range(size)]
|
|
145
|
+
return self.run_task(inp)
|
|
146
|
+
else:
|
|
147
|
+
return self.do_task(name, args, kwargs)
|
|
143
148
|
|
|
144
149
|
if hasattr(getattr(self.object, name), '__call__'):
|
|
145
150
|
return wrap
|
|
@@ -162,11 +167,14 @@ class MPIClassInterface():
|
|
|
162
167
|
|
|
163
168
|
def close(self):
|
|
164
169
|
if not self.closed:
|
|
165
|
-
if
|
|
166
|
-
|
|
170
|
+
if COLLECTIVE_MPI:
|
|
171
|
+
if rank == 0:
|
|
172
|
+
res = self.run_task([('close', [], {}) for _ in range(size)])
|
|
173
|
+
else:
|
|
174
|
+
self.work_loop()
|
|
175
|
+
res = None
|
|
167
176
|
else:
|
|
168
|
-
self.
|
|
169
|
-
res = None
|
|
177
|
+
res = self.do_task('close', [], {})
|
|
170
178
|
self.closed = True
|
|
171
179
|
|
|
172
180
|
|
|
@@ -42,11 +42,28 @@ def mpitest_mpi_ProcessClass():
|
|
|
42
42
|
with ProcessClass(MyTest) as cls:
|
|
43
43
|
myTest = cls(1)
|
|
44
44
|
assert myTest.get_id() == 1
|
|
45
|
-
print("done, test_mpi_ProcessClass")
|
|
45
|
+
print("done, test_mpi_ProcessClass", flush=True)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def mpitest_non_collective_mpi():
|
|
49
|
+
mpi_interface.COLLECTIVE_MPI = False
|
|
50
|
+
rank = mpi_interface.rank
|
|
51
|
+
import time
|
|
52
|
+
N = 3
|
|
53
|
+
with MPIClassInterface(MyTest, [(i + 10,) for i in range(N)]) as m:
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
assert m.get_id() == rank + 10
|
|
57
|
+
assert rank < N # rank > N will fail with ChildProcessError
|
|
58
|
+
except ChildProcessError:
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
mpi_interface.COLLECTIVE_MPI = True
|
|
46
62
|
|
|
47
63
|
|
|
48
64
|
def mpitest_all():
|
|
49
65
|
mpi_interface.activate_mpi()
|
|
66
|
+
|
|
50
67
|
mpi_interface.exit_mpi_on_close = False
|
|
51
68
|
rank = mpi_interface.rank
|
|
52
69
|
from multiclass_interface.tests.test_multiprocessinterface import test_attribute, test_missing_attribute, test_execption, test_setattr, test_setattr_method
|
|
@@ -67,13 +84,14 @@ def mpitest_all():
|
|
|
67
84
|
run(f)
|
|
68
85
|
|
|
69
86
|
try:
|
|
70
|
-
with MPIClassInterface(MyTest, [(1,), (2,)]) as mpici:
|
|
87
|
+
with MPIClassInterface(MyTest, [(1,), (2,), (3,)]) as mpici:
|
|
71
88
|
for f in [test_attribute, test_missing_attribute, test_execption, test_setattr, test_setattr_method]:
|
|
72
|
-
|
|
89
|
+
|
|
73
90
|
run(f, mpici)
|
|
74
91
|
|
|
75
92
|
except ChildProcessError:
|
|
76
93
|
pass
|
|
77
|
-
|
|
94
|
+
|
|
95
|
+
run(mpitest_non_collective_mpi)
|
|
78
96
|
|
|
79
97
|
print(f"Rank {rank} Done test_all")
|
multiclass_interface/version.py
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|