Skip to content

Commit

Permalink
Add md5 for hashing config file
Browse files Browse the repository at this point in the history
remove date from work_dir name
  • Loading branch information
DesmondYuan committed Sep 12, 2019
1 parent 56ff48e commit e18c8c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions pertbio/pertbio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
from pertbio.model import *
from pertbio.dataset import *
from pertbio.train import *
from pertbio.utils import *
from pertbio.version import __version__, VERSION
7 changes: 7 additions & 0 deletions pertbio/pertbio/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import tensorflow as tf
import numpy as np
import time
import hashlib

def loss(x_gold, x_hat,l1, W):
with tf.variable_scope("loss", reuse=True):
Expand Down Expand Up @@ -37,3 +38,9 @@ def log(self, s):
print("#" * 4 * self.hierachy, " ", s, " --time elapsed: %.2f"%(time.time() - self.time))
self.time = time.time()
self.step_count += 1

def md5(key):
'''
returns a hashed with md5 string of the key
'''
return hashlib.md5(key.encode()).hexdigest()
8 changes: 4 additions & 4 deletions scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def prepare_workdir(cfg):

# Create Output Folder
try:
date = datetime.date.today().strftime("%y%m%d")
experiment_path = 'results/{}_{}'.format(cfg.experiment_id, date)
md5 = pertbio.utils.md5(str(vars(cfg)))
experiment_path = 'results/{}_{}'.format(cfg.experiment_id, md5)
os.makedirs(experiment_path)
except:
pass
Expand Down Expand Up @@ -72,9 +72,9 @@ def prepare_workdir(cfg):
except:
seed = int(working_index) + 1000
set_seed(seed)

cfg.dataset = prepare_workdir(cfg)

logger = pertbio.utils.time_logger(time_logger_step = 1, hierachy = 3)
args = cfg
for i, stage in enumerate(cfg.stages):
Expand Down

0 comments on commit e18c8c7

Please sign in to comment.