Skip to content

Commit

Permalink
Support for installing dependencies with conda (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
tesfaldet authored Mar 8, 2023
1 parent 745b37b commit 2c2641c
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 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
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

0 comments on commit 2c2641c

Please sign in to comment.