Commit 38fd874d authored by Philip ABBET's avatar Philip ABBET

Add simple/2 (api change: beat.backend.python v1.4.2)

parent 7b893ab8
{
"description": "A test database that emits integers",
"root_folder": "/this/database/does/not/require/a/path",
"protocols": [
{
"name": "protocol",
"template": "test_integers",
"sets": [
{
"name": "set",
"template": "set",
"view": "View",
"outputs": {
"out": "{{ system_user.username }}/integer/1"
}
},
{
"name": "set2",
"template": "set",
"view": "View2",
"outputs": {
"out": "{{ system_user.username }}/integer/1"
}
}
]
},
{
"name": "protocol2",
"template": "test_integers",
"sets": [
{
"name": "set",
"template": "set",
"view": "LargeView",
"outputs": {
"out": "{{ system_user.username }}/integer/1"
}
},
{
"name": "set2",
"template": "set",
"view": "View2",
"outputs": {
"out": "{{ system_user.username }}/integer/1"
}
}
]
}
]
}
###############################################################################
# #
# Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.examples 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/. #
# #
###############################################################################
import numpy as np
#----------------------------------------------------------
class View:
"""Outputs:
- out: "{{ system_user.username }}/integer/1"
--------------- --------------- --------------- ---------------
| out | | out | | out | | out |
--------------- --------------- --------------- ---------------
"""
def setup(self, root_folder, outputs, parameters, force_start_index=None,
force_end_index=None):
# Initialisations
self.outputs = outputs
# Determine the range of indices that must be provided
self.start_index = force_start_index if force_start_index is not None else 0
self.end_index = force_end_index if force_end_index is not None else 0
self.next_index = self.start_index
return True
def done(self, last_data_index):
return last_data_index >= self.end_index
def next(self):
# Output: out (provide data at each iteration)
if self.outputs['out'].isConnected():
self.outputs['out'].write(
{
'value': np.int32(42)
},
self.next_index
)
# Determine the next data index that must be provided
self.next_index = 1 + min([ x.last_written_data_index for x in self.outputs
if x.isConnected() ]
)
return True
#----------------------------------------------------------
class View2:
"""Outputs:
- out: "{{ system_user.username }}/integer/1"
--------------- --------------- --------------- ---------------
| out | | out | | out | | out |
--------------- --------------- --------------- ---------------
"""
def setup(self, root_folder, outputs, parameters, force_start_index=None,
force_end_index=None):
# Initialisations
self.outputs = outputs
# Determine the range of indices that must be provided
self.start_index = force_start_index if force_start_index is not None else 0
self.end_index = force_end_index if force_end_index is not None else 0
self.next_index = self.start_index
return True
def done(self, last_data_index):
return last_data_index >= self.end_index
def next(self):
# Output: out (provide data at each iteration)
if self.outputs['out'].isConnected():
self.outputs['out'].write(
{
'value': np.int32(53)
},
self.next_index
)
# Determine the next data index that must be provided
self.next_index = 1 + min([ x.last_written_data_index for x in self.outputs
if x.isConnected() ]
)
return True
#----------------------------------------------------------
class LargeView:
"""Outputs:
- out: "{{ system_user.username }}/integer/1"
--------------- --------------- --------------- ---------------
| out | | out | | out | | out |
--------------- --------------- --------------- ---------------
"""
def setup(self, root_folder, outputs, parameters, force_start_index=None,
force_end_index=None):
# Initialisations
self.outputs = outputs
# Determine the range of indices that must be provided
self.start_index = force_start_index if force_start_index is not None else 0
self.end_index = force_end_index if force_end_index is not None else 4
self.next_index = self.start_index
return True
def done(self, last_data_index):
return last_data_index >= self.end_index
def next(self):
# Output: out (provide data at each iteration)
if self.outputs['out'].isConnected():
self.outputs['out'].write(
{
'value': np.int32(self.next_index)
},
self.next_index
)
# Determine the next data index that must be provided
self.next_index = 1 + min([ x.last_written_data_index for x in self.outputs
if x.isConnected() ]
)
return True
#----------------------------------------------------------
def setup_tests():
pass
#----------------------------------------------------------
# Test the behavior of the views (on fake data)
if __name__ == '__main__':
setup_tests()
from beat.backend.python.database import DatabaseTester
DatabaseTester('View', View,
[
'out',
],
parameters=dict(
),
)
DatabaseTester('View2', View2,
[
'out',
],
parameters=dict(
),
)
DatabaseTester('LargeView', LargeView,
[
'out',
],
parameters=dict(
),
)
.. Copyright (c) 2017 Idiap Research Institute, http://www.idiap.ch/ ..
.. Contact: beat.support@idiap.ch ..
.. ..
.. This file is part of the beat.examples 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/. ..
The Simple Digit Database
-------------------------
Changelog
=========
* **Version 2**, 02/Nov/2017:
- Port to beat.backend.python v1.4.2
* **Version 1**:
- Initial release
Description
===========
This database emits two integers (one from each of its set). The first integer
(from ``set``) has a value of 42, while the second (from ``set2``), a value of
53.
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