-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from rkdarst/singleuserapp_and_1.0
Singleuserapp and 1.0
- Loading branch information
Showing
4 changed files
with
51 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
from jupyterhub.singleuser import SingleUserNotebookApp | ||
from jupyterhub.utils import random_port, url_path_join | ||
from traitlets import default | ||
import os | ||
import sys | ||
|
||
class BatchSingleUserNotebookApp(SingleUserNotebookApp): | ||
@default('port') | ||
def _port(self): | ||
return random_port() | ||
from runpy import run_path | ||
from shutil import which | ||
|
||
def start(self): | ||
# Send Notebook app's port number to remote Spawner | ||
self.hub_auth._api_request(method='POST', | ||
url=url_path_join(self.hub_api_url, 'batchspawner'), | ||
json={'port' : self.port}) | ||
super().start() | ||
from jupyterhub.utils import random_port, url_path_join | ||
from jupyterhub.services.auth import HubAuth | ||
|
||
def main(argv=None): | ||
return BatchSingleUserNotebookApp.launch_instance(argv) | ||
port = random_port() | ||
hub_auth = HubAuth() | ||
hub_auth.client_ca = os.environ.get('JUPYTERHUB_SSL_CLIENT_CA', '') | ||
hub_auth.certfile = os.environ.get('JUPYTERHUB_SSL_CERTFILE', '') | ||
hub_auth.keyfile = os.environ.get('JUPYTERHUB_SSL_KEYFILE', '') | ||
hub_auth._api_request(method='POST', | ||
url=url_path_join(hub_auth.api_url, 'batchspawner'), | ||
json={'port' : port}) | ||
|
||
cmd_path = which(sys.argv[1]) | ||
sys.argv = sys.argv[1:] + ['--port={}'.format(port)] | ||
run_path(cmd_path, run_name="__main__") | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters