Skip to content

Commit

Permalink
Release 2.0 (#33)
Browse files Browse the repository at this point in the history
* feat: add option to specify a temporary folder for the experiment. (#5)

* added option to rsync input and output data

* added docstring

* logging to stdout now

* fixed script for clusters - now using slurm tmpdir to write temp results

* fixing travis

* added missing docstring

* fixed tensorflow part (method signature change)

* renamed variables

* Seed for reproducibility (#6)

* added option to rsync input and output data

* added docstring

* logging to stdout now

* fixed script for clusters - now using slurm tmpdir to write temp results

* fixing travis

* added missing docstring

* fixed tensorflow part (method signature change)

* added seed for pytorch

* fixed typo

* added comment on how to use seed

* fixed flake8

* added test on reproducibility

* removed pytorch part from tensorflow

* fixed cookiecutter syntax

* added check for tensorflow

* fixed typo in test file

* added command to set the seed in tensorflow

* fixed flake8 error

* fixed typos

* removed duplicate log

* typo in docstring

* better error message in test

* added test to check repro using Orion (#8)

* added test to check repro using Orion

* more log into travis

* more info to debug travis

* running two trials for orion

* added seed to orion

* added orion test to tensorflow part

* better log messages in travis

* Add support for keras and Pytorch Lighning (#12)

* added code for keras - still need to complete all tests

* fixed flake8

* started adding PyTorch Lightning support - note that mlflow and loading/saving model still does not work

* fixed api change

* fixed pytorch early stopping

* fixed flake8

* fixed flake8 for pytorch version

* fixed keras part for flake8

* added code to resume a model - for pytorch lightning

* removed forgotten diff

* fixed start_from_scratch (not loading a model even if present) / now printing the val loss in the logs

* pytorch lightning now correctly logging under the same run

* now pytorch is correctly resuming training and continues to plot in the same mlflow run

* added github actions

* using a different ubuntu image

* printing folder - trying to fix github actions

* telling git who I am..

* removed not useful test

* fixed typo in test folder

* removed travis configuration - using github actions from now on

* correctly handling the saved models in pytorch

* now passing the full hyper-parameter object to train_impl method (for more flexibility).

* added option to ask for gpus in pytorch

* improved error message

* Fixups for the lightning_and_keras PR (#12) (#22)

* Update torch model to pl-lightning model

* Refactor train+model impl w/ optim module

* Refactor data loader w/ data module for plightning

* removing codecov from cookeicutter. (#24)

* moving to github actions (#25)

* removing coverage computation

* moving from travis to gitbug actions.

* setting fake name/email for git.

* removed (not-correct) duplicate for github actions config file.

* fixing tests.

* refactored pytorch models. (#26)

Co-authored-by: Mirko Bronzi <[email protected]>

* running CI also on develop.

Co-authored-by: Pierre-Luc St-Charles <[email protected]>

* Adding more CI backends. (#27)

* added github actions.

* moved python version to 3.9 - by default.

* added support for azure continuous integration.

* updated mlflox/orion dependencies.

* now correctly restoring models for pytorch. (#28)

* Now running test-coverage locally. (#30)

* running test coverage locally.

* fixed project name.

* correctly allowing mlflow to work in any folder. (#29)

* removed duplicate CI.

Co-authored-by: Pierre-Luc St-Charles <[email protected]>
  • Loading branch information
mirkobronzi and plstcharles authored May 28, 2021
1 parent 42676a3 commit f139850
Show file tree
Hide file tree
Showing 20 changed files with 637 additions and 376 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: python-3.7
- name: python-3.8
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.8
- name: install-dependencies
run: |
python -m pip install --upgrade pip
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ A cookiecutter is a generic project template that will instantiate a new project

* Pytorch/Tensorflow
* Travis CI
* Codecov
* Sphinx (documentation)
* MLFlow (experiment management)
* Orion (hyperparameter optimization)
Expand Down
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"project_name": "Wonderful Project",
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}",
"project_short_description": "{{ cookiecutter.project_name }} is wonderful!",
"python_version": "3.7",
"python_version": "3.8",
"dl_framework": ["pytorch", "tensorflow_cpu", "tensorflow_gpu"],
"pypi_username": "{{ cookiecutter.github_username }}",
"version": "0.0.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end_pytorch/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pip freeze
sh config/hooks/pre-commit

# run tests
pytest .
pytest --cov=wonderful_project

# run the example
cd examples/local
Expand Down
4 changes: 1 addition & 3 deletions tests/end2end_tensorflow/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ git add -A
git commit -m "initial commit"
pip install -e . --quiet
pip install flake8 pytest --quiet
# necessary cause tf dependencies are sometimes not updated
pip install -U setuptools numpy six --quiet

# print all dependencies
pip freeze
Expand All @@ -24,7 +22,7 @@ pip freeze
sh config/hooks/pre-commit

# run tests
pytest .
pytest --cov=wonderful_project

# run the examples
cd examples/local
Expand Down
27 changes: 27 additions & 0 deletions {{cookiecutter.project_slug}}/.azure_pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
jobs:
- job:
pool:
vmImage: 'ubuntu-16.04'
strategy:
matrix:
Python:
python.version: '{{ cookiecutter.python_version }}'

steps:
- task: UsePythonVersion@0
displayName: 'Use Python $(python.version)'
inputs:
versionSpec: '$(python.version)'

- script: pip install -e .
displayName: 'Install dependencies'

- script: sh config/hooks/pre-commit
displayName: 'Running commit hook'

- script: pytest --cov={{cookiecutter.project_slug}}
displayName: 'Run pytest and display test coverage'

- script: sh run.sh
workingDirectory: examples/local
displayName: 'Run single toy experiment'
39 changes: 39 additions & 0 deletions {{cookiecutter.project_slug}}/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: unit-tests
on:
# Trigger the workflow on push or pull request,
# but only for the main/develop branch
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: python-{{ cookiecutter.python_version }}
uses: actions/setup-python@v2
with:
python-version: {{ cookiecutter.python_version }}
- name: install-dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -e .
- name: flake8
run: |
config/hooks/pre-commit
- name: print env
run: |
env
- name: pytest_and_coverage
run: |
pytest --cov={{cookiecutter.project_slug}}
- name: end2end-toyexp
run: |
cd examples/local
sh run.sh
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
- "3.7"
- "{{ cookiecutter.python_version }}"
cache: pip
install:
# Reducing verbosity is needed because of Travis' limit on log length
Expand All @@ -9,4 +9,4 @@ script:
# run flake8 with exactly the same options as in the commit hook:
- config/hooks/pre-commit
# run tests and compute the coverage
- pytest
- pytest --cov={{cookiecutter.project_slug}}
31 changes: 28 additions & 3 deletions {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,40 @@ link your local git to the remote project, which should look like this:
git remote add origin [email protected]:{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}.git
git push -u origin master

### Add Travis
A travis configuration file (`.travis.yml`) is already in your repository (so, no need to
create it). This will run `flake8` and run the tests under `tests`.
### Setup Continuous Integration

Continuous integration will run the following:
- Unit tests under `tests`.
- End-to-end test under `exmaples/local`.
- `flake8` to check the code syntax.
- Checks on documentation presence and format (using `sphinx`).

We support the following Continuous Integration providers.
Check the following instructions for more details.

#### GitHub Actions

Github actions are already configured in `.github/workflows/tests.yml`.
Github actions are already enabled by default when using Github, so, when
pushing to github, they will be executed automatically for pull requests to
`master` and to `develop`.

#### Travis

Travis is already configured in (`.travis.yml`).

To enable it server-side, just go to https://travis-ci.com/account/repositories and click
` Manage repositories on GitHub`. Give the permission to run on the git repository you just created.

Note, the link for public project may be https://travis-ci.org/account/repositories .

#### Azure

Azure Continuous Integration is already configured in (`.azure_pipeline.yml`).

To enable it server-side, just in azure and select `.azure_pipeline.yml` as the
configuration one for Continuous Integration.

## Running the code

### Run the tests
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/docs/usage/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Everybody loves Schrodinger's equation, why not put it everywhere?

You can also add math directly in your docstrings! For an example, click at the docstrings here:
```eval_rst
:py:meth:`{{cookiecutter.project_slug}}.models.model_loader.load_loss`
:py:meth:`{{cookiecutter.project_slug}}.models.optim.load_loss`
```

You can even reference them directly anywhere for convenience, because clicking is for the lazy:
```eval_rst
.. autoclass:: {{cookiecutter.project_slug}}.models.model_loader.load_loss
.. autoclass:: {{cookiecutter.project_slug}}.models.optim.load_loss
:show-inheritance:
:noindex:
```
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/examples/local/run.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
main --data ../data --output output --config config.yaml --disable-progressbar
main --data ../data --output output --config config.yaml --start-from-scratch
23 changes: 12 additions & 11 deletions {{cookiecutter.project_slug}}/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,36 @@
packages=find_packages(include=['{{ cookiecutter.project_slug }}', '{{ cookiecutter.project_slug }}.*']),
python_requires='>={{ cookiecutter.python_version }}',
install_requires=[
{%- if cookiecutter.dl_framework in ['tensorflow_cpu', 'tensorflow_gpu'] %}
'numpy==1.19.2',
'scipy==1.4.1',
'setuptools>=41.0.0',
'six>=1.15.0',
{%- endif %}
'flake8',
'flake8-docstrings',
'gitpython',
'tqdm',
'jupyter',
'mlflow==1.10.0',
'orion>=0.1.8',
'mlflow==1.15.0',
'orion>=0.1.14',
'pyyaml>=5.3',
'pytest>=4.6',
'pytest-cov',
'sphinx',
'sphinx-autoapi',
'sphinx-rtd-theme',
'sphinxcontrib-napoleon',
'sphinxcontrib-katex',
'recommonmark',
{%- if cookiecutter.dl_framework == 'pytorch' %}
'torch'],
'torch==1.8.1', 'pytorch_lightning==1.2.7'],
{%- endif %}
{%- if cookiecutter.dl_framework == 'tensorflow_cpu' %}
'tensorflow==2.2.0',
'tensorflow==2.4.0'],
{%- endif %}
{%- if cookiecutter.dl_framework == 'tensorflow_gpu' %}
'tensorflow-gpu==2.2.0'
{%- endif %}
{%- if cookiecutter.dl_framework in ['tensorflow_cpu', 'tensorflow_gpu'] %}
'scipy==1.4.1',
'setuptools>=41.0.0',
'six>=1.12.0',
'numpy>=1.19.4'],
'tensorflow-gpu==2.4.0'],
{%- endif %}
entry_points={
'console_scripts': [
Expand Down
11 changes: 0 additions & 11 deletions {{cookiecutter.project_slug}}/tests/test_train.py

This file was deleted.

Loading

0 comments on commit f139850

Please sign in to comment.