Skip to content

Commit

Permalink
Add progress indicators when spawning
Browse files Browse the repository at this point in the history
- Uses JupyterHub 0.9 feature, no effect for <0.9.
- Closes: #81
  • Loading branch information
rkdarst committed Jun 16, 2019
1 parent 35b7afd commit 4f793fa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ install:
- pip install attrs>17.4.0
- pip install --pre -r jupyterhub/dev-requirements.txt
- pip install --pre -e jupyterhub
- pip install --pre -f travis-wheels/wheelhouse -r requirements.txt

script:
- travis_retry py.test --lf --cov batchspawner batchspawner/tests -v
20 changes: 20 additions & 0 deletions batchspawner/batchspawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
* remote execution via submission of templated scripts
* job names instead of PIDs
"""
import asyncio
from async_generator import async_generator, yield_, yield_from_
import pwd
import os
import re
import sys

import xml.etree.ElementTree as ET

Expand Down Expand Up @@ -411,6 +414,23 @@ def stop(self, now=False):
self.job_id, self.current_ip, self.port)
)

@async_generator
async def progress(self):
while True:
if self.state_ispending():
await yield_({
"message": "Pending in queue...",
})
elif self.state_isrunning():
await yield_({
"message": "Cluster job running... waiting to connect",
})
return
else:
await yield_({
"message": "Unknown status...",
})
await gen.sleep(.1)

class BatchSpawnerRegexStates(BatchSpawnerBase):
"""Subclass of BatchSpawnerBase that uses config-supplied regular expressions
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
async_generator>=1.8
jinja2
jupyterhub>=0.5

0 comments on commit 4f793fa

Please sign in to comment.