Skip to content

Commit cc46448

Browse files
authored
New documentation pipeline (#1037)
1 parent 20f4cc7 commit cc46448

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2281
-35023
lines changed

.github/workflows/build-docs.yaml

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,44 @@
1-
name: "build-docs"
1+
name: build-docs
22
on:
33
push:
4-
branches: ["main"]
4+
branches: [main]
55
pull_request:
6-
branches: ["main"]
7-
workflow_dispatch:
6+
branches: [main]
87

98
jobs:
109
build-docs:
1110
runs-on: ubuntu-latest
1211
steps:
13-
- name: Clone repo
14-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
12+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1513
with:
1614
submodules: "true"
17-
- name: Clone docs repo
18-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19-
with:
20-
repository: Nixtla/docs
21-
ref: scripts
22-
path: docs-scripts
15+
2316
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2417
with:
25-
python-version: "3.10"
26-
- name: Build docs
27-
run: |
28-
set -ux
29-
pip install uv && uv pip install --system ".[all]"
30-
mkdir nbs/_extensions
31-
cp -r docs-scripts/mintlify/ nbs/_extensions/
32-
python docs-scripts/update-quarto.py
33-
echo "procs = nbdev_plotly.plotly:PlotlyProc" >> settings.ini
34-
nbdev_docs
35-
- name: Apply final formats
36-
run: bash ./docs-scripts/docs-final-formatting.bash
37-
- name: Copy over necessary assets
18+
python-version: '3.10'
19+
20+
- name: Install dependencies
3821
run: |
39-
cp nbs/mint.json _docs/mint.json
40-
cp docs-scripts/imgs/* _docs/
41-
- name: Deploy to Mintlify Docs
22+
pip install -e '.[all]' lazydocs pyyaml
23+
24+
# setup quarto for rendering example/tutorial nbs
25+
- uses: quarto-dev/quarto-actions/setup@v2
26+
with:
27+
version: 1.4.515
28+
29+
- name: Build Docs
30+
run: make all_docs
31+
32+
- name: Deploy
4233
if: github.event_name == 'push'
4334
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
4435
with:
4536
github_token: ${{ secrets.GITHUB_TOKEN }}
4637
publish_branch: docs
47-
publish_dir: ./_docs
38+
publish_dir: docs/mintlify
4839
user_name: github-actions[bot]
4940
user_email: 41898282+github-actions[bot]@users.noreply.github.com
41+
5042
- name: Trigger mintlify workflow
5143
if: github.event_name == 'push'
5244
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@@ -59,14 +51,3 @@ jobs:
5951
workflow_id: 'mintlify-action.yml',
6052
ref: 'main',
6153
});
62-
- name: Configure redirects for gh-pages
63-
run: python docs-scripts/configure-redirects.py statsforecast
64-
- name: Deploy to Github Pages
65-
if: github.event_name == 'push'
66-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
67-
with:
68-
github_token: ${{ secrets.GITHUB_TOKEN }}
69-
publish_branch: gh-pages
70-
publish_dir: ./gh-pages
71-
user_name: github-actions[bot]
72-
user_email: 41898282+github-actions[bot]@users.noreply.github.com

.github/workflows/ci.yaml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,7 @@ jobs:
5858
CIBW_BEFORE_TEST: >
5959
yum install -y java-17-openjdk
6060
CIBW_TEST_COMMAND: >
61-
uv pip install -r {project}/setup.py --extra all &&
62-
nbdev_test --path {project}/nbs/ --skip_file_re "(distributed|prophet).*.ipynb" --pause 1.0 --do_print --timing &&
63-
pytest --durations=0 {project}/action_files -k "not efficiency"
64-
65-
- name: Build wheels and run local tests
66-
if: matrix.os-platform[0] != 'ubuntu-latest'
67-
uses: pypa/cibuildwheel@5f22145df44122af0f5a201f93cf0207171beca7 # v3.0.0
68-
env:
69-
CIBW_BUILD: cp${{ matrix.python-version }}-${{ matrix.os-platform[1] }}
70-
CIBW_TEST_COMMAND: >
71-
uv pip install -r {project}/setup.py --extra dev --extra plotly &&
72-
python {project}/action_files/nbdev_test --path {project}/nbs/ --skip_file_re "(distributed|prophet).*.ipynb" --pause 1.0 --do_print --timing
61+
uv pip install -r {project}/setup.py --extra all && pytest --durations=0 {project}/action_files -k "not efficiency" --no-cov
7362
7463
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
7564
if: github.event_name == 'push'
@@ -140,10 +129,10 @@ jobs:
140129
python-version: "3.13"
141130

142131
- name: Install dependencies
143-
run: pip install uv && uv pip install --system . pytest-codspeed pytest-xdist
132+
run: pip install uv && uv pip install --system . pytest-cov pytest-codspeed pytest-xdist
144133

145134
- name: Run benchmarks
146135
uses: CodSpeedHQ/action@0010eb0ca6e89b80c88e8edaaa07cfe5f3e6664d # 3.5.0
147136
with:
148137
token: ${{ secrets.CODESPEED_TOKEN }}
149-
run: pytest action_files/test_efficiency.py --codspeed -n 2
138+
run: pytest action_files/test_efficiency.py --codspeed -n 2 --no-cov

.github/workflows/pytest.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ jobs:
2222
steps:
2323
- name: Clone repo
2424
uses: actions/checkout@v4
25+
with:
26+
submodules: true
2527

2628
- uses: actions/setup-python@v5
2729
with:
2830
python-version: ${{ matrix.python-version }}
2931

3032
- name: Install dependencies
31-
run: |
32-
git submodule status
33-
git submodule update --init --recursive
34-
pip install uv && uv pip install --system ".[all]"
33+
run: pip install -e ".[all]"
3534

3635
- name: Run pytest
37-
run: pytest tests --ignore tests/test_distributed_fugue.py
36+
run: pytest

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,17 @@ mlruns/
2626
.luarc.json
2727
*.so
2828
*.dll
29+
30+
31+
# ignore files created in the docs folder
32+
docs/*.md
33+
docs/**/*.mdx
34+
35+
docs-scripts
36+
docs/mintlify/examples
37+
38+
nbs/_extensions
39+
.quarto
40+
41+
*.png
42+
.coverage*

.pre-commit-config.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
11
fail_fast: true
22

33
repos:
4-
- repo: local
5-
hooks:
6-
- id: imports_with_code
7-
name: Cells with imports and code
8-
entry: python action_files/imports_with_code.py
9-
language: system
10-
- id: nbdev_clean
11-
name: Clean notebooks
12-
entry: sh action_files/clean_nbs
13-
language: system
14-
15-
- repo: https://github.com/fastai/nbdev
16-
rev: 2.2.10
17-
hooks:
18-
- id: nbdev_export
194
- repo: https://github.com/astral-sh/ruff-pre-commit
205
rev: v0.2.1
216
hooks:
227
- id: ruff
238
files: python/statsforecast
9+
2410
- repo: https://github.com/pre-commit/mirrors-mypy
2511
rev: v1.8.0
2612
hooks:

CONTRIBUTING.md

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,27 @@ Sometimes, diving into a new technology can be challenging and overwhelming. We'
66

77
## Table of Contents 📚
88

9-
1. [Prerequisites](#prerequisites)
10-
2. [Git `fork-and-pull` worklow](#git-fork-and-pull-worklow)
11-
3. [Set Up a Virtual Environment](#set-up-a-virtual-environment)
12-
4. [Install required libraries for development](#install-required-libraries-for-development)
13-
5. [Start editable mode](#start-editable-mode)
14-
6. [Set Up your Notebook based development environment](#set-up-your-notebook-based-development-environment)
15-
7. [Start Coding](#start-coding)
16-
8. [Example with Screen-shots](#example-with-screen-shots)
9+
- [Step-by-step Contribution Guide](#step-by-step-contribution-guide)
10+
- [Table of Contents 📚](#table-of-contents-)
11+
- [Prerequisites](#prerequisites)
12+
- [Git `fork-and-pull` worklow](#git-fork-and-pull-worklow)
13+
- [Set Up a Virtual Environment](#set-up-a-virtual-environment)
14+
- [Install required libraries for development](#install-required-libraries-for-development)
15+
- [Setup pre-commit hooks](#setup-pre-commit-hooks)
16+
- [Start editable mode](#start-editable-mode)
17+
- [Re-compiling the shared library](#re-compiling-the-shared-library)
18+
- [Set Up your Notebook based development environment](#set-up-your-notebook-based-development-environment)
19+
- [Running tests](#running-tests)
20+
- [Viewing documentation locally](#viewing-documentation-locally)
21+
- [Install `quarto`](#install-quarto)
22+
- [Install mintlify](#install-mintlify)
23+
- [Start Coding](#start-coding)
24+
- [Example with Screen-shots](#example-with-screen-shots)
25+
- [1. Create a fork of the mlforecast repo](#1-create-a-fork-of-the-mlforecast-repo)
26+
- [2. Clone the repository](#2-clone-the-repository)
27+
- [3. Make the changes you want](#3-make-the-changes-you-want)
28+
- [4. Create a pull request](#4-create-a-pull-request)
29+
- [Notes](#notes)
1730

1831
## Prerequisites
1932

@@ -42,7 +55,7 @@ Branching in GitHub is a key strategy for effectively managing and isolating cha
4255

4356
After testing, branches are merged back into the main branch via a pull request, and then typically deleted to maintain a clean repository. You can read more about github and branching [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository).
4457

45-
## Set Up a Virtual Environment
58+
## Set Up a Virtual Environment
4659

4760
> If you want to use Docker or Codespaces, let us know opening an issue and we will set you up.
4861
@@ -71,25 +84,50 @@ Install the library in editable mode using `uv pip install --no-build-isolation
7184
By using the `-e` flag the package is linked directly to the source code, allowing any changes made to the source code to be immediately reflected in your Python environment without the need to reinstall the package. This is useful for testing changes during package development.
7285

7386
### Re-compiling the shared library
87+
7488
If you're working on the C++ code, you'll need to re-compile the shared library, which can be done with: `python setup.py build_ext --inplace` (this will compile it into the `build` directory and copy it to the python package location).
7589

7690
## Set Up your Notebook based development environment
7791

78-
Notebook-based development refers to using interactive notebooks, such as Jupyter Notebooks, for coding, data analysis, and visualization. Here's a brief description of its characteristics:
92+
Notebooks are only used in the project for how-to-guides and code-walkthroughs.
93+
94+
## Running tests
95+
96+
To run the tests, run
97+
98+
```sh
99+
uv run pytest
100+
```
101+
102+
## Viewing documentation locally
103+
104+
The new documentation pipeline relies on `quarto`, `mintlify` and `lazydocs`.
105+
106+
### Install `quarto`
79107

80-
1. **Interactivity**: Code in notebooks is written in cells which can be run independently. This allows for iterative development and testing of small code snippets.
108+
Install `quarto` from → [this link](https://quarto.org/docs/get-started/)
81109

82-
2. **Visualization**: Notebooks can render charts, tables, images, and other graphical outputs within the same interface, making it great for data exploration and analysis.
110+
### Install mintlify
83111

84-
3. **Documentation**: Notebooks support Markdown and HTML, allowing for detailed inline documentation. Code, outputs, and documentation are in one place, which is ideal for tutorials, reports, or sharing work.
112+
> [!NOTE]
113+
> Please install Node.js before proceeding.
85114
86-
For notebook based development you'll need `nbdev` and a notebook editor (such as VS Code, Jupyter Notebook or Jupyter Lab). `nbdev` and jupyter have been installed in the previous step. If you use VS Code follow [this tutorial](https://code.visualstudio.com/docs/datascience/jupyter-notebooks).
115+
```sh
116+
npm i -g mint
117+
```
87118

88-
[nbdev](https://github.com/fastai/nbdev) makes debugging and refactoring your code much easier than in traditional programming environments since you always have live objects at your fingertips. `nbdev` also promotes software engineering best practices because tests and documentation are first class.
119+
For additional instructions, you can read about it → [this link](https://mintlify.com/docs/installation).
89120

90-
All your changes must be written in the notebooks contained in the library (under the `nbs` directory). Once a specific notebook is open (more details to come), you can write your Python code in cells within the notebook, as you would do in a traditional Python development workflow. You can break down complex problems into smaller parts, visualizing data, and documenting your thought process. Along with your code, you can include markdown cells to add documentation directly in the notebook. This includes explanations of your logic, usage examples, and more. Also, `nbdev` allows you to write [tests inline](https://nbdev.fast.ai/tutorials/best_practices.html#document-error-cases-as-tests) with your code in your notebook. After writing a function, you can immediately write tests for it in the following cells.
121+
```sh
122+
uv pip install -e '.[dev]' lazydocs
123+
make all_docs
124+
```
91125

92-
Once your code is ready, `nbdev` can automatically convert your notebook into Python scripts. Code cells are converted into Python code, and markdown cells into comments and docstrings.
126+
Finally to view the documentation
127+
128+
```sh
129+
make preview_docs
130+
```
93131

94132
## Start Coding
95133

@@ -99,7 +137,6 @@ Open a jupyter notebook using `jupyter lab` (or VS Code).
99137

100138
2. **Commit Your Changes:** Add the changed files using `git add [your_modified_file_0.ipynb] [your_modified_file_1.ipynb]`, then commit these changes using `git commit -m "<type>: <Your descriptive commit message>"`. Please use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
101139

102-
103140
3. **Push Your Changes:**
104141
Push your changes to the remote repository on GitHub with `git push origin feature/your-feature-name`.
105142

@@ -116,6 +153,7 @@ You can find a detailed step by step buide with screen-shots below.
116153
## Example with Screen-shots
117154

118155
### 1. Create a fork of the mlforecast repo
156+
119157
The first thing you need to do is create a fork of the GitHub repository to your own account:
120158
![image](https://github.com/Nixtla/how-to-contribute-nixtlaverse/assets/10517170/af767f5b-66f1-4068-9dd2-917096285ae9)
121159

@@ -149,7 +187,7 @@ You will end up with something like this:
149187

150188
![image](https://github.com/Nixtla/how-to-contribute-nixtlaverse/assets/10517170/ea4aed6f-2000-4ec8-a242-36b9dfd68d26)
151189

152-
### 3. Make the changes you want.
190+
### 3. Make the changes you want
153191

154192
In this section, we assume that we want to increase the default number of windows used to create prediction intervals from 2 to 3. The first thing we need to do is create a specific branch for that change using `git checkout -b [new_branch]` like this:
155193

@@ -181,8 +219,7 @@ Finally, push your changes using `git push`:
181219

182220
![image](https://github.com/Nixtla/how-to-contribute-nixtlaverse/assets/10517170/49c6851c-949b-4ca7-ac38-6b17ec103437)
183221

184-
185-
### 4. Create a pull request.
222+
### 4. Create a pull request
186223

187224
In GitHub, open your repository that contains your fork of the original repo. Once inside, you will see the changes you just pushed. Click on "Compare and pull request":
188225

@@ -196,6 +233,6 @@ Finally, you will see something like this:
196233

197234
![image](https://github.com/Nixtla/how-to-contribute-nixtlaverse/assets/10517170/846c0b97-46d2-492b-a58e-3e9f669c1632)
198235

199-
200236
## Notes
237+
201238
- This file was generated using [this file](https://github.com/Nixtla/nixtla-commons/blob/main/docs/contribute/step-by-step.md). Please change that file if you want to enhance the document.

Makefile

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
include dev/.help.mk
2-
3-
SHELL := /bin/bash
1+
SHELL := /bin/bash
42
CURR_DIR := $(CURDIR)
53

64
START_COMMAND := jupyter-lab --allow-root
@@ -18,11 +16,46 @@ buildless: # Run jupyter notebook using Docker image without building the image
1816
@docker run --name statsforecast --rm -d --network host -v $(CURR_DIR):/workdir/ statsforecast $(START_COMMAND)
1917
@docker exec statsforecast $(PIPINSTALLE)
2018

21-
address: # Show the ipaddress and port of Jupyter Notebook
19+
address: # Show the ipaddress and port of Jupyter Notebook
2220
@docker exec statsforecast $(JUPYTER_LIST)
2321

2422
stop: # Stops statsforecast container
2523
@docker stop statsforecast
2624

2725
remove: # Deletes statsforecast Docker image
2826
@docker image rm statsforecast
27+
28+
load_docs_scripts:
29+
if [ ! -d "docs-scripts" ] ; then \
30+
git clone -b scripts https://github.com/Nixtla/docs.git docs-scripts --single-branch; \
31+
fi
32+
33+
api_docs:
34+
cd python && lazydocs .statsforecast --no-watermark --output-path ../docs
35+
python docs/to_mdx.py
36+
37+
examples_docs:
38+
mkdir -p nbs/_extensions
39+
cp -r docs-scripts/mintlify/ nbs/_extensions/mintlify
40+
python docs-scripts/update-quarto.py
41+
quarto render nbs/docs --output-dir ../docs/mintlify/
42+
quarto render nbs/src --output-dir ../docs/mintlify/
43+
quarto render nbs/blog --output-dir ../docs/mintlify/
44+
45+
format_docs:
46+
# replace _docs with docs
47+
sed -i -e 's/_docs/docs/g' ./docs-scripts/docs-final-formatting.bash
48+
bash ./docs-scripts/docs-final-formatting.bash
49+
find docs/mintlify -name "*.mdx" -exec sed -i.bak '/^:::/d' {} + && find docs/mintlify -name "*.bak" -delete
50+
51+
# replace <= with \<=
52+
find docs/mintlify -name "*.mdx" -exec sed -i.bak 's/<=/\\<=/g' {} + && find docs/mintlify -name "*.bak" -delete
53+
54+
preview_docs:
55+
cd docs/mintlify && mintlify dev
56+
57+
clean:
58+
rm -f docs/*.md
59+
find docs/mintlify -name "*.mdx" -exec rm -f {} +
60+
61+
all_docs: load_docs_scripts api_docs examples_docs format_docs

0 commit comments

Comments
 (0)