From 0379417917d335a010870a266deaa2aca67385d5 Mon Sep 17 00:00:00 2001 From: Mirko Bronzi Date: Wed, 22 Jul 2020 11:38:06 -0400 Subject: [PATCH] Add more exp info (#33) * added info on dependencies * added newline * fixed flake8 * fixed typos * printing dependencies now * updated numpy version --- tests/end2end_pytorch/run.sh | 6 ++++-- tests/end2end_tensorflow/run.sh | 6 ++++-- {{cookiecutter.project_slug}}/README.md | 4 ++-- {{cookiecutter.project_slug}}/setup.py | 4 ++-- .../utils/logging_utils.py | 12 ++++++++---- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/end2end_pytorch/run.sh b/tests/end2end_pytorch/run.sh index 305448a..3333a66 100755 --- a/tests/end2end_pytorch/run.sh +++ b/tests/end2end_pytorch/run.sh @@ -7,16 +7,18 @@ cd ${DIR} cookiecutter ../.. --no-input --output-dir=./ cd wonderful_project pip install -e . --quiet +pip install flake8 pytest --quiet # necessary cause tf dependencies are sometimes not updated pip install -U setuptools numpy six --quiet +# print all dependencies +pip freeze + # run flake8 test first -pip install flake8 --quiet sh config/hooks/pre-commit # run tests -pip install pytest --quiet pytest . # run the example diff --git a/tests/end2end_tensorflow/run.sh b/tests/end2end_tensorflow/run.sh index 39b7add..98dea4f 100755 --- a/tests/end2end_tensorflow/run.sh +++ b/tests/end2end_tensorflow/run.sh @@ -7,15 +7,17 @@ cd ${DIR} python -c "from cookiecutter.main import cookiecutter; cookiecutter('../..', no_input=True, extra_context={'dl_framework': 'tensorflow_cpu'}, output_dir='./')" cd wonderful_project pip install -e . --quiet +pip install flake8 pytest --quiet # necessary cause tf dependencies are sometimes not updated pip install -U setuptools numpy six --quiet +# print all dependencies +pip freeze + # run flake8 test first -pip install flake8 --quiet sh config/hooks/pre-commit # run tests -pip install pytest --quiet pytest . # run the examples diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index d092046..83c07f7 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -109,7 +109,7 @@ First, bring you project on the Mila cluster (assuming you didn't create your project directly there). To do so, simply login on the Mila cluster and git clone your project: - git@github.com:{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}.git + git clone git@github.com:{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}.git Then activate your virtual env, and install the dependencies: @@ -153,7 +153,7 @@ To do so, simply run `sh run.sh` N times. When Orion has completed the trials, you will find the orion db file and the mlruns folder (i.e., the folder containing the mlflow results). -You will also find the output of your experiments in `orion_workinf_dir`, which +You will also find the output of your experiments in `orion_working_dir`, which will contain a folder for every trial. Inside these folders, you can find the models (the best one and the last one), the config file with the hyper-parameters for this trial, and the log file. diff --git a/{{cookiecutter.project_slug}}/setup.py b/{{cookiecutter.project_slug}}/setup.py index 00a7176..cc569f8 100644 --- a/{{cookiecutter.project_slug}}/setup.py +++ b/{{cookiecutter.project_slug}}/setup.py @@ -11,7 +11,7 @@ 'flake8-docstrings', 'gitpython', 'tqdm', - 'mlflow', + 'mlflow==1.10.0', 'orion>=0.1.8', 'pyyaml>=5.3', 'pytest>=4.6', @@ -34,7 +34,7 @@ 'scipy==1.4.1', 'setuptools>=41.0.0', 'six>=1.12.0', - 'numpy==1.19'], + 'numpy==1.19.1'], {%- endif %} entry_points={ 'console_scripts': [ diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/logging_utils.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/logging_utils.py index 3a8318d..20f2000 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/logging_utils.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/logging_utils.py @@ -3,6 +3,7 @@ import os import socket +from pip._internal.operations import freeze from git import InvalidGitRepositoryError, Repo from mlflow.utils.mlflow_tags import MLFLOW_RUN_NOTE @@ -63,7 +64,10 @@ def log_exp_details(script_location, args): # pragma: no cover """ git_hash = get_git_hash(script_location) hostname = socket.gethostname() - message = "\nhostname: {}\ngit code hash: {}\ndata folder: {}\ndata folder (abs): {}".format( - hostname, git_hash, args.data, os.path.abspath(args.data)) - logger.info('Experiment info:' + message + '\n') - mlflow.set_tag(key=MLFLOW_RUN_NOTE, value=message) + dependencies = freeze.freeze() + details = "\nhostname: {}\ngit code hash: {}\ndata folder: {}\ndata folder (abs): {}\n\n" \ + "dependencies:\n{}".format( + hostname, git_hash, args.data, os.path.abspath(args.data), + '\n'.join(dependencies)) + logger.info('Experiment info:' + details + '\n') + mlflow.set_tag(key=MLFLOW_RUN_NOTE, value=details)