Package: nbgitpuller-link
nbgitpuller-linkGenerate annbgitpullerlink
through a command-line interface or Python code.InstallationInstall the latest stable release ofnbgitpuller-linkwithpip:pip install nbgitpuller-linkor withconda:conda install nbgitpuller-link -c conda-forgeTo install from source, after cloning or downloading thenbgitpuller-linkrepository,
change into the repository directory
and install the package withpip:pip install -e .ExamplesThenbgitpuller-linkpackage includes a CLI and a Python API.
The repository holds shortexamplesof both, which are adapted here.ShellTo see how to use the CLI,
callnbgitpuller-linkwith the--helpoption:$nbgitpuller-link--help
Usage:nbgitpuller-link[OPTIONS]GenerateannbgitpullerlinktoloadarepositoryonaJupyterHub

Options:--versionShowtheversionandexit.--jupyterhub-urlTEXTTargetJupyterHubforlink.[required]--repository-urlTEXTSourcerepositoryforlink.[required]--branchTEXTBranchtousefromsourcerepository.[default:main]--launch-pathTEXTRelativepathtofileordirectoryinsourcerepositorytolaunchontargetJupyterHub.[default:]--interface[notebook|lab]OpenwithclassicJupyterNotebookinterfaceornext-generationJupyterLab.[default:notebook]--helpShowthismessageandexit.Generate a link to load a repository on a JupyterHub,
specifying the file to launch
and the branch to use:nbgitpuller-link\--jupyterhub-url=https://lab.openearthscape.org\--repository-url=https://github.com/csdms/ivy\--branch=main\--launch-path=lessons/bmi/index.ipynbThe resulting link:https://lab.openearthscape.org/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fcsdms%2Fivy&urlpath=tree%2Fivy%2Flessons%2Fbmi%2Findex.ipynb&branch=mainPythonStart a Python session and import theLinkclass from thenbgitpuller-linkpackage:fromnbgitpuller_linkimportLinkGenerate a link though aLinkinstance:linker=Link(jupyterhub_url="https://lab.openearthscape.org",repository_url="https://github.com/csdms/ivy",branch="main",launch_path="lessons/bmi/index.ipynb",interface="lab",)Note that this example uses the JupyterLab interface.Thelinkproperty holds the URL:print(f"The nbgitpuller link is:\n{linker.link}")The nbgitpuller link is:
https://lab.openearthscape.org/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fcsdms%2Fivy&urlpath=lab%2Ftree%2Fivy%2Flessons%2Fbmi%2Findex.ipynb%3Fautodecode&branch=mainMIT LicenseCopyright (c) 2021 Mark PiperPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.