Skip to content
Snippets Groups Projects
Commit 7ce86099 authored by ferrari's avatar ferrari
Browse files

initial commit

parent fae7fd75
Branches
No related tags found
No related merge requests found
......@@ -2,21 +2,33 @@ import git
import json
import os
import datetime
import argparse
import warnings
import __main__
def log_info(args, path=None):
time = datetime.time()
time = datetime.datetime.now().isoformat()
if isinstance(args, argparse.Namespace):
args = args.__dict__
elif isinstance(args, argparse.ArgumentParser):
args = args.parse_args().__dict__
if path:
if '/' in path:
os.makedirs(path.rsplit('/', 1)[0], exist_ok=True)
else:
if not os.path.isdir('run_log'):
os.makedirs('run_log')
path = 'run_log/' + time.isoformat() + '.json'
path = 'run_log/' + time + '.json'
with open(path, 'w') as logfile:
repo = git.Repo(os.path.dirname(os.path.abspath(__main__.__file__)), search_parent_directories=True)
sha = repo.head.object.hexsha
changes = repo.index.diff(None)
if len(changes):
warnings.simplefilter('always', DeprecationWarning)
warnings.warn(f'{[c.a_path for c in changes]} have differences with current commit',
DeprecationWarning, stacklevel=2)
warnings.simplefilter('default', DeprecationWarning)
json.dump({'script': __main__.__file__,
'commit': sha,
'parameters': args,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment