Skip to content

Commit e0fafa4

Browse files
committed
[FIX] typo introduced when rebasing. Also added some unit tests for the pool option
1 parent 0e6283c commit e0fafa4

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

scripts/smart_dispatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def main():
9797

9898
# If no pool size is specified the number of commands is taken
9999
if args.pool is None:
100-
args.pool = command_manager.get_nb_commands_to_run(command_line)
100+
args.pool = command_manager.get_nb_commands_to_run()
101101

102102
# Generating all the worker commands
103103
COMMAND_STRING = 'cd "{cwd}"; smart_worker.py "{commands_file}" "{log_folder}" '\

tests/test_smart_dispatch.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@ def setUp(self):
1515
self.testing_dir = tempfile.mkdtemp()
1616
self.logs_dir = os.path.join(self.testing_dir, 'SMART_DISPATCH_LOGS')
1717

18-
base_command = 'smart_dispatch.py --pool 10 -C 42 -q test -t 5:00 -x {0}'
19-
self.launch_command = base_command.format('launch echo "[1 2 3 4]" "[6 7 8]" "[9 0]"')
20-
self.resume_command = base_command.format('resume {0}')
18+
self.commands = 'echo "[1 2 3 4]" "[6 7 8]" "[9 0]"'
19+
self.nb_commands = 4*3*2
20+
21+
smart_dispatch_command = 'smart_dispatch.py -C 1 -q test -t 5:00 -x {0}'
22+
self.launch_command = smart_dispatch_command.format('launch ' + self.commands)
23+
self.resume_command = smart_dispatch_command.format('resume {0}')
24+
25+
smart_dispatch_command_with_pool = 'smart_dispatch.py --pool 10 -C 1 -q test -t 5:00 -x {0}'
26+
self.launch_command_with_pool = smart_dispatch_command_with_pool.format('launch ' + self.commands)
27+
self.nb_workers = 10
2128

2229
self._cwd = os.getcwd()
2330
os.chdir(self.testing_dir)
@@ -35,6 +42,23 @@ def test_main_launch(self):
3542
assert_true(os.path.isdir(self.logs_dir))
3643
assert_equal(len(os.listdir(self.logs_dir)), 1)
3744

45+
batch_uid = os.listdir(self.logs_dir)[0]
46+
path_job_commands = os.path.join(self.logs_dir, batch_uid, "commands")
47+
assert_equal(len(os.listdir(path_job_commands)), self.nb_commands + 1)
48+
49+
def test_main_launch_with_pool_of_workers(self):
50+
# Actual test
51+
exit_status = call(self.launch_command_with_pool, shell=True)
52+
53+
# Test validation
54+
assert_equal(exit_status, 0)
55+
assert_true(os.path.isdir(self.logs_dir))
56+
assert_equal(len(os.listdir(self.logs_dir)), 1)
57+
58+
batch_uid = os.listdir(self.logs_dir)[0]
59+
path_job_commands = os.path.join(self.logs_dir, batch_uid, "commands")
60+
assert_equal(len(os.listdir(path_job_commands)), self.nb_workers + 1)
61+
3862
def test_main_resume(self):
3963
# Setup
4064
call(self.launch_command, shell=True)

0 commit comments

Comments
 (0)