Merge pull request #218 from efiop/master

workflow: extract float before converting
This commit is contained in:
Ruslan Kuprieiev
2017-09-17 17:06:11 +03:00
committed by GitHub
+16 -8
View File
@@ -309,15 +309,23 @@ class GitWrapper(GitWrapperI):
file_name = os.path.join(settings.config.cache_dir, cache_file_name)
full_file_name = os.path.join(self.git_dir_abs, file_name)
if os.path.exists(full_file_name):
lines = open(full_file_name).readlines(2)
if len(lines) != 1:
msg = '[dvc-git] Target file {} with hash {} has wrong format: {} lines were obtained, 1 expected.'
Logger.warn(msg.format(target, hash, len(lines)))
else:
return float(lines[0])
if not os.path.exists(full_file_name):
return None
return None
lines = open(full_file_name).readlines(2)
if len(lines) != 1:
msg = '[dvc-git] Target file {} with hash {} has wrong format: {} lines were obtained, 1 expected.'
Logger.warn(msg.format(target, hash, len(lines)))
return None
# Extract float from string. I.e. from 'AUC: 0.596182'
num = re.findall("\d+\.\d+", lines[0])
if len(num) != 1:
msg = '[dvc-git] Unable to parse metrics from \'{}\' file {}'
Logger.warn(msg.format(lines[0], target))
return None
return float(num[0])
@staticmethod
def get_merges_map():