diff --git a/{{ cookiecutter.repo_name }}/.github/workflows/codecheck.yaml b/{{ cookiecutter.repo_name }}/.github/workflows/codecheck.yaml index 53d72b0..67ec7c1 100644 --- a/{{ cookiecutter.repo_name }}/.github/workflows/codecheck.yaml +++ b/{{ cookiecutter.repo_name }}/.github/workflows/codecheck.yaml @@ -32,4 +32,4 @@ jobs: - name: Run mypy run: | - mypy {{ cookiecutter.project_name }} --install-types --non-interactive \ No newline at end of file + mypy {{ cookiecutter.project_name }} --install-types --non-interactive diff --git a/{{ cookiecutter.repo_name }}/.github/workflows/tests.yaml b/{{ cookiecutter.repo_name }}/.github/workflows/tests.yaml index 9055d49..3770b9c 100644 --- a/{{ cookiecutter.repo_name }}/.github/workflows/tests.yaml +++ b/{{ cookiecutter.repo_name }}/.github/workflows/tests.yaml @@ -34,10 +34,10 @@ jobs: run: | coverage report -m coverage html - + - name: Upload coverage report if: always() uses: actions/upload-artifact@v2 with: name: coverage-report - path: ./htmlcov \ No newline at end of file + path: ./htmlcov diff --git a/{{ cookiecutter.repo_name }}/.pre-commit-config.yaml b/{{ cookiecutter.repo_name }}/.pre-commit-config.yaml index 0a3655e..fd16ba2 100644 --- a/{{ cookiecutter.repo_name }}/.pre-commit-config.yaml +++ b/{{ cookiecutter.repo_name }}/.pre-commit-config.yaml @@ -7,4 +7,4 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - - id: check-added-large-files \ No newline at end of file + - id: check-added-large-files diff --git a/{{ cookiecutter.repo_name }}/Makefile b/{{ cookiecutter.repo_name }}/Makefile index 86fbe0b..12d0ed7 100644 --- a/{{ cookiecutter.repo_name }}/Makefile +++ b/{{ cookiecutter.repo_name }}/Makefile @@ -146,4 +146,4 @@ else printf "\n"; \ }' \ | more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars') -endif \ No newline at end of file +endif diff --git a/{{ cookiecutter.repo_name }}/requirements.txt b/{{ cookiecutter.repo_name }}/requirements.txt index 08b8331..bbebf4b 100644 --- a/{{ cookiecutter.repo_name }}/requirements.txt +++ b/{{ cookiecutter.repo_name }}/requirements.txt @@ -1,3 +1,3 @@ tensorflow wandb -hydra-core \ No newline at end of file +hydra-core diff --git a/{{ cookiecutter.repo_name }}/requirements_dev.txt b/{{ cookiecutter.repo_name }}/requirements_dev.txt index d5d1d33..b2c8088 100644 --- a/{{ cookiecutter.repo_name }}/requirements_dev.txt +++ b/{{ cookiecutter.repo_name }}/requirements_dev.txt @@ -1,7 +1,7 @@ # pre-commit pre-commit >= 3.5.0 - -{% if cookiecutter.with_docs == 'y' %}# docs +{% if cookiecutter.with_docs == 'y' %} +# docs mkdocs <= 1.5.3 mkdocs-material <= 9.4.6 mkdocstrings <= 0.23.0 diff --git a/{{ cookiecutter.repo_name }}/tests/test_sample.py b/{{ cookiecutter.repo_name }}/tests/test_sample.py index e0312fa..66d6f2f 100644 --- a/{{ cookiecutter.repo_name }}/tests/test_sample.py +++ b/{{ cookiecutter.repo_name }}/tests/test_sample.py @@ -1,2 +1,2 @@ def test_pass(): - assert 1 == 1 \ No newline at end of file + assert 1 == 1 diff --git a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/commiter/commiter.py b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/commiter/commiter.py index 0179cb3..49f77f1 100644 --- a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/commiter/commiter.py +++ b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/commiter/commiter.py @@ -12,7 +12,7 @@ def _run_git_command(*args): def commit_experiment(): - """Tries to find a commit with the same repository state, if unsuccessful, creates a new branch + """Tries to find a commit with the same repository state, if unsuccessful, creates a new branch and commits the current state of the repository there. Returns: @@ -31,7 +31,7 @@ def commit_experiment(): # BUG: When adding a new file or renaming a file (which might be considered as deleting the old file and creating a new one), # the diff command will return a non-empty string, even if the file is the same. This will cause the code to create a new branch # and commit the changes there, even though the changes are not real - + time_tag = int(time.time()*1000) stash_name = "stash_{}".format(time_tag) new_branch = "checkpoint/branch_{}".format(time_tag) @@ -42,7 +42,7 @@ def commit_experiment(): exp_commit_message = _run_git_command('log', '-1', '--pretty="%s"') exp_commit_hash = _run_git_command('log', '-1', '--pretty="%H"') return exp_commit_message, exp_commit_hash - + branches = _run_git_command('branch', '--contains', 'HEAD').split('\n') branches = [x for x in branches if '*' not in x] branches = [x.strip() for x in branches] @@ -52,7 +52,7 @@ def commit_experiment(): exp_commit_message = _run_git_command('log', '-1', '--pretty="%s"', branch) exp_commit_hash = _run_git_command('log', '-1', '--pretty="%H"', branch) return exp_commit_message, exp_commit_hash - + # 3.1. Stash all changes _run_git_command('stash', 'push', '--include-untracked', '-m', stash_name) @@ -72,10 +72,10 @@ def commit_experiment(): # 3.4. Go back to the initial branch and pop the stash there _run_git_command('checkout', initial_branch) _run_git_command('stash', 'pop') - + return exp_commit_message, exp_commit_hash if __name__ == '__main__': commit_message, commit_hash = commit_experiment() print("Commit message: ", commit_message) - print("Commit hash: ", commit_hash) \ No newline at end of file + print("Commit hash: ", commit_hash) diff --git a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/configs/config.yaml b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/configs/config.yaml index a9a56d3..6af62a3 100644 --- a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/configs/config.yaml +++ b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/configs/config.yaml @@ -1,4 +1,4 @@ # training parameters learning_rate: 0.001 epochs: 10 -batch_size: 32 \ No newline at end of file +batch_size: 32 diff --git a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/data/get_data.py b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/data/get_data.py index 05d086a..dadf13b 100644 --- a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/data/get_data.py +++ b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/data/get_data.py @@ -4,4 +4,4 @@ def get_data(): if __name__ == '__main__': - pass \ No newline at end of file + pass diff --git a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/logger/easy_logger.py b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/logger/easy_logger.py index d020c90..04a9614 100644 --- a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/logger/easy_logger.py +++ b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/logger/easy_logger.py @@ -13,10 +13,10 @@ def get_logger(name, level=DEFAULT_LOG_LEVEL, log_path=None, use_rich=False): level (str): Level of the logger. One of "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL". log_path (str): Path to the log file. If None, no log file is created. use_rich (bool): Whether to use rich to beautify the log. - + Returns: logging.Logger: Logger. - + Examples: >>> logger = get_logger(__name__, level="DEBUG", log_path="logs/latest.log", use_rich=False) >>> logger.debug("Used for debugging your code.") @@ -59,7 +59,7 @@ def get_logger(name, level=DEFAULT_LOG_LEVEL, log_path=None, use_rich=False): "stream": "ext://sys.stdout" } config["root"]["handlers"].append("console") - + if log_path: os.makedirs(os.path.dirname(log_path), exist_ok=True) config["handlers"]["file"] = { @@ -73,5 +73,5 @@ def get_logger(name, level=DEFAULT_LOG_LEVEL, log_path=None, use_rich=False): logging.config.dictConfig(config) logger = logging.getLogger(name) - - return logger \ No newline at end of file + + return logger diff --git a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/models/model.py b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/models/model.py index 8d6040a..3e20aaf 100644 --- a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/models/model.py +++ b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/models/model.py @@ -10,4 +10,4 @@ def get_model() -> tf.keras.Model: if __name__ == '__main__': model = get_model() - model.summary() \ No newline at end of file + model.summary() diff --git a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/train_model.py b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/train_model.py index 1363b3b..3d08ee6 100644 --- a/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/train_model.py +++ b/{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/train_model.py @@ -20,11 +20,11 @@ def main(cfg): # initializing time_tag = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") - + exp_commit_message, exp_commit_hash = commit_experiment() - + logger = get_logger(__name__) - + wandb_name = datetime.datetime.strptime(time_tag, "%Y-%m-%d_%H-%M-%S").strftime("%Y-%m-%d %H:%M:%S") # USER: change this line respecting your application wandb.init(entity=..., project="{{ cookiecutter.project_name }}", name=wandb_name) @@ -51,7 +51,7 @@ def main(cfg): opt = tf.keras.optimizers.Adam(learning_rate=cfg.learning_rate) model.compile(optimizer=opt, loss=..., metrics=...) # USER: change this line respecting your application - + best_model_path = "models/{time}/model_best.keras".format(time=time_tag) best_model_callback = tf.keras.callbacks.ModelCheckpoint(best_model_path, save_best_only=True, verbose=0) wandb_callback = WandbCallback(save_model=False, ) # USER: change this line respecting your application @@ -87,4 +87,4 @@ def main(cfg): if __name__ == "__main__": - main() \ No newline at end of file + main()