diff --git a/src/appose/__init__.py b/src/appose/__init__.py index 93c44c3..db1141a 100644 --- a/src/appose/__init__.py +++ b/src/appose/__init__.py @@ -134,6 +134,7 @@ def task_listener(event): from pathlib import Path from .environment import Builder, Environment +from .types import NDArray, SharedMemory # noqa: F401 def base(directory: Path) -> Builder: diff --git a/tests/test_shm.py b/tests/test_shm.py index e77e86f..965e398 100644 --- a/tests/test_shm.py +++ b/tests/test_shm.py @@ -27,11 +27,8 @@ # #L% ### -from multiprocessing.shared_memory import SharedMemory - import appose from appose.service import TaskStatus -from appose.types import NDArray ndarray_inspect = """ task.outputs["size"] = data.shm.size @@ -45,11 +42,11 @@ def test_ndarray(): env = appose.system() with env.python() as service: # Construct the data. - shm = SharedMemory(create=True, size=2 * 2 * 20 * 25) + shm = appose.SharedMemory(create=True, size=2 * 2 * 20 * 25) shm.buf[0] = 123 shm.buf[456] = 78 shm.buf[1999] = 210 - data = NDArray("uint16", [2, 20, 25], shm) + data = appose.NDArray("uint16", [2, 20, 25], shm) # Run the task. task = service.task(ndarray_inspect, {"data": data}) diff --git a/tests/test_types.py b/tests/test_types.py index 52a1c46..445c749 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -1,5 +1,4 @@ import unittest -from multiprocessing.shared_memory import SharedMemory import appose @@ -66,7 +65,7 @@ def test_encode(self): "numbers": self.NUMBERS, "words": self.WORDS, } - ndarray = appose.types.NDArray("float32", [2, 20, 25]) + ndarray = appose.NDArray("float32", [2, 20, 25]) shm_name = ndarray.shm.name data["ndArray"] = ndarray json_str = appose.types.encode(data) @@ -76,7 +75,7 @@ def test_encode(self): ndarray.shm.unlink() def test_decode(self): - shm = SharedMemory(create=True, size=4000) + shm = appose.SharedMemory(create=True, size=4000) shm_name = shm.name data = appose.types.decode(self.JSON.replace("SHM_NAME", shm_name)) self.assertIsNotNone(data)