-
Notifications
You must be signed in to change notification settings - Fork 0
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 #8 from vuillaut:docs
full doc :)
- Loading branch information
Showing
16 changed files
with
391 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Deploy Documentation | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build_and_deploy_docs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install sphinx | ||
pip install sphinx_rtd_theme | ||
- name: Build documentation | ||
run: | | ||
cd docs | ||
make html | ||
- name: Deploy documentation to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs/_build/html |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
API Documentation | ||
================= | ||
|
||
This section contains the API documentation for the sshlab library. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: API | ||
|
||
sshlab.sshlab | ||
sshlab.sshlab_kill | ||
sshlab.sshtensorboard | ||
sshlab.utils |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.. _building-docs: | ||
|
||
Building the Documentation | ||
========================== | ||
|
||
This section provides instructions on how to build the documentation locally for development and testing purposes. | ||
|
||
Prerequisites | ||
------------- | ||
|
||
Install `sshlab` with doc requirements after cloning the repository: | ||
|
||
.. code-block:: console | ||
pip install -e ".[doc]" | ||
Building the Documentation | ||
-------------------------- | ||
|
||
To build the documentation, navigate to the `docs` directory in the project root and run the following command: | ||
|
||
.. code-block:: console | ||
make clean html | ||
This command generates the HTML documentation in the `build/html` directory within the `docs` folder. | ||
|
||
To view the generated documentation, open the `index.html` file located in the `build/html` directory with your web browser. | ||
|
||
.. note:: | ||
|
||
If you make any changes to the documentation, you need to rebuild it using the `make html` command. |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath('..')) | ||
|
||
project = 'sshlab' | ||
copyright = '2023, Thomas Vuillaume' | ||
author = 'Thomas Vuillaume' | ||
release = '0.1.4' | ||
|
||
# -- General configuration --------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration | ||
|
||
extensions = [ | ||
'sphinx.ext.autodoc', | ||
'sphinx.ext.viewcode', | ||
'sphinx.ext.githubpages', | ||
] | ||
|
||
templates_path = ['_templates'] | ||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | ||
|
||
root_doc = 'index' | ||
|
||
html_theme = 'furo' | ||
|
||
html_static_path = ['_static'] | ||
|
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
.. sshlab documentation master file, created by | ||
sphinx-quickstart on Fri Apr 21 2023 | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
Welcome to sshlab's documentation! | ||
=================================== | ||
|
||
Introduction | ||
============ | ||
|
||
sshlab is a Python library that simplifies the process of launching Jupyter notebooks, TensorBoard, | ||
and managing remote processes on remote servers via SSH. It provides an easy-to-use command-line interface for starting, | ||
stopping, and managing Jupyter and TensorBoard instances. | ||
|
||
Features | ||
-------- | ||
|
||
- Launch Jupyter Notebook or JupyterLab instances on remote servers via SSH. | ||
- Launch TensorBoard instances on remote servers via SSH. | ||
- Kill remote Jupyter and TensorBoard processes. | ||
- Automatic port selection for local and remote servers. | ||
- Simple YAML configuration file for managing multiple remote environments. | ||
|
||
|
||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
installation | ||
overview | ||
api | ||
build-doc | ||
|
||
|
||
|
||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Installation | ||
============ | ||
|
||
The sshlab library can be installed using pip: | ||
|
||
.. code-block:: bash | ||
pip install sshlab | ||
Alternatively, you can clone the repository and install it manually: | ||
|
||
.. code-block:: bash | ||
git clone https://github.com/vuillaut/sshlab.git | ||
cd sshlab | ||
pip install . |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=source | ||
set BUILDDIR=build | ||
|
||
%SPHINXBUILD% >NUL 2>NUL | ||
if errorlevel 9009 ( | ||
echo. | ||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
echo.installed, then set the SPHINXBUILD environment variable to point | ||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
echo.may add the Sphinx directory to PATH. | ||
echo. | ||
echo.If you don't have Sphinx installed, grab it from | ||
echo.https://www.sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
if "%1" == "" goto help | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
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 |
---|---|---|
@@ -0,0 +1,128 @@ | ||
.. _overview: | ||
|
||
Overview | ||
======== | ||
|
||
Welcome to the sshlab library documentation! | ||
This library provides a simple and convenient way to start Jupyter Notebook or JupyterLab instances on a remote server through an SSH tunnel. | ||
It also includes utilities for killing remote Jupyter and Tensorboard processes. | ||
|
||
Using the sshlab library | ||
------------------------ | ||
|
||
The library consists of three main scripts: `sshlab.py`, `sshlab_kill.py`, and `sshtensorboard.py`. | ||
|
||
The `sshlab.py` script is used to start a Jupyter instance on a remote server, the `sshlab_kill.py` script is used to kill a remote Jupyter or Tensorboard process, | ||
and the `sshtensorboard.py` script is used to start a TensorBoard instance on a remote server. | ||
|
||
Additionally, the `utils.py` module contains utility functions for checking port availability, getting remote process PIDs, and killing remote processes. | ||
|
||
Configuration | ||
------------- | ||
|
||
The library relies on a configuration file in YAML format to store user configurations. | ||
By default, it looks for a file named `.sshlab_config.yml` in the user's home directory, but a different file can be specified using the `--file` command-line option. | ||
|
||
Here's an example configuration file: | ||
|
||
.. code-block:: yaml | ||
default: | ||
SSH: | ||
user: username | ||
server: example.com | ||
ip: 127.0.0.1 | ||
port: 8888 | ||
Environment: | ||
cmd: singularity | ||
target: /path/to/singularity/image.sif | ||
options: --bind /exp_dir/:/exp_dir/ | ||
Jupyter: | ||
flavor: lab | ||
options: --no-browser --notebook-dir=/exp_dir/ | ||
In this example, the configuration file has a single user configuration named "default." | ||
The configuration specifies the SSH user and server, the environment command (Singularity in this case), the path to the Singularity image, and the Jupyter flavor (lab or notebook). | ||
|
||
|
||
Starting a remote Jupyter instance | ||
---------------------------------- | ||
|
||
To start a remote Jupyter instance using the sshlab library, run the `sshlab.py` script: | ||
|
||
.. code-block:: bash | ||
sshlab | ||
By default, it will use the configuration named "default" in the `.sshlab_config.yml` file. If you have multiple configurations, you can specify the configuration to use with the `--config` option: | ||
|
||
.. code-block:: bash | ||
sshlab --config myconfig | ||
Starting a remote TensorBoard instance | ||
-------------------------------------- | ||
|
||
To start a remote TensorBoard instance using the sshlab library, run the `sshlab-tensorboard` command: | ||
|
||
.. code-block:: bash | ||
sshlab-tensorboard EXP_NAMES | ||
Replace `EXP_NAMES` with a comma-separated list of experiment names. By default, it will use the configuration named "default" in the `.sshlab_config.yml` file. | ||
If you have multiple configurations, you can specify the configuration to use with the `--config` option: | ||
|
||
.. code-block:: bash | ||
sshlab-tensorboard --config myconfig EXP_NAMES | ||
The config used must include a `Tensorboard` section, such as: | ||
|
||
.. code-block:: yaml | ||
tensorboard: | ||
SSH: | ||
user: username | ||
server: server.com | ||
port: 6006 | ||
ip: 127.0.0.1 | ||
Environment: | ||
cmd: singularity exec | ||
target: /path/to/image.sif | ||
options: --bind /exp_dir/:/exp_dir/ | ||
Tensorboard: | ||
cmd: /opt/conda/envs/glearn/bin/tensorboard | ||
logdir: /exp_dir/logs | ||
The `logdir` option is the path to the directory containing the TensorBoard logs (where are located the directories of `EXP_NAMES`). | ||
|
||
The `options` option is used to specify any additional options to pass to the environment command. | ||
For example, if you are using Singularity, you can use the `--bind` option to bind a local directory to a directory in the container. | ||
|
||
|
||
Killing a remote process | ||
------------------------ | ||
|
||
When closing the SSH connection, the remote process (Jupyter or TensorBoard) should be killed automatically. | ||
If not, one may run the `sshlab_kill.py` script: | ||
|
||
.. code-block:: bash | ||
sshlab_kill | ||
By default, it will use the configuration named "default" in the `.sshlab_config.yml` file and try to kill a remote Jupyter process. | ||
|
||
If you have multiple configurations or want to kill a different process such as tensorboard, | ||
|
||
you can specify the configuration to use with the `--config` option and the process name with the `--process` option: | ||
|
||
.. code-block:: bash | ||
sshlab_kill --config myconfig --process myprocess | ||
That's it! You now have a basic understanding of how to use the sshlab library to start and manage remote Jupyter instances. |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
sshlab | ||
====== | ||
|
||
.. automodule:: sshlab.sshlab | ||
:members: | ||
:undoc-members: |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
sshlab_kill | ||
=========== | ||
|
||
.. automodule:: sshlab.sshlab_kill | ||
:members: | ||
:undoc-members: |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
sshlab_tensorboard | ||
================== | ||
|
||
.. automodule:: sshlab.sshtensorboard | ||
:members: | ||
:undoc-members: |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
utils | ||
===== | ||
|
||
.. automodule:: sshlab.utils | ||
:members: | ||
:undoc-members: |
Oops, something went wrong.