Package: jhub-client
JupyterHub ClientAutomation of JupyterHubInstallpipinstalljhub-clientCommand Line UsageBelow are some example use cases of the tool. Note that with an admin
api token you can impersonate users and create temporary
users. Service api tokens do not have an associated user therefore
must run as existing users or temporary users.Set the api token used forjhub-client.exportJUPYTERHUB_API_TOKEN=<api-token>Optionally basic authentication can be used instead of token based
(not recommended but needed in some use cases). In which caseusernameandpasswordare required.exportJUPYTERHUB_USERNAME=<username>exportJUPYTERHUB_PASSWORD=<password>Token$jhubctltoken--help
usage:__main__.pytoken[-h][--hubHUB][--nameNAME]optionalarguments:-h,--helpshowthishelpmessageandexit--hubHUBurlforrunningjupyterhubcluster--nameNAMEnametogivetojupyterhubapitokenA simple command line utility can be used to create a token. This only
supports basic authentication (usernameandpassword) login to the
jupyterhub cluster.Run$jhubctlrun--help
usage:__main__.pyrun[-h]-nNOTEBOOK[--auth-type{token,basic}][--hubHUB][-uUSERNAME][--user-optionsUSER_OPTIONS][--temporary-user][-d][--stop-server][--validate][--kernel-specKERNEL_SPEC][--output-filenameOUTPUT_FILENAME]optionalarguments:-h,--helpshowthishelpmessageandexit-nNOTEBOOK,--notebookNOTEBOOKnotebooktorun--auth-type{token,basic}jupyterhubauthenticationtypetousewithdefaultoftokenbased--hubHUBurlforrunningjupyterhubclusterwithdefaultof'http://localhost:8000'-uUSERNAME,--usernameUSERNAMEusernametorunnotebookas--user-optionsUSER_OPTIONSjsonobjectrepresentinguserserveroptions--temporary-usercreateusertemporarilyifdoesnotexist-d,--daemonizerunnotebookasyncronously--stop-serverstopserveraftercompletionofnotebook--validatevalidatenotebookoutputmatches--kernel-specKERNEL_SPECkernelspectolaunchisnotspecifiedwillusedefault--output-filenameOUTPUT_FILENAMEoutputfilenameforresultsofrunningnotebookRun notebook as given token user syncronouslyYou can run a given notebook as a pre-existing user syncronously. The
api token either has to be for the given user or an admin token.jhubctl--verboserun--notebook<notebook>--hub<hub_url>Run notebook as given token user syncronously and validate notebook output matchesYou can run a given notebook as a pre-existing user syncronously. The
api token either has to be for the given user or an admin token.jhubctlrun--notebook<notebook>--hub<hub_url>--validateRun notebook as given token user asyncronously and shutdown server after completionYou can run a given notebook as a pre-existing user asyncronously and
stop server after completion. The api token either has to be for the
given user or an admin token.jhubctlrun--notebook<notebook>--hub<hub_url>--daemonize--stop-serverRun notebook as given token user with user optionsWhile this is an advanced use case, it is often times encountered
with kubernetes jupyerhub clusters where you may want to select a
given profile e.g. small, medium, gpu jupyterlab session. For these
clusters you must supply--user-options='{"profile": 0}'where 0 is
replaced with the index of the profile you would like to choose. It is
possible for other more customized jupyterhub clusters that different
options must be used.jhubctlrun--notebook<notebook>--hub<hub_url>--user-options='{"profile": 1}'Run notebook as given token user with user optionsYou can run a given notebook with any available kernel spec.jhubctlrun--notebook<notebook>--hub<hub_url>--kernel-spec=python3Run a given notebook as a temporary userAdditionally you can temporarily create a useruser-<uuid>or supply
the temporary user's username. The username will be deleted upon
completion. The api token requires admin permissions.jhubctlrun--temporary-user--notebook<notebook>--hub<hub_url>[--username<username>]TestingBring up test jupyterhub clustercdtests/assets
docker-composeup--buildRun unit testspytestFAQCreating an API TokenLogin to the given jupyterhub clusterAccess the hub control page. The url will be<hub_url>/hub/home.Click onTokenin top left corner and request new api token. This
token will have the permissions of the user. Make sure to set the
environment variableJUPYTERHUB_API_TOKENto the value of the given
token.If you want to add a service token instead edit the jupyterhub
configuration.c.JupyterHub.services=[{'name':'<my-service-name>','api_token':'<my-super-secret-long-token>','oauth_no_confirm':True,'admin':True}]Code of ConductTo guarantee a welcoming and friendly community, we require contributors to follow ourCode of Conduct.Licensejhub-clientis BSD-3 Licensed