Skip to content

Commit

Permalink
Format files with pre-commit hooks and improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleve committed May 23, 2022
1 parent 8253ecd commit 84275cd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
7 changes: 3 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# this is example of the file that can be used for storing private and user specific environment variables, like keys or system paths
# create a file named .env (by default .env will be excluded from version control)
# the variables declared in .env are loaded in train.py automatically
# example of file for storing private and user specific environment variables, like keys or system paths
# rename it to ".env" (excluded from version control by default)
# .env is loaded by train.py automatically
# hydra allows you to reference variables in .yaml configs with special syntax: ${oc.env:MY_VAR}

MY_VAR="/home/user/my/system/path"
MY_KEY="asdgjhawi8y23ihsghsueity23ihwd"
4 changes: 3 additions & 1 deletion src/pipelines/_pipeline_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import time
from src import utils

from omegaconf import DictConfig

from src import utils

log = utils.get_logger(__name__)


Expand Down
12 changes: 7 additions & 5 deletions src/pipelines/testing_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
from typing import List, Dict, Tuple, Any

from typing import Any, Dict, List, Tuple

import hydra
from omegaconf import DictConfig
from pytorch_lightning import LightningDataModule, LightningModule, Trainer
from pytorch_lightning.loggers import LightningLoggerBase

from src.pipelines import pipeline_wrapper
from src import utils
from src.pipelines import pipeline_wrapper

log = utils.get_logger(__name__)


@pipeline_wrapper
def test(cfg: DictConfig) -> Tuple[None, Dict[str, Any]]:
"""Contains minimal example of the testing pipeline. Evaluates given checkpoint on a testset.
"""Evaluates given checkpoint on a datamodule testset.
This method is wrapped in @pipeline_wrapper decorator which applies extra utilities
before and after the call.
Args:
cfg (DictConfig): Configuration composed by Hydra.
Returns:
Tuple[None, Dict[str, Any]]
Tuple[None, Dict[str, Any]]: A tuple of None and dictionary with all instantiated objects.
"""

assert cfg.ckpt_path
Expand Down
6 changes: 4 additions & 2 deletions src/pipelines/training_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, List, Dict, Tuple, Any
from typing import Any, Dict, List, Optional, Tuple

import hydra
from omegaconf import DictConfig
Expand All @@ -13,7 +13,9 @@

@pipeline_wrapper
def train(cfg: DictConfig) -> Tuple[Optional[float], Dict[str, Any]]:
"""Contains the training pipeline. Can additionally evaluate model on a testset, using best
"""Contains the training pipeline.
Can additionally evaluate model on a testset, using best
weights obtained during training.
This method is wrapped in @pipeline_wrapper decorator which applies extra utilities
Expand Down
3 changes: 1 addition & 2 deletions src/test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import pyrootutils
import hydra
import pyrootutils
from omegaconf import DictConfig


root = pyrootutils.setup_root(indicator=".git", search_from=__file__)


Expand Down
3 changes: 1 addition & 2 deletions src/train.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import pyrootutils
import hydra
import pyrootutils
from omegaconf import DictConfig


# project root setup
# allows for calling this script from any place
root = pyrootutils.setup_root(
Expand Down

0 comments on commit 84275cd

Please sign in to comment.