Skip to content

Commit 2b049e5

Browse files
committed
fixes to test
1 parent 059f888 commit 2b049e5

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

executorlib/task_scheduler/file/task_scheduler.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
class FileTaskScheduler(TaskSchedulerBase):
2828
def __init__(
2929
self,
30-
cache_directory: Optional[str] = None,
3130
resource_dict: Optional[dict] = None,
3231
execute_function: Callable = execute_with_pysqa,
3332
terminate_function: Optional[Callable] = None,
@@ -39,7 +38,6 @@ def __init__(
3938
Initialize the FileExecutor.
4039
4140
Args:
42-
cache_directory (str, optional): The directory to store cache files. Defaults to "executorlib_cache".
4341
resource_dict (dict): A dictionary of resources required by the task. With the following keys:
4442
- cores (int): number of MPI cores to be used for each function call
4543
- cwd (str/None): current working directory where the parallel python task is executed
@@ -53,7 +51,6 @@ def __init__(
5351
default_resource_dict = {
5452
"cores": 1,
5553
"cwd": None,
56-
"cache_directory": cache_directory,
5754
}
5855
if resource_dict is None:
5956
resource_dict = {}

tests/test_cache_fileexecutor_mpi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def mpi_funct(i):
3232
class TestCacheExecutorMPI(unittest.TestCase):
3333
def test_executor(self):
3434
with FileTaskScheduler(
35-
resource_dict={"cores": 2}, execute_function=execute_in_subprocess
35+
resource_dict={"cores": 2, "cache_directory": "executorlib_cache"},
36+
execute_function=execute_in_subprocess,
3637
) as exe:
3738
fs1 = exe.submit(mpi_funct, 1)
3839
self.assertFalse(fs1.done())

tests/test_cache_fileexecutor_serial.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,30 @@ def get_error(a):
3636
)
3737
class TestCacheExecutorSerial(unittest.TestCase):
3838
def test_executor_mixed(self):
39-
with FileTaskScheduler(execute_function=execute_in_subprocess) as exe:
39+
with FileTaskScheduler(
40+
execute_function=execute_in_subprocess,
41+
resource_dict={"cache_directory": "executorlib_cache"},
42+
) as exe:
4043
fs1 = exe.submit(my_funct, 1, b=2)
4144
self.assertFalse(fs1.done())
4245
self.assertEqual(fs1.result(), 3)
4346
self.assertTrue(fs1.done())
4447

4548
def test_executor_mixed_cache_key(self):
46-
with FileTaskScheduler(execute_function=execute_in_subprocess) as exe:
49+
with FileTaskScheduler(
50+
execute_function=execute_in_subprocess,
51+
resource_dict={"cache_directory": "executorlib_cache"},
52+
) as exe:
4753
fs1 = exe.submit(my_funct, 1, b=2, resource_dict={"cache_key": "a/b/c"})
4854
self.assertFalse(fs1.done())
4955
self.assertEqual(fs1.result(), 3)
5056
self.assertTrue(fs1.done())
5157

5258
def test_executor_dependence_mixed(self):
53-
with FileTaskScheduler(execute_function=execute_in_subprocess) as exe:
59+
with FileTaskScheduler(
60+
execute_function=execute_in_subprocess,
61+
resource_dict={"cache_directory": "executorlib_cache"},
62+
) as exe:
5463
fs1 = exe.submit(my_funct, 1, b=2)
5564
fs2 = exe.submit(my_funct, 1, b=fs1)
5665
self.assertFalse(fs2.done())
@@ -66,23 +75,27 @@ def test_create_file_executor_error(self):
6675
def test_executor_dependence_error(self):
6776
with self.assertRaises(ValueError):
6877
with FileTaskScheduler(
69-
execute_function=execute_in_subprocess, disable_dependencies=True
78+
execute_function=execute_in_subprocess,
79+
disable_dependencies=True,
80+
resource_dict={"cache_directory": "executorlib_cache"},
7081
) as exe:
7182
fs = exe.submit(my_funct, 1, b=exe.submit(my_funct, 1, b=2))
7283
fs.result()
7384

7485
def test_executor_working_directory(self):
7586
cwd = os.path.join(os.path.dirname(__file__), "executables")
7687
with FileTaskScheduler(
77-
resource_dict={"cwd": cwd}, execute_function=execute_in_subprocess
88+
resource_dict={"cwd": cwd, "cache_directory": "executorlib_cache"},
89+
execute_function=execute_in_subprocess,
7890
) as exe:
7991
fs1 = exe.submit(list_files_in_working_directory)
8092
self.assertEqual(fs1.result(), os.listdir(cwd))
8193

8294
def test_executor_error(self):
8395
cwd = os.path.join(os.path.dirname(__file__), "executables")
8496
with FileTaskScheduler(
85-
resource_dict={"cwd": cwd}, execute_function=execute_in_subprocess
97+
resource_dict={"cwd": cwd, "cache_directory": "executorlib_cache"},
98+
execute_function=execute_in_subprocess,
8699
) as exe:
87100
fs1 = exe.submit(get_error, a=1)
88101
with self.assertRaises(ValueError):

0 commit comments

Comments
 (0)