Skip to content

Unify example notebooks, rerun example notebooks #1330

Merged
merged 11 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-
- Unify errors, warnings and checks in models ([#1312](https://github.com/tinkoff-ai/etna/pull/1312))
- Merge User Guide and API sections in documentation, limit classes to show in API section ([#1324](https://github.com/tinkoff-ai/etna/pull/1324))
- Unify example notebooks, rerun example notebooks ([#1330](https://github.com/tinkoff-ai/etna/pull/1330))

### Fixed
-
Expand Down
97 changes: 55 additions & 42 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Every good PR usually consists of:

## Step-by-step guide

### Before the PR
### 1. Before the PR
Please ensure that you have read the following docs:
- [changelog](https://github.com/tinkoff-ai/etna/blob/master/CHANGELOG.md)
- [documentation](https://etna-docs.netlify.app/)
- [tutorials](https://github.com/tinkoff-ai/etna/tree/master/examples)
- [changelog](https://github.com/tinkoff-ai/etna/blob/master/CHANGELOG.md)

### Setting up your development environment
### 2. Setting up your development environment

Before writing any code it is useful to set up a development environment.
1. Clone etna library to some folder and go inside:
Expand All @@ -35,19 +35,24 @@ poetry install -E all-dev
poetry shell
```

To connect virtual environment interpreter to IDE use `which python` command.
To connect virtual environment interpreter to IDE the `which python` command can be useful.

### 3. Suggesting a feature (optional)

### New feature
This is an optional step, you could skip it if you want to take some of the existing tasks.

1. Make an issue with your feature description;
2. We shall discuss the design and its implementation details;
3. Once we agree that the plan looks good, go ahead and implement it.

### Bugfix
### 4. Choosing a task

1. Goto [GitHub issues](https://github.com/tinkoff-ai/etna/issues);
2. Pick an issue and comment on the task that you want to work on this feature;
alex-hse-repository marked this conversation as resolved.
Show resolved Hide resolved
3. If you need more context on a specific issue, please ask, and we will discuss the details.
2. Pick an issue with status "Todo" on a [board](https://github.com/orgs/tinkoff-ai/projects/2)
3. Leave a comment in the issue that you want to work on this task;
4. If you need more context on a specific issue, please ask, and we will discuss the details.

### 5. Doing a task

You can also join our [ETNA Community telegram chat](https://t.me/etna_support) to make it easier to discuss.
Once you finish implementing a feature or bugfix, please send a Pull Request.
Expand All @@ -56,59 +61,28 @@ If you are not familiar with creating a Pull Request, here are some guides:
- [Creating a pull request](https://help.github.com/articles/creating-a-pull-request/);
- [Creating a pull request from a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).

### Tests
### 6. Writing tests

Do not forget to check that your code passes the unit tests.
Do not forget to check that your code passes the unit tests.
```bash
poetry install -E tests

pytest tests -v
pytest etna -v --doctest-modules
```

ETNA uses the [`black`](https://github.com/psf/black) and [`flake8`](https://github.com/pycqa/flake8) with several plugins
for coding style checks as well as [`mypy`](https://github.com/python/mypy) for type checks, and you must ensure that your code follows it.
```bash
poetry install -E style

make format
```

If any of checks fails, the CI will fail and your Pull Request won't be merged.

### Documentation
### 7. Writing a documentation

ETNA uses [Numpydoc style](https://numpydoc.readthedocs.io/en/latest/format.html) for formatting docstrings.
The documentation is written in ReST.
Length of a line inside docstrings block must be limited to 100 characters to fit into Jupyter documentation popups.

You could check the docs with:
```bash
make build-docs
```

Now you could open them into your browser, for example with
```bash
open ./build/html/index.html
```

If you have some issues with building docs - please make sure that you installed the required packages.

```bash
poetry install -E docs
```
You also may need to install pandoc package ([pandoc installation guide](https://pandoc.org/installing.html)):
```bash
# Ubuntu
apt-get update && apt-get install -y pandoc

# Mac OS
brew install pandoc

#Windows
choco install pandoc
```

During creation of Pull Request make sure that your documentation looks good, check:
1. `Parameters` and `Returns` sections have correct names and types;
2. Sections should be
Expand All @@ -126,3 +100,42 @@ Useful links:
3. [ReST Cross-referencing Python objects](https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#cross-referencing-python-objects)
4. [Matplotlib Cheetsheet](https://matplotlib.org/sampledoc/cheatsheet.html)
5. [Sklearn example](https://github.com/scikit-learn/scikit-learn/blob/37ac6788c/sklearn/linear_model/_ridge.py#L321)

The simplest way to check how documentation is rendered is to make a pull request.
CI will build it, publish and attach a link to the pull request.

#### 7.1 Adding tutorials (optional)

If you are going to add a jupyter notebook tutorial:
1. Add the notebook into `examples` folder with its prepended number.
2. Add "launch binder" button to the notebook.
3. Add "Table of contents" for headings of the levels 2 and 3.
4. Install extensions that are necessary for this notebook to run.
5. Add imports that are unrelated to the topic of the tutorial at the very top.
6. Add new notebook with its table of contents to the `examples/README.md`
7. Add new notebook with to the `README.md`

#### 7.2 Building locally (optional)

You can also build the documentation locally.
Before building the documentation you may need to install a pandoc package ([pandoc installation guide](https://pandoc.org/installing.html)):
```bash
# Ubuntu
apt-get update && apt-get install -y pandoc

# Mac OS
brew install pandoc

# Windows
choco install pandoc
```

After that, you can try to build the docs with:
```bash
cd docs
make build-docs
```

You could check the result in your browser by opening `build/html/index.html` file.

If you have some issues with building docs - please make sure that you installed the required packages.
alex-hse-repository marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ imported-deps-check:

notebooks-check:
black --check examples/*.ipynb
nbqa isort --sl -c examples/

format-examples:
isort --sl examples/**/*.py
Expand All @@ -38,6 +39,7 @@ format-examples:
format:
isort --skip etna/libs --sl etna/
isort --skip etna/libs --sl tests/
nbqa isort --sl examples/
black etna/
black tests/
black examples/*.ipynb
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,24 @@ To set up a configuration for your project you should create a `.etna` file at t

We have also prepared a set of tutorials for an easy introduction:

| Notebook | Interactive launch |
|:----------|------:|
| [Get started](https://github.com/tinkoff-ai/etna/tree/master/examples/get_started.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/get_started.ipynb) |
| [Backtest](https://github.com/tinkoff-ai/etna/tree/master/examples/backtest.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/backtest.ipynb) |
| [EDA](https://github.com/tinkoff-ai/etna/tree/master/examples/EDA.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/EDA.ipynb) |
| [Regressors and exogenous data](https://github.com/tinkoff-ai/etna/tree/master/examples/exogenous_data.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/exogenous_data.ipynb) |
| [Custom model and transform](https://github.com/tinkoff-ai/etna/tree/master/examples/custom_transform_and_model.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/custom_transform_and_model.ipynb) |
| [Deep learning models](https://github.com/tinkoff-ai/etna/tree/master/examples/NN_examples.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/NN_examples.ipynb) |
| [Ensembles](https://github.com/tinkoff-ai/etna/tree/master/examples/ensembles.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/ensembles.ipynb) |
| [Outliers](https://github.com/tinkoff-ai/etna/tree/master/examples/outliers.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/outliers.ipynb) |
| [Forecasting strategies](https://github.com/tinkoff-ai/etna/tree/master/examples/forecasting_strategies.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/forecasting_strategies.ipynb) |
| [Forecast interpretation](https://github.com/tinkoff-ai/etna/tree/master/examples/forecast_interpretation.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/forecast_interpretation.ipynb) |
| [Clustering](https://github.com/tinkoff-ai/etna/tree/master/examples/clustering.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/clustering.ipynb) |
| [AutoML](https://github.com/tinkoff-ai/etna/tree/master/examples/automl.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/automl.ipynb) |
| [Inference: using saved pipeline on a new data](https://github.com/tinkoff-ai/etna/tree/master/examples/inference.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/inference.ipynb) |
| [Hierarchical time series](https://github.com/tinkoff-ai/etna/blob/master/examples/hierarchical_pipeline.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/hierarchical_pipeline.ipynb) |
| [Classification](https://github.com/tinkoff-ai/etna/blob/master/examples/classification.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/classification.ipynb) |
| [Feature selection](https://github.com/tinkoff-ai/etna/blob/master/examples/feature_selection.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/feature_selection.ipynb) |
| Notebook | Interactive launch |
|:----------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------:|
| [Get started](https://github.com/tinkoff-ai/etna/tree/master/examples/01-get_started.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/01-get_started.ipynb) |
alex-hse-repository marked this conversation as resolved.
Show resolved Hide resolved
| [Backtest](https://github.com/tinkoff-ai/etna/tree/master/examples/02-backtest.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/02-backtest.ipynb) |
| [EDA](https://github.com/tinkoff-ai/etna/tree/master/examples/03-EDA.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/03-EDA.ipynb) |
| [Regressors and exogenous data](https://github.com/tinkoff-ai/etna/tree/master/examples/04-exogenous_data.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/04-exogenous_data.ipynb) |
| [Custom model and transform](https://github.com/tinkoff-ai/etna/tree/master/examples/05-custom_transform_and_model.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/05-custom_transform_and_model.ipynb) |
| [Deep learning models](https://github.com/tinkoff-ai/etna/tree/master/examples/06-NN_examples.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/06-NN_examples.ipynb) |
| [Ensembles](https://github.com/tinkoff-ai/etna/tree/master/examples/07-ensembles.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/07-ensembles.ipynb) |
| [Outliers](https://github.com/tinkoff-ai/etna/tree/master/examples/08-outliers.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/08-outliers.ipynb) |
| [Forecasting strategies](https://github.com/tinkoff-ai/etna/tree/master/examples/09-forecasting_strategies.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/09-forecasting_strategies.ipynb) |
| [Forecast interpretation](https://github.com/tinkoff-ai/etna/tree/master/examples/10-forecast_interpretation.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/10-forecast_interpretation.ipynb) |
| [Clustering](https://github.com/tinkoff-ai/etna/tree/master/examples/11-clustering.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/11-clustering.ipynb) |
| [AutoML](https://github.com/tinkoff-ai/etna/tree/master/examples/12-automl.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/12-automl.ipynb) |
| [Inference: using saved pipeline on a new data](https://github.com/tinkoff-ai/etna/tree/master/examples/13-inference.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/13-inference.ipynb) |
| [Hierarchical time series](https://github.com/tinkoff-ai/etna/blob/master/examples/14-hierarchical_pipeline.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/14-hierarchical_pipeline.ipynb) |
| [Classification](https://github.com/tinkoff-ai/etna/blob/master/examples/15-classification.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/15-classification.ipynb) |
| [Feature selection](https://github.com/tinkoff-ai/etna/blob/master/examples/16-feature_selection.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/tinkoff-ai/etna/master?filepath=examples/16-feature_selection.ipynb) |

## Documentation

Expand Down
16 changes: 15 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,24 @@
f"https://github.com/tinkoff-ai/etna/tree/{release}/examples/{notebook_file}" # noqa
)

nbsphinx_prolog = f"""
nbsphinx_prolog_css_fix = """
.. raw:: html

<style>
alex-hse-repository marked this conversation as resolved.
Show resolved Hide resolved
table {
margin-left: 0;
width: auto;
}
</style>
"""

nbsphinx_prolog_notebook_link = f"""
View Jupyter notebook on the `GitHub <{notebook_url}>`_.
"""

nbsphinx_prolog = nbsphinx_prolog_css_fix + nbsphinx_prolog_notebook_link


# -- Options for linkcode extension ------------------------------------------
# Reference: https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html

Expand Down
32 changes: 16 additions & 16 deletions docs/source/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ Tutorials
:titlesonly:
:maxdepth: 1

tutorials/get_started
tutorials/backtest
tutorials/EDA
tutorials/exogenous_data
tutorials/custom_transform_and_model
tutorials/NN_examples
tutorials/ensembles
tutorials/outliers
tutorials/forecasting_strategies
tutorials/forecast_interpretation
tutorials/clustering
tutorials/automl
tutorials/inference
tutorials/hierarchical_pipeline
tutorials/classification
tutorials/feature_selection
tutorials/01-get_started
tutorials/02-backtest
tutorials/03-EDA
tutorials/04-exogenous_data
tutorials/05-custom_transform_and_model
tutorials/06-NN_examples
tutorials/07-ensembles
tutorials/08-outliers
tutorials/09-forecasting_strategies
tutorials/10-forecast_interpretation
tutorials/11-clustering
tutorials/12-automl
tutorials/13-inference
tutorials/14-hierarchical_pipeline
tutorials/15-classification
tutorials/16-feature_selection
Loading
Loading