workflow: extract float before converting

Fixes #217

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2017-09-17 15:33:04 +03:00
parent 7286f8074d
commit e310db238b
+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():