Skip to content

Commit

Permalink
#119 Try-except clause if hashing fails, and also check for None for …
Browse files Browse the repository at this point in the history
…hash, which obviously should not be checked in the DB
  • Loading branch information
lekah committed Jun 2, 2017
1 parent 13caff2 commit ca5f047
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions aiida/orm/implementation/general/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,15 +1489,23 @@ def get_hash(self):
Making a hash based on my attributes
"""
from aiida.common.hashing import make_hash
return make_hash(self.get_attrs())
try:
return make_hash(self.get_attrs())
except:
return None


def get_same_node(self):
from aiida.orm.querybuilder import QueryBuilder

qb = QueryBuilder()
qb.append(self.__class__, filters={'extras.hash':self.get_hash()}, project='*', subclassing=False)
same_node = qb.first()
hash_ = self.get_hash()
if hash_:
qb = QueryBuilder()
qb.append(self.__class__, filters={'extras.hash':hash_}, project='*', subclassing=False)
same_node = qb.first()
else:
same_node = None

if same_node:
return same_node[0]
else:
Expand Down

0 comments on commit ca5f047

Please sign in to comment.