Multiclass-interface 1.18__tar.gz → 1.20__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.
Files changed (26) hide show
  1. {multiclass_interface-1.18 → multiclass_interface-1.20}/.gitlab-ci.yml +3 -3
  2. {multiclass_interface-1.18 → multiclass_interface-1.20/Multiclass_interface.egg-info}/PKG-INFO +1 -1
  3. multiclass_interface-1.20/Multiclass_interface.egg-info/scm_version.json +8 -0
  4. {multiclass_interface-1.18/Multiclass_interface.egg-info → multiclass_interface-1.20}/PKG-INFO +1 -1
  5. {multiclass_interface-1.18 → multiclass_interface-1.20}/multiclass_interface/mpi_interface.py +17 -16
  6. {multiclass_interface-1.18 → multiclass_interface-1.20}/multiclass_interface/tests/test_mpi.py +30 -4
  7. {multiclass_interface-1.18 → multiclass_interface-1.20}/multiclass_interface/version.py +3 -3
  8. multiclass_interface-1.18/Multiclass_interface.egg-info/scm_version.json +0 -8
  9. {multiclass_interface-1.18 → multiclass_interface-1.20}/.gitignore +0 -0
  10. {multiclass_interface-1.18 → multiclass_interface-1.20}/LICENSE +0 -0
  11. {multiclass_interface-1.18 → multiclass_interface-1.20}/Multiclass_interface.egg-info/SOURCES.txt +0 -0
  12. {multiclass_interface-1.18 → multiclass_interface-1.20}/Multiclass_interface.egg-info/dependency_links.txt +0 -0
  13. {multiclass_interface-1.18 → multiclass_interface-1.20}/Multiclass_interface.egg-info/requires.txt +0 -0
  14. {multiclass_interface-1.18 → multiclass_interface-1.20}/Multiclass_interface.egg-info/scm_file_list.json +0 -0
  15. {multiclass_interface-1.18 → multiclass_interface-1.20}/Multiclass_interface.egg-info/top_level.txt +0 -0
  16. {multiclass_interface-1.18 → multiclass_interface-1.20}/README.md +0 -0
  17. {multiclass_interface-1.18 → multiclass_interface-1.20}/multiclass_interface/__init__.py +0 -0
  18. {multiclass_interface-1.18 → multiclass_interface-1.20}/multiclass_interface/multi_object_list.py +0 -0
  19. {multiclass_interface-1.18 → multiclass_interface-1.20}/multiclass_interface/multiprocess_interface.py +0 -0
  20. {multiclass_interface-1.18 → multiclass_interface-1.20}/multiclass_interface/tests/__init__.py +0 -0
  21. {multiclass_interface-1.18 → multiclass_interface-1.20}/multiclass_interface/tests/my_test_cls.py +0 -0
  22. {multiclass_interface-1.18 → multiclass_interface-1.20}/multiclass_interface/tests/test_multiclass_list.py +0 -0
  23. {multiclass_interface-1.18 → multiclass_interface-1.20}/multiclass_interface/tests/test_multiprocessinterface.py +0 -0
  24. {multiclass_interface-1.18 → multiclass_interface-1.20}/pyproject.toml +0 -0
  25. {multiclass_interface-1.18 → multiclass_interface-1.20}/sequence_diagrams.md +0 -0
  26. {multiclass_interface-1.18 → multiclass_interface-1.20}/setup.cfg +0 -0
@@ -15,7 +15,7 @@ test_mpitest_openmpi:
15
15
  - if: $CI_COMMIT_BRANCH == "main"
16
16
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
17
17
  tags:
18
- - ci-ubuntu
18
+ - docker,ubuntu,linux,shared
19
19
 
20
20
 
21
21
  # ===== Check code style =====
@@ -26,7 +26,7 @@ check_code_style: # name the job what we like
26
26
  - pip install -e . --user
27
27
  - pycodestyle --ignore=E501,W504,E741 multiclass_interface
28
28
  tags: # only runners with this tag can do the job [3]
29
- - ci-ubuntu
29
+ - docker,ubuntu,linux,shared
30
30
  rules:
31
31
  - if: $CI_COMMIT_BRANCH == "main"
32
32
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
@@ -52,4 +52,4 @@ pypi_linux:
52
52
  allow_failure: true
53
53
  - when: never
54
54
  tags:
55
- - ci-ubuntu
55
+ - docker,ubuntu,linux,shared
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Multiclass_interface
3
- Version: 1.18
3
+ Version: 1.20
4
4
  Summary: Multiclass interface
5
5
  Author-email: "Mads M. Pedersen" <mmpe@dtu.dk>
6
6
  Project-URL: Homepage, https://gitlab.windenergy.dtu.dk/DYNAMIKS/multiclass_interface
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "1.20",
3
+ "distance": 0,
4
+ "node": "g3db3816fe0890a14fa9c4ef6512022e342553b3e",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-10-30"
8
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Multiclass_interface
3
- Version: 1.18
3
+ Version: 1.20
4
4
  Summary: Multiclass interface
5
5
  Author-email: "Mads M. Pedersen" <mmpe@dtu.dk>
6
6
  Project-URL: Homepage, https://gitlab.windenergy.dtu.dk/DYNAMIKS/multiclass_interface
@@ -7,6 +7,7 @@ import shutil
7
7
  import sys
8
8
  import traceback
9
9
  from contextlib import contextmanager
10
+ import contextlib
10
11
 
11
12
  comm = None
12
13
  size = 1
@@ -258,7 +259,10 @@ def bcast_function_result(f):
258
259
  def wrapper(*args, **kwargs):
259
260
  if mpi:
260
261
  try:
