Commit dfd30b8b authored by Samuel GAIST's avatar Samuel GAIST

[schema][experiment][common] Fix algorithm name pattern

It's missing support for - in the author part of
algorithm author name.

Fixes #104
parent 818c1b6d
Pipeline #45444 passed with stage
in 19 minutes and 35 seconds
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
"environment": { "$ref": "#/definitions/environment" } "environment": { "$ref": "#/definitions/environment" }
}, },
"patternProperties": { "patternProperties": {
"^[a-zA-Z_][a-zA-Z0-9_]*/[a-zA-Z_][a-zA-Z0-9_-]*/[0-9]+$": { "^[a-zA-Z_][a-zA-Z0-9_-]*/[a-zA-Z_][a-zA-Z0-9_-]*/[0-9]+$": {
"$ref": "#/definitions/parameter_set" "$ref": "#/definitions/parameter_set"
} }
}, },
......
{
"schema_version": 3,
"language": "python",
"api_version": 2,
"type": "autonomous_loop_processor",
"splittable": false,
"groups": [
{
"inputs": {
"in": {
"type": "user/single_integer/1"
}
},
"outputs": {
"out": {
"type": "user/single_integer/1"
}
},
"loop": {
"request": {
"type": "user/1d_array_of_integers/1"
},
"answer": {
"type": "user/single_float/1"
}
}
}
],
"parameters": {
"step": {
"default": 1,
"type": "int8",
"description": "Counter step size"
}
}
}
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
###################################################################################
# #
# Copyright (c) 2019 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# Redistribution and use in source and binary forms, with or without #
# modification, are permitted provided that the following conditions are met: #
# #
# 1. Redistributions of source code must retain the above copyright notice, this #
# list of conditions and the following disclaimer. #
# #
# 2. Redistributions in binary form must reproduce the above copyright notice, #
# this list of conditions and the following disclaimer in the documentation #
# and/or other materials provided with the distribution. #
# #
# 3. Neither the name of the copyright holder nor the names of its contributors #
# may be used to endorse or promote products derived from this software without #
# specific prior written permission. #
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND #
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED #
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE #
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE #
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL #
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR #
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER #
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, #
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #
# #
###################################################################################
import numpy as np
class Algorithm:
def __init__(self):
self.step = 1
def setup(self, parameters):
self.step = parameters["step"]
return True
def process(self, data_loaders, outputs, loop_channel):
cnt = 1
is_valid, delta = loop_channel.validate({"value": np.full(10, cnt)})
while not is_valid:
cnt = cnt + self.step
is_valid, delta = loop_channel.validate({"value": np.full(10, cnt)})
delta = delta.value
data_loader = data_loaders.loaderOf("in")
for i in range(data_loader.count()):
view = data_loader.view("in", i)
(data, _, end) = view[view.count() - 1]
value = data["in"].value
new_value = (value + cnt) * delta
outputs["out"].write({"value": np.int32(new_value)}, end)
return True
{
"schema_version": 2,
"blocks": {
},
"loops": {
"loop_super_block": {
"processor_algorithm": "user-with_dash/block-with_dash/1",
"processor_parameters": {
"step": 1
},
"processor_inputs": {
"in": "in"
},
"processor_outputs": {
"out": "out"
},
"evaluator_algorithm": "user/db_input_loop_evaluator/1",
"evaluator_parameters": {
"threshold": 9
},
"evaluator_inputs": {
"in_loop": "in_loop"
},
"evaluator_outputs": {
"out_loop": "out_loop"
}
}
},
"analyzers": {
"analysis": {
"algorithm": "v1/integers_analysis/1",
"parameters": {
},
"inputs": {
"input": "input"
}
},
"loop_analysis": {
"algorithm": "v1/integers_analysis/1",
"parameters": {
},
"inputs": {
"input": "input"
}
}
},
"datasets": {
"integers": {
"database": "integers_db/1",
"protocol": "double",
"set": "double"
},
"integers2": {
"database": "simple/1",
"protocol": "protocol2",
"set": "set"
}
},
"globals": {
"environment": {
"name": "Python for tests",
"version": "1.3.0"
},
"queue": "queue",
"user-with_dash/block-with_dash/1": {
"step": 2
},
"user/db_input_loop_evaluator/1" : {
"threshold": 8
}
}
}
Test that loading an experiment with an algorithm containg dashes
in its author name works.
See beat/beat.core#104
...@@ -172,6 +172,29 @@ def test_load_experiment_with_loop(): ...@@ -172,6 +172,29 @@ def test_load_experiment_with_loop():
nose.tools.eq_(len(experiment.algorithms), 6) nose.tools.eq_(len(experiment.algorithms), 6)
def test_load_experiment_with_dash_in_algorithm_name():
experiment = Experiment(prefix, "user/loop/1/with_dash")
nose.tools.assert_true(
experiment.valid, "\n * %s" % "\n * ".join(experiment.errors)
)
nose.tools.eq_(experiment.label, "user/user/loop/1/with_dash")
nose.tools.assert_true(
experiment.toolchain.valid,
"\n * %s" % "\n * ".join(experiment.toolchain.errors),
)
nose.tools.eq_(experiment.toolchain.name, "user/loop/1")
nose.tools.eq_(len(experiment.datasets), 2)
nose.tools.eq_(len(experiment.databases), 2)
nose.tools.eq_(len(experiment.blocks), 0)
nose.tools.eq_(len(experiment.loops), 1)
nose.tools.eq_(len(experiment.analyzers), 2)
nose.tools.eq_(len(experiment.algorithms), 3)
@nose.tools.with_setup(teardown=cleanup) @nose.tools.with_setup(teardown=cleanup)
def test_export(): def test_export():
......
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