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

[schema] Add algorithm v2 schema

parent 9915dd15
Pipeline #22287 passed with stages
in 63 minutes and 55 seconds
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Algorithm descriptor v2",
"description": "This schema defines the properties of a v2 algorithm",
"allOf": [
{ "$ref": "1.json"}
],
"definitions": {
"type": {
"type": "string",
"enum": [
"legacy",
"sequential",
"autonomous"
]
},
"api_version": {
"type": "number",
"exclusiveMinimum": 0
}
},
"required": ["type", "api_version"]
}
\ No newline at end of file
{
"schema_version": 2,
"language": "python",
"api_version": 2,
"type": "autonomous",
"splittable": false,
"parameters": {
"sync": {
"default": "in1",
"type": "string"
}
},
"groups": [
{
"inputs": {
"in1": {
"type": "user/single_integer/1"
},
"in2": {
"type": "user/single_integer/1"
}
},
"outputs": {
"out": {
"type": "user/single_integer/1"
}
}
}
]
}
\ No newline at end of file
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
###############################################################################
# #
# Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.core module of the BEAT platform. #
# #
# Commercial License Usage #
# Licensees holding valid commercial BEAT licenses may use this file in #
# accordance with the terms contained in a written agreement between you #
# and Idiap. For further information contact tto@idiap.ch #
# #
# Alternatively, this file may be used under the terms of the GNU Affero #
# Public License version 3 as published by the Free Software and appearing #
# in the file LICENSE.AGPL included in the packaging of this file. #
# The BEAT platform is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. #
# #
# You should have received a copy of the GNU Affero Public License along #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/. #
# #
###############################################################################
class Algorithm:
def __init__(self):
self.offset = 1
def setup(self, parameters):
self.sync = parameters['sync']
self.offset = parameters['offset']
return True
def process(self, inputs, outputs):
data_loader = data_loaders.loaderOf('in1')
for i in range(data_loader.count(self.sync)):
view = data_loader.view(self.sync, i)
(data, start, end) = view[view.count() - 1]
outputs['out'].write({
'value': data['in1'].value + data['in2'].value,
},
end
)
return True
......@@ -67,6 +67,15 @@ def test_missing_outputs():
#----------------------------------------------------------
def test_v2():
algorithm = Algorithm(prefix, 'user/integers_add_v2/1')
assert algorithm.valid, '\n * %s' % '\n * '.join(algorithm.errors)
#----------------------------------------------------------
@nose.tools.with_setup(teardown=cleanup)
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