-
Notifications
You must be signed in to change notification settings - Fork 482
Developer Wiki
This wiki is for development purposes of the NeuralProphet library.
The user documentation can be found here.
In summary, follow the steps below to make your first contribution. If you want to have more details on every step, check out this beginner's guide to contributing to a GitHub project.
- Setup your development environment for NeuralProphet following this tutorial
- Find an issue to work on by filtering on the label https://github.com/ourownstory/neural_prophet/labels/good%20first%20issue. Comment under the issue, you wish to take over to prevent multiple people working on the same issue.
- Pull the latest changes from remote:
git pull upstream main
- Push changes to your fork:
git push origin main
- Create a new branch from main to work on:
git checkout -b BRANCH_NAME
- Make some changes in your local repository
- Stage the changes:
git add -A
- Commit the changes:
git commit -m "DESCRIPTION OF CHANGES"
- Push changes to your fork:
git push origin BRANCH_NAME
- Do a pull request: If you visit https://github.com/ourownstory/neural_prophet now, there should be a green button saying "Compare & pull request", click on it and describe the changes you did. Now you only need to wait for a review and respond to any feedback.
Congratulations, you just contributed your first pull request. For your next issue just follow the steps starting from number 2.
NeuralProphet uses the Sphinx documentation framework to build the documentation website, which is hosted via Github Pages on www.neuralprophet.com.
The documentation's source is enclosed in the docs folder. Whereas the main
branch only contains the basic source files, the branch gh-pages
entails the build data (with folders docs/html
and docs/doctrees
) and is used for deployment.
Docstrings need to be formatted according to NumPy Style in order to display their API reference correctly using Spinx. Please refer to Pandas Docstring Guide for best practices.
The length of line inside docstrings block must be limited to 80 characters to fit into Jupyter documentation popups.
You can check for adherence to the style guide by running:
pydocstyle --convention=numpy path/my_file.py
(You may need to install the tool first. On Linux: sudo apt install pydocstyle
.)
See how Pandas does this for melt
in their melt documentation page and how it looks in the melt docstring.
Docstring architecture sample:
def return_first_elements(n=5):
"""
Return the first elements of a given Series.
This function is mainly useful to preview the values of the
Series without displaying all of it.
Parameters
----------
n : int
Number of values to return.
Return
------
pandas.Series
Subset of the original series with the n first values.
See Also
--------
tail : Return the last n elements of the Series.
Examples
--------
If you have multi-index columns:
>>> df.columns = [list('ABC'), list('DEF')]
>>> df
A B C
D E F
0 a 1 2
1 b 3 4
2 c 5 6
"""
return self.iloc[:n]
All Jupyter notebooks should be located inside docs/source/
subfolders tutorials
and how-to-guides
.
When you add a new tutorial notebook, please add the new tutorial file names to the index.rst
file inside docs/source/how-to-guides/
or docs/source/tutorials/
, respectively. Follow Sphinx restructured text syntax.
They are then auto-rendered using the Sphinx extension nbsphinx
to html files in the documentation website.
To build the documentation and publish the new website
-
Remove branch protection from
website
branch (allow force push and do not require any reviews) -
Update
website
branch tomain
-
git fetch
make sure you’ve got the latest main branch version locally -
git checkout website
go into website branch - Variant 1 (try first)
git merge origin/main
git push origin website
- Variant 2
-
git reset --hard origin/main
reset website branch to main branch (meaning all changes of main go into website, changes in website would get lost, but there should be none) -
git push origin website -f
-f means force, meaning override the website branch also on github (origin)
-
-
-
GitHub action automatically publishes the new website
- GitHub action config for website
- Website is built with sphinx and pandox, locally with
sphinx-build docs/source _site -j4 -E
(or shortly withmake html
in the docs folder and thenopen html/index.html
). For that you need to install:poetry install --with=docs
brew install pandoc
- Hosting is done with Github pages
- Changes should be reflected instantly on the documentation website.
We are using PyTest
to run tests within our projects. All tests can be found in tests/
directory.
All tests can be triggered via the command:
pytest tests -v
Running specific tests can be done by running the command:
pytest tests -k "name_of_test"
We are using pytest-cov and codecov to create transparent code coverage reports. To locally trigger and output a code coverage report via the commandline, run the following command:
pytest tests -v --cov=./
We are using Github Actions to setup a CI pipeline. The creation as well as single commits to a pull request trigger the CI pipeline.
Currently there is one workflow called .github/worklfows/ci.yml
to trigger testing, create code coverage reports via pytest-cov and subsequently uploading reports via codecov for the major OS systems (Linux, Mac, Windows).
We deploy Black, the uncompromising code formatter, so there is no need to worry about style. Beyond that, where reasonable, for example for docstrings, we follow the Google Python Style Guide
As for Git practices, please follow the steps described at Swiss Cheese for how to git-rebase-squash when working on a forked repo. (Update: all PR are now squashed, so you can skip this step, but it's still good to know.)
Please use the more readable f-string formatting style.
We try to use type annotations across the project to improve code readability and maintainability.
Please follow the official python recommendations for type hints and PEP-484.
The Postponed Evaluation of Annotations PEP 563 provides major benefits for type annotations. To use them with our currently support python versions we must use the following syntax:
from __future__ import annotations
When using type annotations, you may encounter circular imports. To avoid this, you can use the following pattern based on the typing.TYPE_CHECKING constant:
from __future__ import annotations
from typing import TYPE_CHECKING
# Imports only needed for type checking
if TYPE_CHECKING:
from my_module import MyType
To contribute to NeuralProphet from Windows install WSL to run Linux terminal in Windows.
1.Install WSL2.
2.Install libraries
a. pip:This will allow users to quick install using pip.
sudo apt install pip
b.For any ”name” not found try.
pip install <name>
Notes:
- To install NeuralProphet in dev mode, create a venv using the Linux terminal on the subsystem drive (not the mount).
- For any statement error try using sudo and --user which will then allow administrator access to perform the action.
- Create release branch from main (latest version) with
git checkout -b release/x.y.z
- Update version number in project (currently in
pyproject.toml
), set it tox.y.z
- Stage and commit changes,
git commit -m “bump version number to x.y.z"
- Upload changes
git push
- Set token (only first time)
- (For test.pypi:
poetry config pypi-token.test-pypi <your-test-pypi-token>
→ doesn't work yet) - For pypi:
poetry config pypi-token.pypi <you-pypi-token>
(get your token from https://pypi.org/manage/account/token/)
- (For test.pypi:
- Build and publish with poetry
poetry publish --build
- On Github create pull request from
release/x.y.z
tomain
(to update version number in main too) - Create a git tag after the pull request is merged
- Update local directory
git checkout main
andgit pull
- Create a git tag with
git tag x.y.z
- Upload the git tag with
git push --tags
- Update local directory
-
Create a release on Github
- Click on
Choose a tag
and selectx.y.z
- Name it with
Release x.y.z
orBeta x.y.z
- Auto generate release notes (button on the right side)
- Clean up the release notes and group them
- Set as
pre-release
orlatest release
depending on the type - Publish the release
- Click on
- Make an announcement of the release in Slack
Install neuralprophet in an empty environment and check if everything works
Create environment with poetry
poetry init
poetry shell
poetry add neuralprophet==x.y.z
Create environment with venv
python3.9 -m venv .venv
source .venv/bin/activate
pip install neuralprophet==x.y.z
Close the milestone