Skip to content

Commit 7d5ad1f

Browse files
committed
Added get_nb_commands_to_run() to command_manager
1 parent 221d49e commit 7d5ad1f

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

scripts/smart_dispatch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def main():
5959
command_manager.set_commands_to_run(commands)
6060
else:
6161
command_manager.reset_running_commands()
62+
nb_commands = command_manager.get_nb_commands_to_run()
6263

6364
worker_command = 'smart_worker.py "{0}" "{1}"'.format(command_manager._commands_filename, path_job_logs)
6465
# Replace commands with `args.pool` workers

smartdispatch/command_manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def get_command_to_run(self):
3636
self._move_line_between_files(commands_file, running_commands_file, command)
3737
return command[:-1]
3838

39+
def get_nb_commands_to_run(self):
40+
with utils.open_with_lock(self._commands_filename, 'r') as commands_file:
41+
return len(commands_file.readline())
42+
3943
def set_running_command_as_finished(self, command):
4044
with utils.open_with_lock(self._running_commands_filename, 'r+') as running_commands_file:
4145
with utils.open_with_lock(self._finished_commands_filename, 'a') as finished_commands_file:

smartdispatch/tests/test_command_manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def test_get_command_to_run(self):
5555

5656
assert_true(not os.path.isfile(self.command_manager._finished_commands_filename))
5757

58+
def test_get_nb_commands_to_run(self):
59+
assert_equal(self.command_manager.get_nb_commands_to_run(), 3)
60+
5861
def test_set_running_command_as_finished(self):
5962
# SetUp
6063
command = self.command_manager.get_command_to_run()

0 commit comments

Comments
 (0)