Skip to content

Commit e18c8c7

Browse files
committed
Add md5 for hashing config file
remove date from work_dir name
1 parent 56ff48e commit e18c8c7

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

pertbio/pertbio/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
from pertbio.model import *
55
from pertbio.dataset import *
66
from pertbio.train import *
7+
from pertbio.utils import *
78
from pertbio.version import __version__, VERSION

pertbio/pertbio/utils.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import tensorflow as tf
22
import numpy as np
33
import time
4+
import hashlib
45

56
def loss(x_gold, x_hat,l1, W):
67
with tf.variable_scope("loss", reuse=True):
@@ -37,3 +38,9 @@ def log(self, s):
3738
print("#" * 4 * self.hierachy, " ", s, " --time elapsed: %.2f"%(time.time() - self.time))
3839
self.time = time.time()
3940
self.step_count += 1
41+
42+
def md5(key):
43+
'''
44+
returns a hashed with md5 string of the key
45+
'''
46+
return hashlib.md5(key.encode()).hexdigest()

scripts/main.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def prepare_workdir(cfg):
2929

3030
# Create Output Folder
3131
try:
32-
date = datetime.date.today().strftime("%y%m%d")
33-
experiment_path = 'results/{}_{}'.format(cfg.experiment_id, date)
32+
md5 = pertbio.utils.md5(str(vars(cfg)))
33+
experiment_path = 'results/{}_{}'.format(cfg.experiment_id, md5)
3434
os.makedirs(experiment_path)
3535
except:
3636
pass
@@ -72,9 +72,9 @@ def prepare_workdir(cfg):
7272
except:
7373
seed = int(working_index) + 1000
7474
set_seed(seed)
75-
75+
7676
cfg.dataset = prepare_workdir(cfg)
77-
77+
7878
logger = pertbio.utils.time_logger(time_logger_step = 1, hierachy = 3)
7979
args = cfg
8080
for i, stage in enumerate(cfg.stages):

0 commit comments

Comments
 (0)