261
- v = f(*args, **kwargs)[0]
262
+ v = f(*args, **kwargs)
263
+ if not isinstance(v, list):
264
+ v = [v]
265
+ v = v[0]
262
266
  except ChildProcessError:
263
267
  v = None
264
268
 
@@ -267,7 +271,10 @@ def bcast_function_result(f):
267
271
  # broadcast the full list to all workers
268
272
  return comm.bcast(v, root=0)
269
273
  else:
270
- return f(*args, **kwargs)
274
+ v = f(*args, **kwargs)
275
+ if not isinstance(v, list):
276
+ v = [v]
277
+ return v
271
278
  return wrapper
272
279
 
273
280
 
@@ -284,21 +291,15 @@ def mpi_run_test(n, cwd='.', mpirun_cmd='mpirun'):
284
291
  name = test_function.__name__
285
292
 
286
293
  def wrap(mpirun=False):
287
- cwd = os.getcwd()
288
- try:
289
- if mpirun:
290
- os.chdir(cwd)
294
+ if mpirun:
295
+ with contextlib.chdir(cwd):
291
296
  return test_function()
292
- else:
293
-
294
- import_path = Path(inspect.getsourcefile(test_function)).relative_to(os.getcwd()).as_posix()
295
- import_path = import_path[:-3].replace('/', '.')
296
- cmd = f'''{mpirun_cmd} -n {n} {sys.executable} -c "from {import_path} import {name}; {name}(mpirun=True)"'''
297
- print(f"cd {os.getcwd()} && {cmd}", flush=True)
298
- assert os.system(cmd) == 0, name
299
-
300
- finally:
301
- os.chdir(cwd)
297
+ else:
298
+ import_path = Path(inspect.getsourcefile(test_function)).relative_to(os.getcwd()).as_posix()
299
+ import_path = import_path[:-3].replace('/', '.')
300
+ cmd = f'''{mpirun_cmd} -n {n} {sys.executable} -c "from {import_path} import {name}; {name}(mpirun=True)"'''
301
+ print(f"cd {os.getcwd()} && {cmd}", flush=True)
302
+ assert os.system(cmd) == 0, name
302
303
 
303
304
  wrap.__name__ = name
304
305
  return wrap
@@ -145,14 +145,40 @@ def test_non_collective_mpi2():
145
145
  m.object.cls
146
146
 
147
147
 
148
- def test_non_collective_mpi2_no_mpi():
149
- N = 3
148
+ @pytest.mark.parametrize('N', [1, 3])
149
+ def test_bcast_function_result_mci(N):
150
150
  with MultiClassInterface(MyTest, [(i + 10,) for i in range(N)]) as m:
151
151
 
152
152
  id_lst = mpi_interface.bcast_function_result(lambda: m.get_id())()
153
- assert id_lst == [10, 11, 12], id_lst
153
+ assert id_lst == [10, 11, 12][:N], id_lst
154
+ id_lst = mpi_interface.bcast_function_result(lambda: m.return_input(['a', 'b', 'c'][:N]))()
155
+ assert id_lst == ["10 got: ('a',) and {}", "11 got: ('b',) and {}", "12 got: ('c',) and {}"][:N], id_lst
156
+
157
+ assert mpi_interface.bcast_function_result(lambda: 0)() == [0]
158
+
159
+
160
+ @mpi_run_test
161
+ def test_bcast_function_result_mpi1():
162
+ mpi_interface.activate_mpi(collective_mpi=False)
163
+ with MPIClassInterface(MyTest, [(i + 10,) for i in range(1)]) as m:
164
+ id_lst = mpi_interface.bcast_function_result(lambda: m.get_id())()
165
+ assert id_lst == [10, None, None, None], id_lst
166
+ id_lst = mpi_interface.bcast_function_result(lambda: m.return_input(['a']))()
167
+ assert id_lst == ["10 got: ('a',) and {}", None, None, None], id_lst
168
+
169
+ assert mpi_interface.bcast_function_result(lambda: mpi_interface.rank)() == [0, 1, 2, 3]
170
+
171
+
172
+ @mpi_run_test
173
+ def test_bcast_function_result_mpi3():
174
+ mpi_interface.activate_mpi(collective_mpi=False)
175
+ with MPIClassInterface(MyTest, [(i + 10,) for i in range(3)]) as m:
176
+ id_lst = mpi_interface.bcast_function_result(lambda: m.get_id())()
177
+ assert id_lst == [10, 11, 12, None], id_lst
154
178
  id_lst = mpi_interface.bcast_function_result(lambda: m.return_input(['a', 'b', 'c']))()
155
- assert id_lst == ["10 got: ('a',) and {}", "11 got: ('b',) and {}", "12 got: ('c',) and {}"], id_lst
179
+ assert id_lst == ["10 got: ('a',) and {}", "11 got: ('b',) and {}", "12 got: ('c',) and {}", None], id_lst
180
+
181
+ assert mpi_interface.bcast_function_result(lambda: mpi_interface.rank)() == [0, 1, 2, 3]
156
182
 
157
183
 
158
184
  @mpi_run_test(4)
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '1.18'
22
- __version_tuple__ = version_tuple = (1, 18)
21
+ __version__ = version = '1.20'
22
+ __version_tuple__ = version_tuple = (1, 20)
23
23
 
24
- __commit_id__ = commit_id = 'gb93401984'
24
+ __commit_id__ = commit_id = 'g3db3816fe'
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "1.18",
3
- "distance": 0,
4
- "node": "gb934019843ac9640a5beae7880add16d3c7e3838",
5
- "dirty": false,
6
- "branch": "HEAD",
7
- "node_date": "2026-10-23"
8
- }