jupyterhub / nbgitpuller

Jupyter server extension to sync a git repository one-way to a local path
https://nbgitpuller.readthedocs.io
BSD 3-Clause "New" or "Revised" License
211 stars 86 forks source link

Create an nbgitpuller "generate link" function in Python #155

Open choldgraf opened 4 years ago

choldgraf commented 4 years ago

I think another common way folks might want to be able to generate a link is via Python instead of via a UI (for example, if they want to generate a bunch of links programmatically, or if they are more comfortable calling a library than a UI). What do folks think about adding a generate_link function that takes arguments that match the fields in nbgitpuller.link and generates the proper link?

ryanlovett commented 4 years ago

I like this approach, maybe with defaults that inherit from the current environment.

manics commented 4 years ago

Sounds sensible! Are you thinking an importable module/function plus a entrypoint console_script in this repo?

choldgraf commented 4 years ago

yeah I was just thinking from nbgitpuller import link

and something like

def link(hub_url, repo_url, file_to_open, ..., kind="jupyterhub") -> str:
    """Generate an nbgitpuller link for a given hub and repository configuration."""
    magic-happens-here
ttimbers commented 3 years ago

We did something like this for an older version of our course management workflow (we're now taking a different approach) for generating an nbgitpuller launch url from Canvas. If anything is useful, please feel free to borrow (credit to a very talented past student of mine @samhinshaw): https://github.com/UBC-DSCI/rudaux/blob/834b396146934b6c048851a911db82337c5219a3/rudaux-archive/rudaux/assignment.py#L115