Commit 97782a00 authored by Pielage, Leon's avatar Pielage, Leon

Merge branch 'develop' into refactor/410_align-host-manager

parents addad155 7c2a2ee7
......@@ -16,7 +16,7 @@ Barista is an open-source graphical high-level interface for the Caffe deep lear
**Using Barista**
* To start Barista, run the file `main.py`
* A user manual as well as a starter's tutorial on Barista can be found in the wiki of the project repository: https://zivgitlab.uni-muenster.de/pria/Barista
* A user manual as well as a starter's tutorial on Barista can be found in the wiki of the project repository: https://zivgitlab.uni-muenster.de/pria/Barista/wikis/home
If you have any questions regarding Barista, please feel free to contact the developers at barista(at)uni-muenster.de
......
......@@ -45,6 +45,13 @@ def getMultipleHash(dbPaths):
hashValue += getHash(path)
return hashValue
"""
returns the sha256 hash value of a single string
@author j_stru18
@param inputStr : the string that has to be hashed
@return : the hashValue of the string
"""
def getStringHash(inputStr):
hashObject = hashlib.sha256()
hashObject.update(inputStr)
......
......@@ -7,10 +7,11 @@ from backend.barista.utils.logger import Log
class Hdf5Input:
def __init__(self):
def __init__(self, pathOfHdf5Txt=False):
self._db = None
self._path = None
self.logid = Log.getCallerId('HDF5 Input')
self._pathOfHdf5Txt = pathOfHdf5Txt # HDF5TXT files can contain commentary lines that are no paths
self._logid = Log.getCallerId('HDF5 Input')
def __del__(self):
self.close()
......@@ -19,6 +20,10 @@ class Hdf5Input:
'''set the path of the database.'''
self._path = path
def getPath(self):
'''get the path of this HDF5Input object'''
return self._path
def open(self):
'''open the database from the set path.'''
if self._db:
......@@ -28,10 +33,10 @@ class Hdf5Input:
try:
self._db = h5.File(self._path, 'r')
except:
Log.error("File not valid HDF5: " + self._path, self.logid)
Log.error("File not valid HDF5: " + self._path, self._logid)
self._db = None
else:
Log.error("File does not exist: " + self._path, self.logid)
elif not self._pathOfHdf5Txt:
Log.error("File does not exist: " + self._path, self._logid)
def close(self):
if self._db:
......
......@@ -8,7 +8,7 @@ class Hdf5TxtInput:
def __init__(self):
self._db = []
self._path = None
self.logid = Log.getCallerId("HDF5TXT Input")
self._logid = Log.getCallerId("HDF5TXT Input")
self._projectPath = None
def __del__(self):
......@@ -23,20 +23,21 @@ class Hdf5TxtInput:
if self._path is not None:
if os.path.exists(self._path):
lines = [line.rstrip('\n') for line in open(self._path)]
hdf5Count = 0
for line in lines:
if line is not "":
if line[:1] == '.':
line = self._makepath(line)
i = len(self._db)
self._db.append(Hdf5Input())
self._db.append(Hdf5Input(pathOfHdf5Txt=True))
self._db[i].setPath(line)
self._db[i].open()
if not self._db[i].isOpen():
Log.error("File contains invalid HDF5: " + self._path, self.logid)
if self._db[i].isOpen():
hdf5Count += 1
if hdf5Count == 0:
self._db = None
return
else:
Log.error("File does not exist: " + self._path, self.logid)
Log.error("File contained no valid paths to HDF5 files: {}".format(self._path), self._logid)
def close(self):
if self._db:
......@@ -77,7 +78,11 @@ class Hdf5TxtInput:
self._projectPath = path
def _sumDataCount(self, d1, d2):
return {k: d1.get(k, 0) + d2.get(k, 0) for k in set(d1) | set(d2)}
dataCountDict = {}
if d1 or d2:
dataCountDict = {k: d1.get(k, 0) + d2.get(k, 0) for k in set(d1) | set(d2)}
return dataCountDict
def _combineDim(self, d1, d2):
return {k: max(d1.get(k, 0), d2.get(k, 0)) for k in set(d1) | set(d2)}
......@@ -87,6 +92,7 @@ class Hdf5TxtInput:
if False in l:
return False
return True
"""
Converts a path that is considered to be relative to the project path into an absolute path.
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment