Skip to content

Commit

Permalink
Merge branch 'ashleve:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ruhyadi authored Aug 7, 2023
2 parents a072381 + 8055898 commit d23bc9a
Show file tree
Hide file tree
Showing 38 changed files with 513 additions and 219 deletions.
30 changes: 27 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,33 @@ repos:

# python docstring formatting
- repo: https://github.com/myint/docformatter
rev: v1.5.1
rev: v1.7.4
hooks:
- id: docformatter
args: [--in-place, --wrap-summaries=99, --wrap-descriptions=99]
args:
[
--in-place,
--wrap-summaries=99,
--wrap-descriptions=99,
--style=sphinx,
--black,
]

# python docstring coverage checking
- repo: https://github.com/econchick/interrogate
rev: 1.5.0 # or master if you're bold
hooks:
- id: interrogate
args:
[
--verbose,
--fail-under=80,
--ignore-init-module,
--ignore-init-method,
--ignore-module,
--ignore-nested-functions,
-vv,
]

# python check (PEP8), programming errors and code complexity
- repo: https://github.com/PyCQA/flake8
Expand All @@ -53,10 +76,11 @@ repos:
args:
[
"--extend-ignore",
"E203,E402,E501,F401,F841",
"E203,E402,E501,F401,F841,RST2,RST301",
"--exclude",
"logs/*,data/*",
]
additional_dependencies: [flake8-rst-docstrings==0.3.0]

# python security linter
- repo: https://github.com/PyCQA/bandit
Expand Down
8 changes: 4 additions & 4 deletions configs/callbacks/default.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defaults:
- model_checkpoint.yaml
- early_stopping.yaml
- model_summary.yaml
- rich_progress_bar.yaml
- model_checkpoint
- early_stopping
- model_summary
- rich_progress_bar
- _self_

model_checkpoint:
Expand Down
2 changes: 1 addition & 1 deletion configs/debug/fdr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# runs 1 train, 1 validation and 1 test step

defaults:
- default.yaml
- default

trainer:
fast_dev_run: true
2 changes: 1 addition & 1 deletion configs/debug/limit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# uses only 1% of the training data and 5% of validation/test data

defaults:
- default.yaml
- default

trainer:
max_epochs: 3
Expand Down
2 changes: 1 addition & 1 deletion configs/debug/overfit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# overfits to 3 batches

defaults:
- default.yaml
- default

trainer:
max_epochs: 20
Expand Down
2 changes: 1 addition & 1 deletion configs/debug/profiler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# runs with execution time profiling

defaults:
- default.yaml
- default

trainer:
max_epochs: 1
Expand Down
12 changes: 6 additions & 6 deletions configs/eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

defaults:
- _self_
- data: mnist.yaml # choose datamodule with `test_dataloader()` for evaluation
- model: mnist.yaml
- data: mnist # choose datamodule with `test_dataloader()` for evaluation
- model: mnist
- logger: null
- trainer: default.yaml
- paths: default.yaml
- extras: default.yaml
- hydra: default.yaml
- trainer: default
- paths: default
- extras: default
- hydra: default

task_name: "eval"

Expand Down
8 changes: 4 additions & 4 deletions configs/experiment/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# python train.py experiment=example

defaults:
- override /data: mnist.yaml
- override /model: mnist.yaml
- override /callbacks: default.yaml
- override /trainer: default.yaml
- override /data: mnist
- override /model: mnist
- override /callbacks: default
- override /trainer: default

# all parameters below will be merged with parameters from default configurations set above
# this allows you to overwrite only specified parameters
Expand Down
6 changes: 6 additions & 0 deletions configs/hydra/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ run:
sweep:
dir: ${paths.log_dir}/${task_name}/multiruns/${now:%Y-%m-%d}_${now:%H-%M-%S}
subdir: ${hydra.job.num}

