Skip to content

Commit

Permalink
Release v1.5.3 (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleve authored Mar 8, 2023
2 parents ed7dea4 + 6d4b1e6 commit adc6afe
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 7 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ repos:
hooks:
- id: prettier
types: [yaml]
exclude: "environment.yaml"

# shell scripts linter
- repo: https://github.com/shellcheck-py/shellcheck-py
Expand Down
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ The directory structure of new project looks like this:
├── .gitignore <- List of files ignored by git
├── .pre-commit-config.yaml <- Configuration of pre-commit hooks for code formatting
├── .project-root <- File for inferring the position of project root directory
├── environment.yaml <- File for installing conda environment
├── Makefile <- Makefile with commands like `make train` or `make test`
├── pyproject.toml <- Configuration options for testing and linting
├── requirements.txt <- File for installing python dependencies
Expand Down Expand Up @@ -1216,9 +1217,9 @@ ______________________________________________________________________
What it does
## How to run
## Installation
Install dependencies
#### Pip
```bash
# clone project
Expand All @@ -1236,6 +1237,22 @@ conda activate myenv
pip install -r requirements.txt
```

#### Conda

```bash
# clone project
git clone https://github.com/YourGithubName/your-repo-name
cd your-repo-name

# create conda environment and install dependencies
conda env create -f environment.yaml

# activate conda environment
conda activate myenv
```

## How to run

Train model with default configuration

```bash
Expand Down
1 change: 1 addition & 0 deletions configs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# this file is needed here to include configs when building project as a package
43 changes: 43 additions & 0 deletions environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# reasons you might want to use `environment.yaml` instead of `requirements.txt`:
# - pip installs packages in a loop, without ensuring dependencies across all packages
# are fulfilled simultaneously, but conda achieves proper dependency control across
# all packages
# - conda allows for installing packages without requiring certain compilers or
# libraries to be available in the system, since it installs precompiled binaries

name: myenv

channels:
- pytorch
- conda-forge
- defaults

# it is strongly recommended to specify versions of packages installed through conda
# to avoid situation when version-unspecified packages install their latest major
# versions which can sometimes break things

# current approach below keeps the dependencies in the same major versions across all
# users, but allows for different minor and patch versions of packages where backwards
# compatibility is usually guaranteed

dependencies:
- pytorch>=1.10
- torchvision>=0.11
- pytorch-lightning=1.*
- torchmetrics=0.*
- hydra-core=1.*
- rich=13.*
- pre-commit=3.*
- pytest=7.*

# --------- loggers --------- #
# - wandb
# - neptune-client
# - mlflow
# - comet-ml

- pip>=23
- pip:
- hydra-optuna-sweeper
- hydra-colorlog
- pyrootutils
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pytorch-lightning==1.9.1
torchmetrics==0.11.0

# --------- hydra --------- #
hydra-core==1.3.1
hydra-core==1.3.2
hydra-colorlog==1.2.0
hydra-optuna-sweeper==1.2.0

Expand Down
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
description="Describe Your Cool Project",
author="",
author_email="",
url="https://github.com/user/project", # REPLACE WITH YOUR OWN GITHUB PROJECT LINK
url="https://github.com/user/project",
install_requires=["pytorch-lightning", "hydra-core"],
packages=find_packages(),
# use this to customize global commands available in the terminal after installing the package
entry_points={
"console_scripts": [
"train_command = src.train:main",
"eval_command = src.eval:main",
]
},
)
4 changes: 3 additions & 1 deletion src/models/mnist_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def forward(self, x: torch.Tensor):

def on_train_start(self):
# by default lightning executes validation step sanity checks before training starts,
# so we need to make sure val_acc_best doesn't store accuracy from these checks
# so it's worth to make sure validation metrics don't store results from these checks
self.val_loss.reset()
self.val_acc.reset()
self.val_acc_best.reset()

def model_step(self, batch: Any):
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@pytest.fixture(scope="package")
def cfg_train_global() -> DictConfig:
with initialize(version_base="1.2", config_path="../configs"):
with initialize(version_base="1.3", config_path="../configs"):
cfg = compose(config_name="train.yaml", return_hydra_config=True, overrides=[])

# set defaults for all tests
Expand All @@ -32,7 +32,7 @@ def cfg_train_global() -> DictConfig:

@pytest.fixture(scope="package")
def cfg_eval_global() -> DictConfig:
with initialize(version_base="1.2", config_path="../configs"):
with initialize(version_base="1.3", config_path="../configs"):
cfg = compose(config_name="eval.yaml", return_hydra_config=True, overrides=["ckpt_path=."])

# set defaults for all tests
Expand Down

0 comments on commit adc6afe

Please sign in to comment.