Commit b12489b5 authored by Wout De Nolf's avatar Wout De Nolf
Browse files

esrftaskgraph rename "uhash_nonce" to "instance_nonce"

parent edfddeac
......@@ -127,15 +127,15 @@ class UniversalHashable:
__VERSION = None
MISSING_DATA = MissingData()
def __init__(self, uhash=None, uhash_nonce=None):
def __init__(self, uhash=None, instance_nonce=None):
"""
:param str, bytes, UniversalHash, UniversalHashable uhash:
:param uhash_nonce:
:param instance_nonce:
"""
self.__set_uhash(uhash)
self.__original_uhash = self.__uhash
self.__instance_nonce = uhash_nonce
self.__original__instance_nonce = uhash_nonce
self.__instance_nonce = instance_nonce
self.__original__instance_nonce = instance_nonce
def __init_subclass__(subcls, version=None, **kwargs):
super().__init_subclass__(**kwargs)
......
......@@ -64,7 +64,7 @@ class Task(Registered, hashing.UniversalHashable, register=False):
self._outputs = VariableContainer(
value=ovars,
uhash=self._inputs,
uhash_nonce=self.class_nonce(),
instance_nonce=self.class_nonce(),
varinfo=varinfo,
)
......@@ -140,7 +140,7 @@ class Task(Registered, hashing.UniversalHashable, register=False):
return super().class_nonce_data() + (
sorted(cls.input_names()),
sorted(cls.output_names()),
cls._N_REQUIRED_POSITIONAL_INPUTS
cls._N_REQUIRED_POSITIONAL_INPUTS,
)
@property
......
......@@ -264,11 +264,11 @@ class VariableContainer(Mapping, Variable):
varparams = dict(self.__varparams)
if isinstance(value, hashing.UniversalHash):
varparams["uhash"] = value
varparams["uhash_nonce"] = None
varparams["instance_nonce"] = None
else:
varparams["value"] = value
uhash_nonce = varparams.pop("uhash_nonce", None)
varparams["uhash_nonce"] = uhash_nonce, key
instance_nonce = varparams.pop("instance_nonce", None)
varparams["instance_nonce"] = instance_nonce, key
return Variable(**varparams)
def __iter__(self):
......@@ -291,7 +291,7 @@ class VariableContainer(Mapping, Variable):
def _deserialize(self, value):
adict = dict()
varparams = dict(self.__varparams)
varparams["uhash_nonce"] = None
varparams["instance_nonce"] = None
for k, v in value.items():
varparams["uhash"] = hashing.UniversalHash(v)
adict[k] = Variable(**varparams)
......
......@@ -48,15 +48,15 @@ def test_variable_uhash(varinfo):
def test_variable_nonce(varinfo):
v1 = Variable(9999, varinfo=varinfo)
v2 = Variable(value=9999, uhash_nonce=1, varinfo=varinfo)
v2 = Variable(value=9999, instance_nonce=1, varinfo=varinfo)
assert v1.uhash != v2.uhash
assert v1 != v2
assert v1.value == v2.value
v2 = Variable(uhash=v1, uhash_nonce=1, varinfo=varinfo)
v2 = Variable(uhash=v1, instance_nonce=1, varinfo=varinfo)
assert v1.uhash != v2.uhash
assert v1 != v2
assert v1.value != v2.value
v2 = Variable(uhash=v1.uhash, uhash_nonce=1, varinfo=varinfo)
v2 = Variable(uhash=v1.uhash, instance_nonce=1, varinfo=varinfo)
assert v1.uhash != v2.uhash
assert v1 != v2
assert v1.value != v2.value
......
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