Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Lightning Studio Launch Button #851

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"binderhub_url": "https://mybinder.org",
"colab_url": "https://colab.research.google.com/",
"deepnote_url": "https://deepnote.com/",
"lightning_studio_url": "https://lightning.ai/",
"notebook_interface": "jupyterlab",
"thebe": True,
# "jupyterhub_url": "https://datahub.berkeley.edu", # For testing
Expand Down
16 changes: 16 additions & 0 deletions docs/content/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ html_theme_options = {
This will create a new Deepnote project every time you click the launch button.
```

## Lightning Studio

To add [Ligthning Studio](https://lightning.ai) links to your page, add the following configuration:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To add [Ligthning Studio](https://lightning.ai) links to your page, add the following configuration:
To add [Lightning Studio](https://lightning.ai) links to your page, add the following configuration:



```python
html_theme_options = {
...
"launch_buttons": {
"lightning_studio_url": "https://lightning.ai"
},
...
}
```



## Live code cells with Thebe

Expand Down
17 changes: 17 additions & 0 deletions src/sphinx_book_theme/header_buttons/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def add_launch_buttons(
binderhub_url = launch_buttons.get("binderhub_url", "").strip("/")
colab_url = launch_buttons.get("colab_url", "").strip("/")
deepnote_url = launch_buttons.get("deepnote_url", "").strip("/")
lightning_studio_url = launch_buttons.get("lightning_studio_url", "").strip("/")

# Loop through each provider and add a button for it if needed
if binderhub_url:
Expand Down Expand Up @@ -189,6 +190,22 @@ def add_launch_buttons(
}
)

if lightning_studio_url:
if provider.lower() != "github":
SPHINX_LOGGER.warning(f"Provider {provider} not supported on Lightning.")
else:
github_path = f"%2F{org}%2F{repo}%2Fblob%2F{branch}%2F{path_rel_repo}"
url = f"{lightning_studio_url}/new?repo_url=https://github.com{github_path}"
launch_buttons_list.append(
{
"type": "link",
"text": "Lightning Studio",
"tooltip": translation("Launch on") + " Lightning Studio",
"icon": "_static/images/logo_lightning_studio.svg",
"url": url,
}
)

# Add thebe flag in context
if launch_buttons.get("thebe", False):
launch_buttons_list.append(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/sites/base/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"jupyterhub_url": "https://datahub.berkeley.edu",
"colab_url": "https://colab.research.google.com",
"deepnote_url": "https://deepnote.com",
"lightning_studio_url": "https://lightning.ai/",
"notebook_interface": "jupyterlab",
"thebe": True,
},
Expand Down
10 changes: 10 additions & 0 deletions tests/test_build/build__header-article.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
</span>
</a>
</li>
<li>
<a class="btn btn-sm dropdown-item" data-bs-placement="left" data-bs-toggle="tooltip" href="https://lightning.ai/new?repo_url=https://github.com%2Fexecutablebooks%2Fsphinx-book-theme%2Fblob%2Fmaster%2FTESTPATH/section1/ntbk.ipynb" target="_blank" title="Launch on Lightning Studio">
<span class="btn__icon-container">
<img alt="Lighting Studio logo" src="../_static/images/logo_lightning_studio.svg"/>
</span>
<span class="btn__text-container">
Lightning Studio
</span>
</a>
</li>
<li>
<button class="btn btn-sm btn-launch-thebe dropdown-item" data-bs-placement="left" data-bs-toggle="tooltip" onclick="initThebeSBT()" title="Launch Thebe">
<span class="btn__icon-container">
Expand Down
10 changes: 10 additions & 0 deletions tests/test_build/test_header_launchbtns.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
</span>
</a>
</li>
<li>
<a class="btn btn-sm dropdown-item" data-bs-placement="left" data-bs-toggle="tooltip" href="https://lightning.ai/new?repo_url=https://github.com%2Fexecutablebooks%2Fsphinx-book-theme%2Fblob%2Fmaster%2FTESTPATH/section1/ntbk.ipynb" target="_blank" title="Launch on Lightning Studio">
<span class="btn__icon-container">
<img alt="Lightning Studio logo" src="../_static/images/logo_lightning_studio.svg"/>
</span>
<span class="btn__text-container">
Lightning Studio
</span>
</a>
</li>
<li>
<button class="btn btn-sm btn-launch-thebe dropdown-item" data-bs-placement="left" data-bs-toggle="tooltip" onclick="initThebeSBT()" title="Launch Thebe">
<span class="btn__icon-container">
Expand Down