-
Notifications
You must be signed in to change notification settings - Fork 4
Add documentation #341
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
Open
EZoni
wants to merge
20
commits into
BLAST-AI-ML:main
Choose a base branch
from
EZoni:setup_docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add documentation #341
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
dc7fbaa
Add documentation
EZoni bc4169c
Add pre-commit to documentation environment
EZoni 30eef7f
Fix issues flagged by Ruff
EZoni 5f4b128
Add autobuild and copybutton
EZoni d1f0bd8
Update list of authors
EZoni aa8fcc8
Remove pre-commit, pip from environment
EZoni bfa9e28
Update .gitignore
EZoni 56cde6b
Merge branch 'main' into setup_docs
EZoni 0150817
Merge branch 'main' into setup_docs
EZoni 161b469
First docs draft
EZoni 19b48dc
Apply batch of suggestions
EZoni 8cc0dbf
Apply batch of suggestions
EZoni 5119baa
Fix chat URL formatting
EZoni 337b086
Merge branch 'main' into setup_docs
EZoni 1c56307
Merge branch 'main' into setup_docs
EZoni 01f9694
Migrate README files into new docs
EZoni a0882c3
Add section on building the docs locally
EZoni 2e1d879
Fix typos
EZoni 7dfe29b
Minor changes
EZoni 52ba706
Clarify section on building the docs locally
EZoni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -6,3 +6,6 @@ experiments/*/ | |
|
|
||
| # JetBrains IDE idea directories | ||
| .idea/ | ||
|
|
||
| # Documentation | ||
| docs/build/ | ||
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,199 +1,3 @@ | ||
| # Table of Contents | ||
| * [Overview](#Overview) | ||
| * [Run the Dashboard Locally](#Run-the-Dashboard-Locally) | ||
| * [Without Docker](#Without-Docker) | ||
| * [With Docker](#With-Docker) | ||
| * [Run the Dashboard at NERSC](#Run-the-Dashboard-at-NERSC) | ||
| * [Get the Superfacility API Credentials](#Get-the-Superfacility-API-Credentials) | ||
| * [For Maintainers](#For-Maintainers) | ||
| * [Generate the conda environment lock file](#Generate-the-conda-environment-lock-file) | ||
| * [Build and push the Docker container to NERSC](#Build-and-push-the-Docker-container-to-NERSC) | ||
| * [References](#References) | ||
| # Dashboard | ||
|
|
||
| # Overview | ||
|
|
||
| The Synapse dashboard provides a web interface for working with data from experiments, simulations, and ML models. | ||
|
|
||
| The dashboard can be run in two distinct ways: | ||
|
|
||
| 1. Locally on your computer. | ||
|
|
||
| 2. At NERSC through Spin. | ||
|
|
||
| # Run the Dashboard Locally | ||
|
|
||
| This section describes how to develop and use the dashboard locally. | ||
|
|
||
| ## Without Docker | ||
|
|
||
| ### Prepare the conda environment | ||
|
|
||
| 1. Move to the [dashboard/](./) directory. | ||
|
|
||
| 2. Activate the conda environment `base`: | ||
| ```bash | ||
| conda activate base | ||
| ``` | ||
|
|
||
| 3. Install `conda-lock` if not installed yet: | ||
| ```bash | ||
| conda install -c conda-forge conda-lock | ||
| ``` | ||
|
|
||
| 4. Create the conda environment `synapse-gui`: | ||
| ```bash | ||
| conda-lock install --name synapse-gui environment-lock.yml | ||
| ``` | ||
|
|
||
| ### Run the dashboard | ||
|
|
||
| 1. Create an SSH tunnel to access the MongoDB database at NERSC (in a separate terminal): | ||
| ```bash | ||
| ssh -L 27017:mongodb05.nersc.gov:27017 <username>@dtn03.nersc.gov -N | ||
| ``` | ||
|
|
||
| 2. Move to the [dashboard/](./) directory. | ||
|
|
||
| 3. Set up the database settings (read-only) and the AmSC MLflow API key: | ||
| ```bash | ||
| export SF_DB_HOST='127.0.0.1' | ||
| export SF_DB_READONLY_PASSWORD='your_password_here' # Use SINGLE quotes around the password! | ||
| export AM_SC_API_KEY='your_amsc_api_key_here' # Required when MLflow tracking_uri is AmSC | ||
| ``` | ||
|
|
||
| 4. Activate the conda environment `synapse-gui`: | ||
| ```bash | ||
| conda activate synapse-gui | ||
| ``` | ||
|
|
||
| 5. Run the dashboard as a web application: | ||
| ```bash | ||
| python -u app.py --port 8080 | ||
| ``` | ||
|
|
||
| ## With Docker | ||
|
|
||
| ### Run the dashboard | ||
|
|
||
| 1. Create an SSH tunnel to access the MongoDB database at NERSC (in a separate terminal): | ||
| ```bash | ||
| ssh -L 27017:mongodb05.nersc.gov:27017 <username>@dtn03.nersc.gov -N | ||
| ``` | ||
|
|
||
| 2. Move to the root directory of the repository. | ||
|
|
||
| 3. Build the Docker image as described [below](#build-the-docker-image). | ||
|
|
||
| 4. Run the Docker container: | ||
| ```bash | ||
| docker run --network=host -v /etc/localtime:/etc/localtime -v $PWD/ml:/app/ml -e SF_DB_HOST='127.0.0.1' -e SF_DB_READONLY_PASSWORD='your_password_here' -e AM_SC_API_KEY='your_amsc_api_key_here' synapse-gui | ||
| ``` | ||
| For debugging, you can enter the container without starting the app: | ||
| ```bash | ||
| docker run --network=host -v /etc/localtime:/etc/localtime -v $PWD/ml:/app/ml -e SF_DB_HOST='127.0.0.1' -e SF_DB_READONLY_PASSWORD='your_password_here' -e AM_SC_API_KEY='your_amsc_api_key_here' -it synapse-gui bash | ||
| ``` | ||
| Note that `-v /etc/localtime:/etc/localtime` is necessary to synchronize the time zone in the container with the host machine. | ||
|
|
||
| # Run the Dashboard at NERSC | ||
|
|
||
| Connect to the [dashboard](https://bellasuperfacility.lbl.gov/) deployed at NERSC through Spin and play around! | ||
| Remember that you need to upload valid Superfacility API credentials in order to launch simulations or train ML models directly from the dashboard. | ||
|
|
||
| # Get the Superfacility API Credentials | ||
|
|
||
| Following the instructions at [docs.nersc.gov/services/sfapi/authentication/#client](https://docs.nersc.gov/services/sfapi/authentication/#client): | ||
|
|
||
| 1. Log in to your profile page at [iris.nersc.gov/profile](https://iris.nersc.gov/profile). | ||
|
|
||
| 2. Click the icon with your username in the upper right of the profile page. | ||
|
|
||
| 3. Scroll down to the section "Superfacility API Clients" and click "New Client". | ||
|
|
||
| 4. Enter a client name (e.g., "Synapse"), choose `sf558` for the user, choose "Red" security level, and select either "Your IP" or "Spin" from the "IP Presets" menu, depending on whether the key will be used from a local computer or from Spin. | ||
|
|
||
| 5. Download the private key file (in pem format) and save it as `priv_key.pem` in the root directory of the dashboard. | ||
| Each time the dashboard is launched, it will automatically find the existing key file and load the corresponding credentials. | ||
|
|
||
| 6. Copy your client ID and add it on the first line of your private key file as described in the instructions at [nersc.github.io/sfapi_client/quickstart/#storing-keys-in-files](https://nersc.github.io/sfapi_client/quickstart/#storing-keys-in-files): | ||
| ``` | ||
| randmstrgz | ||
| -----BEGIN RSA PRIVATE KEY----- | ||
| ... | ||
| -----END RSA PRIVATE KEY----- | ||
| ``` | ||
|
|
||
| 7. Run `chmod 600 priv_key.pem` to change the permissions of your private key file to read/write only. | ||
|
|
||
| # For Maintainers | ||
|
|
||
| ## Generate the conda environment lock file | ||
|
|
||
| 1. Move to the directory [dashboard/](.). | ||
|
|
||
| 2. Activate the conda environment `base`: | ||
| ```bash | ||
| conda activate base | ||
| ``` | ||
|
|
||
| 3. Install `conda-lock` if not installed yet: | ||
| ```bash | ||
| conda install -c conda-forge conda-lock | ||
| ``` | ||
|
|
||
| 4. Generate the conda environment lock file: | ||
| ```bash | ||
| conda-lock --file environment.yml --lockfile environment-lock.yml | ||
| ``` | ||
|
|
||
| ## Build and push the Docker container to NERSC | ||
|
|
||
| > [!WARNING] | ||
| > Pushing a new Docker container affects the production dashboard deployed at NERSC through Spin. | ||
|
|
||
| > [!TIP] | ||
| > Run this workflow automatically with the Python script [publish_container.py](../publish_container.py): | ||
| > ```bash | ||
| > python publish_container.py --gui | ||
| > ``` | ||
|
|
||
| > [!TIP] | ||
| > Prune old, unused images periodically in order to free up space on your machine: | ||
| > ```bash | ||
| > docker system prune -a | ||
| > ``` | ||
|
|
||
| ### Build the Docker image | ||
|
|
||
| 1. Move to the root directory of the repository. | ||
|
|
||
| 2. Build the Docker image: | ||
| ```bash | ||
| docker build --platform linux/amd64 --output type=image,oci-mediatypes=true -t synapse-gui -f dashboard.Dockerfile . | ||
| ``` | ||
|
|
||
| ### Push the Docker container | ||
|
|
||
| 1. Move to the root directory of the repository. | ||
|
|
||
| 2. Login to the [NERSC registry](https://registry.nersc.gov): | ||
| ```bash | ||
| docker login registry.nersc.gov | ||
| # Username: your NERSC username | ||
| # Password: your NERSC password without 2FA | ||
| ``` | ||
|
|
||
| 3. Tag the Docker image: | ||
| ```bash | ||
| docker tag synapse-gui:latest registry.nersc.gov/m558/superfacility/synapse-gui:latest | ||
| docker tag synapse-gui:latest registry.nersc.gov/m558/superfacility/synapse-gui:$(date "+%y.%m") | ||
| ``` | ||
|
|
||
| 4. Push the Docker container: | ||
| ```bash | ||
| docker push -a registry.nersc.gov/m558/superfacility/synapse-gui | ||
| ``` | ||
|
|
||
| # References | ||
|
|
||
| * [Using NERSC's `registry.nersc.gov`](https://docs.nersc.gov/development/containers/registry/) | ||
| * [Superfacility API authentication](https://docs.nersc.gov/services/sfapi/authentication/#client) | ||
| The Synapse dashboard is documented in [docs/source/dashboard.md](../docs/source/dashboard.md). |
This file contains hidden or 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 = source | ||
| 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 hidden or 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,12 @@ | ||
| name: synapse-docs | ||
|
|
||
| channels: | ||
| - conda-forge | ||
| - nodefaults | ||
|
|
||
| dependencies: | ||
| - myst-parser | ||
| - sphinx | ||
| - sphinx-autobuild | ||
| - sphinx-book-theme | ||
| - sphinx-copybutton |
This file contains hidden or 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 hidden or 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,30 @@ | ||
| # Configuration file for the Sphinx documentation builder. | ||
| # | ||
| # For the full list of built-in configuration values, see the documentation: | ||
| # https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
|
||
| # -- Project information ----------------------------------------------------- | ||
| # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information | ||
|
|
||
| project = "Synapse" | ||
| copyright = "BSD-3-Clause-LBNL" | ||
| author = "Arjun Dhamrait, Andrea Diaz, Marco Garten, Axel Huebl, Revathi Jambunathan, Remi Lehe, Ethan Rodriguez, Olga Shapoval, Jean-Luc Vay, Edoardo Zoni" | ||
|
|
||
| # -- General configuration --------------------------------------------------- | ||
| # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration | ||
|
|
||
| extensions = ["myst_parser", "sphinx_copybutton"] | ||
| myst_heading_anchors = 2 | ||
|
|
||
| templates_path = ["_templates"] | ||
| exclude_patterns = [] | ||
|
|
||
| # -- Options for HTML output ------------------------------------------------- | ||
| # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output | ||
|
|
||
| html_theme = "sphinx_book_theme" | ||
| html_theme_options = { | ||
| "show_navbar_depth": 1, | ||
| "max_navbar_depth": 1, | ||
| } | ||
| html_static_path = [] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To discuss: