mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-28 07:18:29 +01:00
dvc find command
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Helpers for other modules.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import stat
|
||||
import shutil
|
||||
|
||||
@@ -13,6 +14,7 @@ from dvc.logger import Logger
|
||||
|
||||
LOCAL_CHUNK_SIZE = 1024*1024*1024
|
||||
|
||||
|
||||
def cached_property(func):
|
||||
'''A decorator for caching properties in classes.'''
|
||||
def get(self):
|
||||
@@ -82,3 +84,27 @@ def map_progress(func, targets, n_threads):
|
||||
progress.finish()
|
||||
|
||||
return zip(targets, ret)
|
||||
|
||||
|
||||
def parse_target_metric_file(file_name):
|
||||
with open(file_name, 'r') as fd:
|
||||
try:
|
||||
lines = fd.readlines(2)
|
||||
except Exception:
|
||||
return None
|
||||
return parse_target_metric(lines)
|
||||
|
||||
|
||||
FLOATS_FROM_STRING = re.compile(r'[-+]?(?:(?:\d*\.\d+)|(?:\d+\.?))(?:[Ee][+-]?\d+)?')
|
||||
|
||||
|
||||
def parse_target_metric(lines):
|
||||
if len(lines) != 1:
|
||||
return None
|
||||
|
||||
# Extract float from string. I.e. from 'AUC: 0.596182'
|
||||
nums = FLOATS_FROM_STRING.findall(lines[0])
|
||||
if len(nums) < 1:
|
||||
return None
|
||||
|
||||
return float(nums[0])
|
||||
|
||||
Reference in New Issue
Block a user