Skip to content
Snippets Groups Projects
Commit 789fa8a3 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[execution][loop] LoopChannel.is_result_valid is now validate

This makes things clearer with regard to the validate method
of the associated loop algorithm.
parent 3e483554
No related branches found
No related tags found
1 merge request!281.6.x
Pipeline #25369 passed
...@@ -83,15 +83,15 @@ class LoopChannel(object): ...@@ -83,15 +83,15 @@ class LoopChannel(object):
answer_format_name = algorithm.loop_map["answer"] answer_format_name = algorithm.loop_map["answer"]
self.answer_data_format = DataFormat(prefix, answer_format_name) self.answer_data_format = DataFormat(prefix, answer_format_name)
def is_result_valid(self, result): def validate(self, hypothesis):
""" This method will request validation for the result passed in """ This method will request validation for the hypothesis passed in
parameter. parameter.
Parameters: Parameters:
result (dict) : Computation result that must be validated by the hypothesis (dict) : Computed hypothesis that must be validated by
loop algorithm. the loop algorithm.
""" """
data = make_data_format(result, self.request_data_format) data = make_data_format(hypothesis, self.request_data_format)
self.socket.send_string("val", zmq.SNDMORE) self.socket.send_string("val", zmq.SNDMORE)
self.socket.send(data.pack()) self.socket.send(data.pack())
...@@ -236,10 +236,10 @@ class LoopExecutor(object): ...@@ -236,10 +236,10 @@ class LoopExecutor(object):
self.message_handler.start() self.message_handler.start()
def validate(self, result): def validate(self, hypothesis):
"""Executes the loop validation code""" """Executes the loop validation code"""
is_valid, answer = self.runner.validate(result) is_valid, answer = self.runner.validate(hypothesis)
logger.debug("User loop has validated: {}\n{}".format(is_valid, answer)) logger.debug("User loop has validated: {}\n{}".format(is_valid, answer))
return is_valid, answer return is_valid, answer
......
...@@ -30,10 +30,10 @@ class Algorithm: ...@@ -30,10 +30,10 @@ class Algorithm:
def process(self, data_loaders, outputs, loop_channel): def process(self, data_loaders, outputs, loop_channel):
cnt = 10 cnt = 10
is_valid, _ = loop_channel.is_result_valid({'value': np.int32(cnt)}) is_valid, _ = loop_channel.validate({'value': np.int32(cnt)})
while not is_valid: while not is_valid:
cnt = cnt - 1 cnt = cnt - 1
is_valid, _ = loop_channel.is_result_valid({'value': np.int32(cnt)}) is_valid, _ = loop_channel.validate({'value': np.int32(cnt)})
data_loader = data_loaders.loaderOf('in') data_loader = data_loaders.loaderOf('in')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment