Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into broker_class
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/test_meta.py
#	tests/test_task.py
  • Loading branch information
jan-janssen committed Feb 19, 2024
2 parents b314883 + a1feb9f commit 8efdaac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/unittest-flux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ jobs:
mamba install -y flux-core=0.58.0 coverage
pip install versioneer[toml]==0.29
pip install . --no-deps --no-build-isolation
cd tests
coverage run --omit="pympipool/_version.py,test_*" -m unittest discover .
coverage run -a --omit="pympipool/_version.py,tests/*" -m unittest discover tests
env:
OMPI_MCA_plm: 'isolated'
OMPI_MCA_rmaps_base_oversubscribe: 'yes'
Expand All @@ -56,7 +55,7 @@ jobs:
timeout-minutes: 5
run: >
flux start
coverage run --omit="pympipool/_version.py,tests/*" -m unittest tests/test_flux.py;
coverage run -a --omit="pympipool/_version.py,tests/*" -m unittest tests/test_flux.py;
env:
OMPI_MCA_plm: 'isolated'
OMPI_MCA_rmaps_base_oversubscribe: 'yes'
Expand Down
4 changes: 4 additions & 0 deletions tests/test_meta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from pympipool.mpi.executor import PyMPIExecutor
from pympipool.shared.executorbase import cloudpickle_register


def calc(i):
Expand All @@ -17,6 +18,7 @@ def mpi_funct(i):
class TestMetaExecutor(unittest.TestCase):
def test_meta_executor_serial(self):
with PyMPIExecutor(max_workers=2, hostname_localhost=True) as exe:
cloudpickle_register(ind=1)
fs_1 = exe.submit(calc, 1)
fs_2 = exe.submit(calc, 2)
self.assertEqual(fs_1.result(), 1)
Expand All @@ -26,6 +28,7 @@ def test_meta_executor_serial(self):

def test_meta_executor_single(self):
with PyMPIExecutor(max_workers=1, hostname_localhost=True) as exe:
cloudpickle_register(ind=1)
fs_1 = exe.submit(calc, 1)
fs_2 = exe.submit(calc, 2)
self.assertEqual(fs_1.result(), 1)
Expand All @@ -35,6 +38,7 @@ def test_meta_executor_single(self):

def test_meta_executor_parallel(self):
with PyMPIExecutor(max_workers=1, cores_per_worker=2, hostname_localhost=True) as exe:
cloudpickle_register(ind=1)
fs_1 = exe.submit(mpi_funct, 1)
self.assertEqual(fs_1.result(), [(1, 2, 0), (1, 2, 1)])
self.assertTrue(fs_1.done())
Expand Down
4 changes: 4 additions & 0 deletions tests/test_task.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from pympipool.mpi.executor import PyMPIExecutor
from pympipool.shared.executorbase import cloudpickle_register


def echo_funct(i):
Expand All @@ -17,16 +18,19 @@ def mpi_funct(i):
class TestTask(unittest.TestCase):
def test_echo(self):
with PyMPIExecutor(max_workers=1, cores_per_worker=2, hostname_localhost=True) as p:
cloudpickle_register(ind=1)
output = p.submit(echo_funct, 2).result()
self.assertEqual(output, [2, 2])

def test_mpi(self):
with PyMPIExecutor(max_workers=1, cores_per_worker=2, hostname_localhost=True) as p:
cloudpickle_register(ind=1)
output = p.submit(mpi_funct, 2).result()
self.assertEqual(output, [(2, 2, 0), (2, 2, 1)])

def test_mpi_multiple(self):
with PyMPIExecutor(max_workers=1, cores_per_worker=2, hostname_localhost=True) as p:
cloudpickle_register(ind=1)
fs1 = p.submit(mpi_funct, 1)
fs2 = p.submit(mpi_funct, 2)
fs3 = p.submit(mpi_funct, 3)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_with_dynamic_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import unittest

from pympipool import Executor
from pympipool.shared.executorbase import cloudpickle_register


class Foo:
Expand Down Expand Up @@ -76,6 +77,7 @@ def slowly_returns_dynamic(dynamic_arg):

dynamic_dynamic = slowly_returns_dynamic()
executor = Executor(hostname_localhost=True)
cloudpickle_register(ind=1)
dynamic_object = does_nothing()
fs = executor.submit(dynamic_dynamic.run, dynamic_object)
self.assertEqual(
Expand Down Expand Up @@ -108,6 +110,7 @@ def slowly_returns_42():
msg="Just a sanity check that the test is set up right"
)
executor = Executor(hostname_localhost=True)
cloudpickle_register(ind=1)
fs = executor.submit(dynamic_42.run)
fs.add_done_callback(dynamic_42.process_result)
self.assertFalse(
Expand Down Expand Up @@ -140,6 +143,7 @@ def returns_42():
msg="Sanity check that the test starts in the expected condition"
)
executor = Executor(hostname_localhost=True)
cloudpickle_register(ind=1)
fs = executor.submit(dynamic_42.run)
fs.add_done_callback(dynamic_42.process_result)
self.assertTrue(
Expand All @@ -163,6 +167,7 @@ def raise_error():

re = raise_error()
executor = Executor(hostname_localhost=True)
cloudpickle_register(ind=1)
fs = executor.submit(re.run)
with self.assertRaises(
RuntimeError,
Expand Down Expand Up @@ -192,6 +197,7 @@ def slowly_returns_dynamic():

dynamic_dynamic = slowly_returns_dynamic()
executor = Executor(hostname_localhost=True)
cloudpickle_register(ind=1)
fs = executor.submit(dynamic_dynamic.run)
self.assertIsInstance(
fs.result(),
Expand Down Expand Up @@ -220,6 +226,7 @@ def slow():

f = slow()
executor = Executor(hostname_localhost=True)
cloudpickle_register(ind=1)
fs = executor.submit(f.run)
self.assertEqual(
fs.result(timeout=30),
Expand Down

0 comments on commit 8efdaac

Please sign in to comment.