Skip to content

Commit

Permalink
tests update + readme (#1215)
Browse files Browse the repository at this point in the history
* tests update + readme

* readme

* workflows changed

* workflows

* readme
  • Loading branch information
Scitator committed May 18, 2021
1 parent a6151d9 commit 3a366c4
Show file tree
Hide file tree
Showing 25 changed files with 406 additions and 20 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/dl_cpu.yml
Expand Up @@ -21,29 +21,29 @@ jobs:
matrix:
os: [ubuntu-18.04, ubuntu-20.04, macOS-10.15] # windows-2019,
python-version: [3.6, 3.7, 3.8]
requirements: ['minimal', 'latest']
requirements: ['latest']
exclude:
# pickle problems
- python-version: 3.8
os: macOS-10.15
- python-version: 3.6
os: macOS-10.15
# github CI problems
- python-version: 3.8
os: ubuntu-18.04
requirements: minimal
- python-version: 3.8
os: ubuntu-20.04
requirements: minimal
- python-version: 3.7
os: ubuntu-18.04
requirements: minimal
- python-version: 3.7
os: ubuntu-20.04
requirements: minimal
- python-version: 3.7
os: macOS-10.15
requirements: minimal
# - python-version: 3.8
# os: ubuntu-18.04
# requirements: minimal
# - python-version: 3.8
# os: ubuntu-20.04
# requirements: minimal
# - python-version: 3.7
# os: ubuntu-18.04
# requirements: minimal
# - python-version: 3.7
# os: ubuntu-20.04
# requirements: minimal
# - python-version: 3.7
# os: macOS-10.15
# requirements: minimal

timeout-minutes: 60
steps:
Expand Down
116 changes: 116 additions & 0 deletions .github/workflows/dl_cpu_minimal.yml
@@ -0,0 +1,116 @@
name: catalyst_minimal
# <- standard block end ->
on:
push:
branches:
- master
pull_request:
branches:
- dev
- develop
- master


jobs:
build:
name: dl-cpu
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
os: [ubuntu-18.04, ubuntu-20.04, macOS-10.15] # windows-2019,
python-version: [3.6, 3.7, 3.8]
requirements: ['minimal']
exclude:
# pickle problems
- python-version: 3.8
os: macOS-10.15
- python-version: 3.6
os: macOS-10.15
# github CI problems
- python-version: 3.8
os: ubuntu-18.04
requirements: minimal
- python-version: 3.8
os: ubuntu-20.04
requirements: minimal
# - python-version: 3.7
# os: ubuntu-18.04
# requirements: minimal
# - python-version: 3.7
# os: ubuntu-20.04
# requirements: minimal
# - python-version: 3.7
# os: macOS-10.15
# requirements: minimal

timeout-minutes: 60
steps:
- uses: actions/checkout@v2

- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

# https://github.com/pytorch/pytorch/issues/20030
- name: Setup macOS
if: startsWith(runner.os, 'macOS')
run: |
brew install libomp
brew install gnu-sed
- name: set minimal dependencies
if: matrix.requirements == 'minimal'
run: |
python -c "req = open('./requirements/requirements.txt').read().replace('>', '=') ; open('./requirements/requirements.txt', 'w').write(req)"
python -c "req = open('./requirements/requirements-cv.txt').read().replace('>', '=') ; open('./requirements/requirements-cv.txt', 'w').write(req)"
python -c "req = open('./requirements/requirements-ml.txt').read().replace('>', '=') ; open('./requirements/requirements-ml.txt', 'w').write(req)"
python -c "req = open('./requirements/requirements-neptune.txt').read().replace('>', '=') ; open('./requirements/requirements-neptune.txt', 'w').write(req)"
# https://github.com/actions/cache/blob/master/examples.md
# Note: This uses an internal pip API and may not always work
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
# - name: get pip cache dir
# id: pip-cache
# run: |
# python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
#
# - name: cache pip
# uses: actions/cache@v2
# with:
# path: ${{ steps.pip-cache.outputs.dir }}
# key: ${{ runner.os }}-${{ matrix.python-version }}-pip -${{ hashFiles('./requirements/requirements.txt') }} -${{ hashFiles('./requirements/requirements-dev.txt') }}
# restore-keys: |
# ${{ runner.os }}-${{ matrix.python-version }}-pip-
#
# - name: cache pip contrib
# uses: actions/cache@v2
# with:
# path: ${{ steps.pip-cache.outputs.dir }}
# key: ${{ runner.os }}-${{ matrix.python-version }}-pip -${{ hashFiles('./requirements/requirements-cv.txt') }} -${{ hashFiles('./requirements/requirements-hydra.txt') }} -${{ hashFiles('./requirements/requirements-ml.txt') }} -${{ hashFiles('./requirements/requirements-optuna.txt') }} -${{ hashFiles('./requirements/requirements-mlflow.txt') }} -${{ hashFiles('./requirements/requirements-nifti.txt') }}
# restore-keys: |
# ${{ runner.os }}-${{ matrix.python-version }}-pip-contrib
#
- name: install dependencies
run: |
# python -m pip install --upgrade --user pip
pip install -r ./requirements/requirements.txt -r ./requirements/requirements-cv.txt -r ./requirements/requirements-dev.txt -r ./requirements/requirements-hydra.txt -r ./requirements/requirements-ml.txt -r ./requirements/requirements-optuna.txt -r ./requirements/requirements-mlflow.txt -r ./requirements/requirements-nifti.txt -r ./requirements/requirements-neptune.txt
python --version
pip --version
pip list
shell: bash
# <- standard block end ->

- name: check examples
env:
REQUIREMENTS: ${{ matrix.requirements }}
OMP_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
run: |
OMP_NUM_THREADS="1" MKL_NUM_THREADS="1" pytest .
pip install -e .
OMP_NUM_THREADS="1" MKL_NUM_THREADS="1" cd examples && bash mnist_stages/run_config.sh && cd ..
OMP_NUM_THREADS="1" MKL_NUM_THREADS="1" cd examples && bash mnist_stages/run_hydra.sh && cd ..
OMP_NUM_THREADS="1" MKL_NUM_THREADS="1" cd examples && bash mnist_stages/run_tune.sh && cd ..
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -11,10 +11,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Reinforcement learning tutorials ([#1205](https://github.com/catalyst-team/catalyst/pull/1205))
- customization demo ([#1207](https://github.com/catalyst-team/catalyst/pull/1207))
- FAQ docs: multiple input and output keys, engine tutorial ([#1202](https://github.com/catalyst-team/catalyst/pull/1202))
- minimal Config API example ([#1215](https://github.com/catalyst-team/catalyst/pull/1215))

### Changed

- tests moved to `tests` folder ([#1208](https://github.com/catalyst-team/catalyst/pull/1208))
- pipeline tests moved to `tests/pipelines` ([#1215](https://github.com/catalyst-team/catalyst/pull/1215))

### Removed

Expand Down
99 changes: 97 additions & 2 deletions README.md
Expand Up @@ -130,7 +130,7 @@ utils.onnx_export(model=runner.model, batch=features_batch, file="./logs/mnist.o
```

### Step-by-step Guide
1. Start with [Catalyst 2021–Accelerated PyTorch 2.0](https://medium.com/catalyst-team/catalyst-2021-accelerated-pytorch-2-0-850e9b575cb6?source=friends_link&sk=865d3c472cfb10379864656fedcfe762) introduction.
1. Start with [Catalyst — A PyTorch Framework for Accelerated Deep Learning R&D](https://medium.com/pytorch/catalyst-a-pytorch-framework-for-accelerated-deep-learning-r-d-ad9621e4ca88?source=friends_link&sk=885b4409aecab505db0a63b06f19dcef) introduction.
1. Check the [minimal examples](#minimal-examples).
1. Try [notebook tutorials with Google Colab](#notebooks).
1. Read the [blog posts](#notable-blog-posts) with use-cases and guides.
Expand Down Expand Up @@ -1447,8 +1447,103 @@ print(study.best_value, study.best_params)
</p>
</details>


<details>
<summary>Config API - minimal example</summary>
<p>

```python
import torch
from torch.utils.data import TensorDataset
from catalyst import dl

NUM_SAMPLES, NUM_FEATURES, NUM_CLASSES = int(1e4), int(1e1), 4
LOGDIR = "./logs"

class CustomConfigRunner(dl.SupervisedConfigRunner):
def get_datasets(self, stage: str):
# sample data
X = torch.rand(NUM_SAMPLES, NUM_FEATURES)
y = (torch.rand(NUM_SAMPLES,) * NUM_CLASSES).to(torch.int64)

# pytorch dataset
dataset = TensorDataset(X, y)
datasets = {"train": dataset, "valid": dataset}
return datasets


runner = CustomConfigRunner(
input_key="features",
output_key="logits",
target_key="targets",
loss_key="loss",
config={
"args": {
"logdir": LOGDIR,
"valid_loader": "valid",
"valid_metric": "accuracy01",
"minimize_valid_metric": False,
"verbose": False,
},
"model": {
"_target_": "Linear",
"in_features": NUM_FEATURES,
"out_features": NUM_CLASSES,
},
"engine": {"_target_": "DeviceEngine"},
"loggers": {
"console": {"_target_": "ConsoleLogger"},
"csv": {"_target_": "CSVLogger", "logdir": LOGDIR},
"tensorboard": {"_target_": "TensorboardLogger", "logdir": LOGDIR},
},
"stages": {
"stage1": {
"num_epochs": 10,
"criterion": {"_target_": "CrossEntropyLoss"},
"optimizer": {"_target_": "Adam", "lr": 1e-3},
"scheduler": {"_target_": "MultiStepLR", "milestones": [2]},
"loaders": {"batch_size": 32, "num_workers": 1},
"callbacks": {
"accuracy": {
"_target_": "AccuracyCallback",
"input_key": "logits",
"target_key": "targets",
"num_classes": NUM_CLASSES,
},
"classification": {
"_target_": "PrecisionRecallF1SupportCallback",
"input_key": "logits",
"target_key": "targets",
"num_classes": NUM_CLASSES,
},
"criterion": {
"_target_": "CriterionCallback",
"input_key": "logits",
"target_key": "targets",
"metric_key": "loss",
},
"optimizer": {"_target_": "OptimizerCallback", "metric_key": "loss"},
"scheduler": {"_target_": "SchedulerCallback"},
"checkpointer": {
"_target_": "CheckpointCallback",
"logdir": LOGDIR,
"loader_key": "valid",
"metric_key": "accuracy01",
"minimize": False,
"save_n_best": 3,
},
},
},
},
},
)
runner.run()
```
</p>
</details>

- [More Catalyst examples](./examples/).
- [Minimal example for Config/Hydra API](https://github.com/catalyst-team/catalyst/tree/master/examples/mnist_stages).
- [Config/Hydra API – full example](https://github.com/catalyst-team/catalyst/tree/master/examples/mnist_stages).


### Features
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Expand Up @@ -211,7 +211,7 @@ Indices and tables
getting_started/quickstart
Minimal examples <https://github.com/catalyst-team/catalyst#minimal-examples>
getting_started/migrating_from_other
Catalyst 2021 — Accelerated PyTorch 2.0 <https://medium.com/catalyst-team/catalyst-2021-accelerated-pytorch-2-0-850e9b575cb6?source=friends_link&sk=865d3c472cfb10379864656fedcfe762>
Catalyst — Accelerated Deep Learning R&D <https://medium.com/pytorch/catalyst-a-pytorch-framework-for-accelerated-deep-learning-r-d-ad9621e4ca88?source=friends_link&sk=885b4409aecab505db0a63b06f19dcef>

.. toctree::
:caption: Tutorials
Expand Down
1 change: 0 additions & 1 deletion tests/catalyst/engines/test_device.py
Expand Up @@ -105,7 +105,6 @@ def train_from_config(device):
"args": {"logdir": logdir},
"model": {"_target_": "DummyModel", "in_features": 4, "out_features": 2},
"engine": {"_target_": "DeviceEngine", "device": device},
"args": {"logdir": logdir},
"stages": {
"stage1": {
"num_epochs": 10,
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 3a366c4

Please sign in to comment.