Commit 2bfa9cbf authored by André Anjos's avatar André Anjos 💬
Browse files

Merge branch 'fix_schemas' into 'master'

Refactored v1 and v2 schema

See merge request !41
parents ec002018 91ba93e1
Pipeline #24850 passed with stages
in 30 minutes and 31 seconds
{
"schema_version": 2,
"language": "unknown",
"api_version": 2,
"type": "sequential",
......
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Algorithm descriptor",
"title": "Algorithm v1 descriptor",
"description": "This schema defines the properties of an algorithm",
"oneOf": [
......@@ -10,130 +10,6 @@
"definitions": {
"endpoints": {
"type": "object",
"patternProperties": {
"^[a-zA-Z_][a-zA-Z0-9_-]*$": {
"type": "object",
"properties": {
"type": { "$ref": "../common/1.json#/definitions/reference" },
"description": { "type": "string" }
},
"required": [
"type"
],
"additionalProperties": false
}
},
"uniqueItems": true,
"additionalProperties": false
},
"io_group": {
"type": "object",
"properties": {
"name": { "type": "string" },
"inputs": { "$ref": "#/definitions/endpoints" },
"outputs": { "$ref": "#/definitions/endpoints" }
},
"required": [
"inputs",
"outputs"
],
"additionalProperties": false
},
"input_group": {
"type": "object",
"properties": {
"name": { "type": "string" },
"inputs": { "$ref": "#/definitions/endpoints" }
},
"required": [
"inputs"
],
"additionalProperties": false
},
"block_groups": {
"type": "array",
"items": [
{ "$ref": "#/definitions/io_group" }
],
"additionalItems": { "$ref": "#/definitions/input_group" },
"minItems": 1
},
"range": {
"type": "array",
"items": { "$ref": "../common/1.json#/definitions/value" },
"minItems": 2,
"maxItems": 2
},
"choice": {
"type": "array",
"items": { "$ref": "../common/1.json#/definitions/value" },
"minItems": 3
},
"parameter": {
"type": "object",
"properties": {
"type": { "$ref": "../common/1.json#/definitions/basetype" },
"default": { "$ref": "../common/1.json#/definitions/value" },
"description": { "type": "string" }
},
"required": [
"type"
]
},
"range_parameter": {
"allOf": [
{ "$ref": "#/definitions/parameter" },
{
"properties": {
"range": { "$ref": "#/definitions/range" }
},
"required": [
"range"
]
}
],
"additionalProperties": false
},
"choice_parameter": {
"allOf": [
{ "$ref": "#/definitions/parameter" },
{
"properties": {
"range": { "$ref": "#/definitions/choice" }
},
"required": [
"choice"
]
}
],
"additionalProperties": false
},
"parameters": {
"type": "object",
"patternProperties": {
"^[a-zA-Z_][a-zA-Z0-9_-]*$": {
"oneOf": [
{ "$ref": "#/definitions/parameter" },
{ "$ref": "#/definitions/range_parameter" },
{ "$ref": "#/definitions/choice_parameter" }
]
}
},
"uniqueItems": true,
"additionalProperties": false
},
"block": {
"type": "object",
......@@ -141,13 +17,10 @@
"properties": {
"language": { "$ref": "../common/1.json#/definitions/language" },
"description": { "$ref": "../common/1.json#/definitions/description" },
"groups": { "$ref": "#/definitions/block_groups" },
"parameters": { "$ref": "#/definitions/parameters" },
"groups": { "$ref": "common.json#/definitions/block_groups" },
"parameters": { "$ref": "common.json#/definitions/parameters" },
"splittable": { "type": "boolean" },
"uses": { "$ref": "../common/1.json#/definitions/uses" },
"schema_version": { "$ref": "../common/1.json#/definitions/version" },
"api_version": { "$ref": "../common/1.json#/definitions/version" },
"type": { "type": "string", "enum": [ "legacy", "sequential", "autonomous" ] }
"uses": { "$ref": "../common/1.json#/definitions/uses" }
},
"required": [
......@@ -160,44 +33,6 @@
},
"analyzer_groups": {
"type": "array",
"items": { "$ref": "#/definitions/input_group" },
"minItems": 1
},
"resulttype": {
"oneOf": [
{ "type": "string", "enum": [ "int32", "float32", "bool", "string" ] },
{ "type": "string", "pattern": "^system/[a-zA-Z0-9_-]+/[0-9]+$" },
{ "type": "string", "pattern": "^plot/[a-zA-Z0-9_-]+/[0-9]+$" }
]
},
"result": {
"type": "object",
"properties": {
"type": { "$ref": "#/definitions/resulttype" },
"display": { "type": "boolean" },
"description": { "type": "string" }
},
"required": [
"type"
],
"additionalProperties": false
},
"results": {
"type": "object",
"patternProperties": {
"^[a-zA-Z_][a-zA-Z0-9_-]*$": {
"$ref": "#/definitions/result"
}
},
"uniqueItems": true,
"additionalProperties": false
},
"analyzer": {
"type": "object",
......@@ -205,11 +40,10 @@
"properties": {
"language": { "$ref": "../common/1.json#/definitions/language" },
"description": { "$ref": "../common/1.json#/definitions/description" },
"groups": { "$ref": "#/definitions/analyzer_groups" },
"parameters": { "$ref": "#/definitions/parameters" },
"results": { "$ref": "#/definitions/results" },
"uses": { "$ref": "../common/1.json#/definitions/uses" },
"schema_version": { "$ref": "../common/1.json#/definitions/version" }
"groups": { "$ref": "common.json#/definitions/analyzer_groups" },
"parameters": { "$ref": "common.json#/definitions/parameters" },
"results": { "$ref": "common.json#/definitions/results" },
"uses": { "$ref": "../common/1.json#/definitions/uses" }
},
"required": [
......
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Algorithm descriptor v2",
"title": "Algorithm v2 descriptor",
"description": "This schema defines the properties of a v2 algorithm",
"allOf": [
{ "$ref": "1.json"}
"oneOf": [
{ "$ref": "#/definitions/block" },
{ "$ref": "#/definitions/analyzer" }
],
"definitions": {
"type": {
"type": "string",
"enum": [
"legacy",
"sequential",
"autonomous"
]
},
"api_version": {
"type": "number",
"exclusiveMinimum": 0
"block": {
"type": "object",
"properties": {
"language": { "$ref": "../common/1.json#/definitions/language" },
"description": { "$ref": "../common/1.json#/definitions/description" },
"groups": { "$ref": "common.json#/definitions/block_groups" },
"parameters": { "$ref": "common.json#/definitions/parameters" },
"splittable": { "type": "boolean" },
"uses": { "$ref": "../common/1.json#/definitions/uses" },
"schema_version": { "$ref": "common.json#/definitions/schema_version" },
"api_version": { "$ref": "common.json#/definitions/api_version" },
"type": { "$ref": "#/definitions/type" }
},
"required": [
"language",
"groups",
"splittable"
],
"additionalProperties": false
},
"analyzer": {
"type": "object",
"properties": {
"language": { "$ref": "../common/1.json#/definitions/language" },
"description": { "$ref": "../common/1.json#/definitions/description" },
"groups": { "$ref": "common.json#/definitions/analyzer_groups" },
"parameters": { "$ref": "common.json#/definitions/parameters" },
"results": { "$ref": "common.json#/definitions/results" },
"uses": { "$ref": "../common/1.json#/definitions/uses" },
"schema_version": { "$ref": "common.json#/definitions/schema_version" },
"api_version": { "$ref": "common.json#/definitions/api_version" },
"type": { "$ref": "#/definitions/type" }
},
"required": [
"language",
"groups",
"results"
],
"additionalProperties": false
}
},
"required": ["type", "api_version"]
"required": ["type", "api_version", "schema_version"]
}
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Algorithm common components descriptor",
"description": "This schema defines the components used in one or more versions of the Algorithm",
"definitions": {
"endpoints": {
"type": "object",
"patternProperties": {
"^[a-zA-Z_][a-zA-Z0-9_-]*$": {
"type": "object",
"properties": {
"type": { "$ref": "../common/1.json#/definitions/reference" },
"description": { "type": "string" }
},
"required": [
"type"
],
"additionalProperties": false
}
},
"uniqueItems": true,
"additionalProperties": false
},
"io_group": {
"type": "object",
"properties": {
"name": { "type": "string" },
"inputs": { "$ref": "#/definitions/endpoints" },
"outputs": { "$ref": "#/definitions/endpoints" }
},
"required": [
"inputs",
"outputs"
],
"additionalProperties": false
},
"input_group": {
"type": "object",
"properties": {
"name": { "type": "string" },
"inputs": { "$ref": "#/definitions/endpoints" }
},
"required": [
"inputs"
],
"additionalProperties": false
},
"block_groups": {
"type": "array",
"items": [
{ "$ref": "#/definitions/io_group" }
],
"additionalItems": { "$ref": "#/definitions/input_group" },
"minItems": 1
},
"range": {
"type": "array",
"items": { "$ref": "../common/1.json#/definitions/value" },
"minItems": 2,
"maxItems": 2
},
"choice": {
"type": "array",
"items": { "$ref": "../common/1.json#/definitions/value" },
"minItems": 3
},
"parameter": {
"type": "object",
"properties": {
"type": { "$ref": "../common/1.json#/definitions/basetype" },
"default": { "$ref": "../common/1.json#/definitions/value" },
"description": { "type": "string" }
},
"required": [
"type"
]
},
"range_parameter": {
"allOf": [
{ "$ref": "#/definitions/parameter" },
{
"properties": {
"range": { "$ref": "#/definitions/range" }
},
"required": [
"range"
]
}
],
"additionalProperties": false
},
"choice_parameter": {
"allOf": [
{ "$ref": "#/definitions/parameter" },
{
"properties": {
"range": { "$ref": "#/definitions/choice" }
},
"required": [
"choice"
]
}
],
"additionalProperties": false
},
"parameters": {
"type": "object",
"patternProperties": {
"^[a-zA-Z_][a-zA-Z0-9_-]*$": {
"oneOf": [
{ "$ref": "#/definitions/parameter" },
{ "$ref": "#/definitions/range_parameter" },
{ "$ref": "#/definitions/choice_parameter" }
]
}
},
"uniqueItems": true,
"additionalProperties": false
},
"analyzer_groups": {
"type": "array",
"items": { "$ref": "#/definitions/input_group" },
"minItems": 1
},
"resulttype": {
"oneOf": [
{ "type": "string", "enum": [ "int32", "float32", "bool", "string" ] },
{ "type": "string", "pattern": "^system/[a-zA-Z0-9_-]+/[0-9]+$" },
{ "type": "string", "pattern": "^plot/[a-zA-Z0-9_-]+/[0-9]+$" }
]
},
"result": {
"type": "object",
"properties": {
"type": { "$ref": "#/definitions/resulttype" },
"display": { "type": "boolean" },
"description": { "type": "string" }
},
"required": [
"type"
],
"additionalProperties": false
},
"results": {
"type": "object",
"patternProperties": {
"^[a-zA-Z_][a-zA-Z0-9_-]*$": {
"$ref": "#/definitions/result"
}
},
"uniqueItems": true,
"additionalProperties": false
},
"schema_version": { "$ref": "../common/1.json#/definitions/version" },
"api_version": { "$ref": "../common/1.json#/definitions/version" }
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
"properties": {
"language": { "$ref": "../common/1.json#/definitions/language" },
"description": { "$ref": "../common/1.json#/definitions/description" },
"parameters": { "$ref": "../algorithm/1.json#/definitions/parameters" },
"parameters": { "$ref": "../algorithm/common.json#/definitions/parameters" },
"dataformat": {
"type": "string",
"pattern": "^plot/[a-zA-Z0-9_-]+/[0-9]+$"
......
{
"schema_version": 2,
"language": "python",
"api_version": 2,
"type": "autonomous",
"groups": [
{
"name": "main",
"inputs": {
"in_data": {
"type": "user/single_integer/1"
}
}
}
],
"results": {
"out_data": {
"type": "int32",
"display": false
}
}
}
#!/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 process(self, inputs, data_loaders, output):
output.write({'out_data': inputs['in_data'].data.value})
return True
{
"schema_version": 2,
"language": "python",
"type": "sequential",
"splittable": true,
"api_version": 2,
"groups": [
......
......@@ -30,6 +30,6 @@ class Algorithm:
def prepare(self, data_loaders):
return False
def process(self, inputs, outputs):
def process(self, inputs, data_loaders, outputs):
outputs['out_data'].write(inputs['in_data'].data)
return True
{
"schema_version": 2,
"language": "python",
"type": "sequential",
"splittable": true,
"api_version": 2,
"groups": [
......
{
"schema_version": 2,
"language": "python",
"type": "sequential",
"splittable": true,
"api_version": 2,
"groups": [
......
......@@ -30,6 +30,6 @@ class Algorithm:
def setup(self, parameters):
return False
def process(self, inputs, outputs):
def process(self, inputs, data_loaders, outputs):
outputs['out_data'].write(inputs['in_data'].data)
return True