Commit 3f345759 authored by Samuel GAIST's avatar Samuel GAIST

[experiment] WARNING Refactor of the loop handling

Rather than having a loops field containing only the "loop"
blocks, they have now become their own entity like "blocks" and
"analyzers".

This new type of block will contain all the information needed
for both the loop user algorithm and for the loop itself as
they work in pair anyway.
parent 50b4c0d2
This diff is collapsed.
......@@ -55,10 +55,25 @@
"algorithm": { "$ref": "../common/1.json#/definitions/reference" },
"parameters": { "$ref": "common.json#/definitions/parameter_set" },
"inputs": { "$ref": "common.json#/definitions/connection_map" },
"outputs": { "$ref": "common.json#/definitions/connection_map" },
"queue": { "$ref": "common.json#/definitions/queue" },
"environment": { "$ref": "common.json#/definitions/environment" },
"nb_slots": { "$ref": "common.json#/definitions/slots" }
}
"nb_slots": { "$ref": "common.json#/definitions/slots" },
"loop_algorithm": { "$ref": "../common/1.json#/definitions/reference" },
"loop_parameters": { "$ref": "common.json#/definitions/parameter_set" },
"loop_inputs": { "$ref": "common.json#/definitions/connection_map" },
"loop_outputs": { "$ref": "common.json#/definitions/connection_map" },
"loop_environment": { "$ref": "common.json#/definitions/environment" }
},
"required": [
"algorithm",
"inputs",
"outputs",
"loop_algorithm",
"loop_inputs",
"loop_outputs"
],
"additionalProperties": false
}
}
......
......@@ -6,12 +6,12 @@
"groups": [
{
"inputs": {
"in": {
"in_loop": {
"type": "user/single_integer/1"
}
},
"outputs": {
"out": {
"out_loop": {
"type": "user/single_integer/1"
}
},
......
......@@ -48,12 +48,12 @@ class Algorithm:
return True
def prepare(self, data_loaders):
data_loader = data_loaders.loaderOf("in")
data_loader = data_loaders.loaderOf("in_loop")
for i in range(data_loader.count()):
view = data_loader.view("in", i)
view = data_loader.view("in_loop", i)
(data, _, _) = view[view.count() - 1]
value = data["in"].value
value = data["in_loop"].value
self.max += value
return True
......@@ -65,5 +65,5 @@ class Algorithm:
self.output = delta
return (result, {"value": np.float32(delta)})
def write(self, outputs):
outputs["out"].write({"value": np.int32(self.output)})
def write(self, outputs, end_data_index):
outputs["out_loop"].write({"value": np.int32(self.output)}, end_data_index)
{
"schema_version": 2,
"blocks": {
"loop_user": {
},
"loops": {
"loop_super_block": {
"algorithm": "user/db_input_loop_user/1",
"parameters": {
},
......@@ -10,17 +12,17 @@
},
"outputs": {
"out": "out"
}
}
},
"loops": {
"loop": {
"algorithm": "user/db_input_loop/1",
"parameters": {
},
"loop_algorithm": "user/db_input_loop/1",
"loop_parameters": {
"threshold": 1
},
"inputs": {
"in": "in"
"loop_inputs": {
"in_loop": "in_loop"
},
"loop_outputs": {
"out_loop": "out_loop"
}
}
},
......@@ -32,6 +34,14 @@
"inputs": {
"input": "input"
}
},
"loop_analysis": {
"algorithm": "v1/integers_analysis/1",
"parameters": {
},
"inputs": {
"input": "input"
}
}
},
"datasets": {
......
......@@ -348,7 +348,9 @@ class BaseExecutionMixIn(object):
@slow
def test_loop_1(self):
nose.tools.assert_is_none(
self.execute("user/user/loop/1/loop", [{"sum": 504, "nb": 9}])
self.execute(
"user/user/loop/1/loop", [{"sum": 504, "nb": 9}, {"sum": 72, "nb": 9}]
)
)
# For benchmark purposes
......
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