Skip to content

Commit 01b918c

Browse files
docs: add webapp docs page (#327)
* add action for automatically deploy docs * add webapp readme test file and point to it in the nav * add readme from webapp * improve and adapt readme * ignore webapp readme * add commands for docs build and deploy * integrate make commands * update docs with the new make cmds * Update .github/workflows/deploy-docs.yml Co-authored-by: Cunliang Geng <c.geng@esciencecenter.nl> * rename sync command --------- Co-authored-by: Cunliang Geng <c.geng@esciencecenter.nl>
1 parent c6384b0 commit 01b918c

File tree

6 files changed

+251
-13
lines changed

6 files changed

+251
-13
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy documentation
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types:
7+
- published
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout nplinker
15+
uses: actions/checkout@v4
16+
with:
17+
ref: dev
18+
fetch-tags: true
19+
20+
- name: Fetch gh-pages
21+
run: git fetch origin gh-pages:gh-pages
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.10'
27+
28+
- name: Install dependencies
29+
run: python3 -m pip install .[dev]
30+
31+
- name: Configure Git
32+
run: |
33+
git config user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
34+
git config user.name "GitHub Actions"
35+
git config -l
36+
37+
- name: Sync webapp README and deploy docs
38+
run: |
39+
version=$(git describe --tags --abbrev=0 | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+)-alpha\.([0-9]+)/\1a\2/')
40+
make deploy-docs version=$version

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ webapp/npapp/static/js/bokeh*.js
6464
src/nplinker/scoring/iokr/data/SPEC/
6565
tests/integration/data/nplinker_local_mode_example.zip
6666
strain_mappings.json
67+
68+
# docs
69+
docs/webapp/readme.md

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# .PHONY is used to declare that the targets are not files
2-
.PHONY: install-dev clean clean-build clean-pyc clean-test clean-doc release build update-version
2+
.PHONY: install-dev clean clean-build clean-pyc clean-test clean-doc release build update-version sync-webapp-readme build-docs deploy-docs
33

44
help:
55
@echo "Available commands to 'make':"
@@ -79,4 +79,17 @@ endif
7979
-e 's/version: "$(CURRENT_VERSION)"/version: "$(NEW_VERSION)"/' $$file; \
8080
fi; \
8181
done
82-
@echo "Version update complete."
82+
@echo "Version update complete."
83+
84+
sync-webapp-readme:
85+
mkdir -p docs/webapp
86+
curl -sSf https://raw.githubusercontent.com/NPLinker/nplinker-webapp/main/README.md -o docs/webapp/readme.md
87+
88+
build-docs: sync-webapp-readme
89+
mkdocs serve
90+
91+
deploy-docs: sync-webapp-readme
92+
ifndef version
93+
$(error version is not set. Usage: make deploy-docs version=YOUR_VERSION)
94+
endif
95+
mike deploy -p -u $(version) latest

README.dev.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,22 +132,45 @@ mkdocs serve -w docs -w src
132132
Then open your browser and go to [http://127.0.0.1:8000/](http://127.0.0.1:8000/).
133133

134134
### Publishing the docs
135-
The docs are published on github pages. We use [mike](https://github.com/jimporter/mike)
136-
to deploy the docs to the `gh-pages` branch and to manage the versions of docs.
137135

138-
For example, to deploy the version 2.0 of the docs to the `gh-pages` branch and make it the latest
139-
version, run:
140-
```shell
141-
mike deploy -p -u 2.0 latest
136+
Documentation is published to GitHub Pages using [mike](https://github.com/jimporter/mike), which also manages versioning on the `gh-pages` branch.
137+
138+
#### Deploying a new version
139+
140+
To deploy version `2.0` of the docs and mark it as the latest, run:
141+
142+
```bash
143+
make deploy-docs version=2.0
144+
```
145+
146+
This command does the following:
147+
148+
* Fetches the latest README from the [`nplinker-webapp`](https://github.com/NPLinker/nplinker-webapp) repository.
149+
* Builds and deploys the documentation to the `gh-pages` branch.
150+
* Updates the `latest` alias to point to this version.
151+
* Creates a commit on the `gh-pages` branch to record the deployment.
152+
153+
If you want to undo a deployment, you can run:
154+
155+
```bash
156+
mike delete 2.0
142157
```
143-
If you are not happy with the changes you can run `mike delete [version]`.
144-
All these mike operations will be recorded as git commits of branch `gh-pages`.
145158

146-
`mike serve` is used to check all versions committed to branch `gh-pages`, which is for checking
147-
the production website. If you have changes but not commit them yet, you should use `mkdocs serve`
148-
instead of `mike serve` to check them.
159+
#### Previewing the docs
160+
161+
* To preview all committed versions from `gh-pages`, use:
162+
163+
```bash
164+
mike serve
165+
```
166+
167+
* To preview your local, uncommitted changes, use:
149168

169+
```bash
170+
make build-docs
171+
```
150172

173+
> `make build-docs` will also update the webapp README before serving the docs.
151174
152175
## Versioning
153176

docs/webapp/readme.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# NPLinker Web Application
2+
3+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6875502.svg)](https://doi.org/10.5281/zenodo.6875502)
4+
5+
👉 **[Webapp Live Demo](https://nplinker-webapp.onrender.com)**
6+
7+
The [NPLinker](https://nplinker.github.io/nplinker/latest/) web application, built with [Plotly Dash](https://dash.plotly.com/), provides an interactive interface for visualizing NPLinker predictions.
8+
9+
## Online Demo
10+
11+
A live demo of the NPLinker webapp is automatically deployed to [Render](https://render.com/) from `main` branch.
12+
You can try out the webapp directly in your browser [here](https://nplinker-webapp.onrender.com).
13+
14+
### Getting Started with Demo Data
15+
16+
The webapp includes a convenient **"Load Demo Data"** button that automatically loads some sample data for you to try. Simply:
17+
18+
1. Open the [live demo link](https://nplinker-webapp.onrender.com/)
19+
2. Click the **"Load Demo Data"** button below the file uploader
20+
3. The app will automatically download and process the sample dataset from [`tests/data/mock_obj_data.pkl`](https://github.com/NPLinker/nplinker-webapp/blob/main/tests/data/mock_obj_data.pkl)
21+
4. Start exploring natural product linking features!
22+
23+
This demo web server is intended only for lightweight demo purposes. For full functionality, including large-scale data processing and persistent storage, please install the application locally or via Docker as described below.
24+
25+
<details>
26+
<summary>⚠️ Demo Server Limitations</summary>
27+
28+
<p>Please note the following limitations of the hosted demo:</p>
29+
30+
<ul>
31+
<li><strong>Cold start delay</strong>: Free-tier apps on Render sleep after 15 minutes of inactivity and may take 20–30 seconds to wake up.</li>
32+
<li><strong>Performance</strong>: This is a minimal deployment on a free tier and is not optimized for large datasets or concurrent users.</li>
33+
<li><strong>File size limits</strong>: The demo data button loads a small sample dataset suitable for testing. Uploading large datasets via the file uploader may lead to errors or timeouts.</li>
34+
<li><strong>No persistent storage</strong>: Uploaded files are not saved between sessions.</li>
35+
</ul>
36+
37+
</details>
38+
39+
## Using the webapp
40+
41+
### Input Data
42+
43+
The webapp accepts data generated by NPLinker and saved as described in the [NPLinker quickstart section](https://nplinker.github.io/nplinker/latest/quickstart/). For testing purposes, a small sample dataset is provided in [`tests/data/mock_obj_data.pkl`](https://github.com/NPLinker/nplinker-webapp/blob/main/tests/data/mock_obj_data.pkl) that can be used to try out the webapp.
44+
45+
Please note that links between genomic and metabolomic data must currently be computed using the NPLinker API separately, as this functionality is not yet implemented in the webapp (see [issue #19](https://github.com/NPLinker/nplinker-webapp/issues/19)). If no links are present in your data, the scoring table will be disabled.
46+
47+
### Filtering Table Data
48+
49+
The "Candidate Links" tables support data filtering to help you focus on relevant results. You can enter filter criteria directly into each column’s filter cell by hovering over the cell.
50+
51+
For numeric columns like "Average Score" or "# Links":
52+
53+
- `34.6` or `= 34.6` (exact match)
54+
- `> 30` (greater than)
55+
- `<= 50` (less than or equal to)
56+
57+
For text columns like "BGC Classes" or "MiBIG IDs":
58+
59+
- `Polyketide` or `contains Polyketide` (contains text)
60+
- `= Polyketide` (exact match)
61+
62+
Multiple filters can be applied simultaneously across different columns to narrow down results.
63+
64+
For a full list of supported filter operators, see the [official Plotly documentation](https://dash.plotly.com/datatable/filtering#filtering-operators).
65+
66+
## Installation
67+
68+
Before installing NPLinker webapp, ensure you have:
69+
70+
- [Python ≥3.10](https://www.python.org/downloads/)
71+
- [Git](https://git-scm.com/downloads)
72+
- [Conda](https://docs.conda.io/en/latest/miniconda.html)
73+
74+
You can install and run the NPLinker webapp in two ways: directly on your local machine or using Docker.
75+
76+
### Option 1: Local Installation (using Conda)
77+
78+
Follow these steps to install the application directly on your system:
79+
80+
1. **Clone the repository**
81+
```bash
82+
git clone https://github.com/NPLinker/nplinker-webapp.git
83+
cd nplinker-webapp
84+
```
85+
86+
2. **Set up a conda environment**
87+
```bash
88+
# Create a new conda environment with Python 3.10
89+
conda create -n nplinker-webapp python=3.10
90+
91+
# Activate the environment
92+
conda activate nplinker-webapp
93+
```
94+
95+
3. **Install dependencies**
96+
```bash
97+
pip install -e .
98+
```
99+
100+
4. **Run the application**
101+
```bash
102+
python app/main.py
103+
```
104+
105+
5. **Access the webapp**
106+
107+
Open your web browser and navigate to `http://0.0.0.0:8050/`
108+
109+
<details>
110+
<summary>Troubleshooting Local Installation</summary>
111+
112+
<h4>Common issues and solutions</h4>
113+
114+
<ul>
115+
<li><strong>Port already in use</strong>: If port 8050 is already in use, modify the port in <code>app/main.py</code> by changing <code>app.run_server(debug=True, port=8050)</code></li>
116+
<li><strong>Package installation errors</strong>: Make sure you're using Python 3.10 and that your pip is up-to-date</li>
117+
</ul>
118+
119+
<p>If you encounter other problems, please check the <a href="https://github.com/NPLinker/nplinker-webapp/issues">Issues</a> page or create a new issue.</p>
120+
121+
</details>
122+
123+
### Option 2: Docker Installation
124+
125+
Using Docker is the quickest way to get started with NPLinker webapp. Make sure you have [Docker](https://www.docker.com/) installed on your system before proceeding:
126+
127+
1. **Pull the Docker image**
128+
```bash
129+
docker pull ghcr.io/nplinker/nplinker-webapp:latest
130+
```
131+
132+
2. **Run the container**
133+
```bash
134+
docker run -p 8050:8050 ghcr.io/nplinker/nplinker-webapp:latest
135+
```
136+
137+
3. **Access the webapp**
138+
139+
Open your web browser and navigate to `http://0.0.0.0:8050/`
140+
141+
<details>
142+
<summary>Docker Image Information</summary>
143+
144+
<ul>
145+
<li><strong>Available Tags</strong>:
146+
<ul>
147+
<li><code>latest</code>: The most recent build</li>
148+
<li>Specific version tags based on GitHub releases</li>
149+
</ul>
150+
</li>
151+
152+
<li><strong>Performance Note</strong>: The application running in Docker might be slower than running it directly on your machine, depending on your Docker resource allocation settings. If you experience performance issues, consider increasing Docker's CPU and memory limits in your Docker Desktop settings, or use the local installation method.</li>
153+
154+
<li><strong>More Details</strong>: For additional information about the Docker image, see its <a href="https://github.com/NPLinker/nplinker-webapp/pkgs/container/nplinker-webapp">GitHub Container Registry page</a>.</li>
155+
</ul>
156+
157+
</details>

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ nav:
102102
- Scoring Methods: api/scoring_methods.md
103103
- Data Models: api/scoring.md
104104
- Utilities: api/scoring_utils.md
105+
- Webapp:
106+
- Webapp Docs: webapp/readme.md
105107

106108
markdown_extensions:
107109
# https://python-markdown.github.io/extensions/

0 commit comments

Comments
 (0)