Skip to content

Commit

Permalink
Add progress indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdarst committed May 20, 2018
1 parent dbadffb commit bfa0ed1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions batchspawner/batchspawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import xml.etree.ElementTree as ET

from async_generator import async_generator, yield_

from tornado import gen
from tornado.process import Subprocess
from subprocess import CalledProcessError
Expand Down Expand Up @@ -308,7 +310,9 @@ def start(self):
# should either raise and Exception or loop forever.
assert len(self.job_id) > 0
while True:
yield gen.sleep(5.0)
yield self.poll()
yield gen.sleep(5.0)
if self.state_isrunning():
break
else:
Expand All @@ -318,6 +322,7 @@ def start(self):
self.log.warn('Job ' + self.job_id + ' neither pending nor running.\n' +
self.job_status)
assert self.state_ispending()
yield gen.sleep(5.0)
yield gen.sleep(self.startup_poll_interval)

self.current_ip = self.state_gethost()
Expand Down Expand Up @@ -353,6 +358,26 @@ def stop(self, now=False):
self.job_id, self.current_ip, self.port)
)

@gen.coroutine
def progress(self):
while True:
if self.state_ispending():
yield ({
"progress": 33,
"message": "Pending in queue...",
})
elif self.state_isrunning():
yield ({
"progress": 66,
"message": "Cluster job running...",
})
else:
yield ({
"progress": 50,
"message": "Unknown status...",
})
yield gen.sleep(.1)

import re

class BatchSpawnerRegexStates(BatchSpawnerBase):
Expand Down Expand Up @@ -486,6 +511,8 @@ class SlurmSpawner(UserEnvMixin,BatchSpawnerRegexStates):
#SBATCH --get-user-env=L
#SBATCH {options}
sleep 10
which jupyterhub-singleuser
{cmd}
""").tag(config=True)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
async_generator>=1.8
jupyterhub>=0.5

0 comments on commit bfa0ed1

Please sign in to comment.