Skip to content

Commit

Permalink
Merge pull request #18 from pypr/improvements
Browse files Browse the repository at this point in the history
Some bug fixes and minor improvements
  • Loading branch information
prabhuramachandran committed Jun 8, 2019
2 parents b8b4cd3 + ebfcec7 commit c7fe50a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
6 changes: 5 additions & 1 deletion automan/automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ def _check_status_of_requires(self, task):
return 'running'

def _check_status_of_task(self, task):
if self.task_status.get(task) == 'not started':
status = self.task_status.get(task)
if status == 'not started':
return False
elif status == 'done':
return True
else:
complete = False
try:
Expand Down Expand Up @@ -278,6 +281,7 @@ def complete(self):
raise RuntimeError(
'Error in task with output in %s.' % self.output_dir
)
return True
else:
return self._copy_output_and_check_status()

Expand Down
4 changes: 2 additions & 2 deletions automan/cluster_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class ClusterManager(object):
set -e
if hash virtualenv 2>/dev/null; then
virtualenv --system-site-packages envs/{project_name}
virtualenv -p python3 --system-site-packages envs/{project_name}
else
python virtualenv.py --system-site-packages envs/{project_name}
python3 virtualenv.py --system-site-packages envs/{project_name}
fi
source envs/{project_name}/bin/activate
Expand Down
35 changes: 35 additions & 0 deletions automan/tests/test_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,41 @@ def test_command_tasks_handles_errors_correctly(self):
self.assertFalse(t.complete())


class TestRemoteCommandTask(TestAutomationBase):
def _make_scheduler(self):
if not os.path.exists(self.output_dir):
os.makedirs(self.output_dir)
worker = dict(
host='test_remote', python=sys.executable,
chdir=self.output_dir, testing=True
)
s = Scheduler(root='.', worker_config=[worker])
return s

def test_remote_command_tasks_complete_method_works(self):
# Given
s = self._make_scheduler()
cmd = 'python -c "print(1)"'
t = CommandTask(cmd, output_dir=self.sim_dir)

self.assertFalse(t.complete())
self.assertFalse(os.path.exists(
os.path.join(self.sim_dir, 'stdout.txt')
))

# When
t.run(s)
wait_until(lambda: not t.complete())

# Then
self.assertTrue(t.complete())
self.assertTrue(os.path.exists(
os.path.join(self.sim_dir, 'stdout.txt')
))
# Test that if we call it repeatedly that it does indeed return True
self.assertTrue(t.complete())


def test_simulation_get_labels():
# Given
s = Simulation(
Expand Down

0 comments on commit c7fe50a

Please sign in to comment.