job_logging:
handlers:
file:
# Incorporates fix from https://github.com/facebookresearch/hydra/pull/2242
filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log
12 changes: 6 additions & 6 deletions configs/logger/many_loggers.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# train with many loggers at once

defaults:
# - comet.yaml
- csv.yaml
# - mlflow.yaml
# - neptune.yaml
- tensorboard.yaml
- wandb.yaml
# - comet
- csv
# - mlflow
# - neptune
- tensorboard
- wandb
16 changes: 8 additions & 8 deletions configs/train.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# order of defaults determines the order in which configs override each other
defaults:
- _self_
- data: mnist.yaml
- model: mnist.yaml
- callbacks: default.yaml
- data: mnist
- model: mnist
- callbacks: default
- logger: null # set logger here or use command line (e.g. `python train.py logger=tensorboard`)
- trainer: default.yaml
- paths: default.yaml
- extras: default.yaml
- hydra: default.yaml
- trainer: default
- paths: default
- extras: default
- hydra: default

# experiment configs allow for version control of specific hyperparameters
# e.g. best hyperparameters for given model and datamodule
Expand All @@ -22,7 +22,7 @@ defaults:

# optional local config for machine/user specific settings
# it's optional since it doesn't need to exist and is excluded from version control
- optional local: default.yaml
- optional local: default

# debugging config (enable through command line, e.g. `python train.py debug=default)
- debug: null
Expand Down
2 changes: 1 addition & 1 deletion configs/trainer/cpu.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defaults:
- default.yaml
- default

accelerator: cpu
devices: 1
8 changes: 2 additions & 6 deletions configs/trainer/ddp.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
defaults:
- default.yaml
- default

# use "ddp_spawn" instead of "ddp",
# it's slower but normal "ddp" currently doesn't work ideally with hydra
# https://github.com/facebookresearch/hydra/issues/2070
# https://pytorch-lightning.readthedocs.io/en/latest/accelerators/gpu_intermediate.html#distributed-data-parallel-spawn
strategy: ddp_spawn
strategy: ddp

accelerator: gpu
devices: 4
Expand Down
2 changes: 1 addition & 1 deletion configs/trainer/ddp_sim.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defaults:
- default.yaml
- default

# simulate DDP on CPU, useful for debugging
accelerator: cpu
Expand Down
2 changes: 1 addition & 1 deletion configs/trainer/gpu.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defaults:
- default.yaml
- default

accelerator: gpu
devices: 1
2 changes: 1 addition & 1 deletion configs/trainer/mps.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defaults:
- default.yaml
- default

accelerator: mps
devices: 1
5 changes: 3 additions & 2 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ channels:
dependencies:
- pytorch=2.*
- torchvision=0.*
- pytorch-lightning=2.*
- lightning=2.*
- torchmetrics=0.*
- hydra-core=1.*
- rich=13.*
Expand All @@ -35,9 +35,10 @@ dependencies:
# - neptune-client
# - mlflow
# - comet-ml
# - aim>=3.16.2 # no lower than 3.16.2, see https://github.com/aimhubio/aim/issues/2550

- pip>=23
- pip:
- hydra-optuna-sweeper
- hydra-colorlog
- pyrootutils
- rootutils
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hydra-optuna-sweeper==1.2.0
# aim>=3.16.2 # no lower than 3.16.2, see https://github.com/aimhubio/aim/issues/2550

# --------- others --------- #
pyrootutils # standardizing the project root setup
rootutils # standardizing the project root setup
pre-commit # hooks for applying linters on commit
rich # beautiful text formatting in terminal
pytest # tests
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
author="",
author_email="",
url="https://github.com/user/project",
install_requires=["pytorch-lightning", "hydra-core"],
install_requires=["lightning", "hydra-core"],
packages=find_packages(),
# use this to customize global commands available in the terminal after installing the package
entry_points={
Expand Down
Loading

0 comments on commit d23bc9a

Please sign in to comment.