Commit f1991440 authored by André Anjos's avatar André Anjos 💬

Merge branch 'reorganize_error_related_prefix_content' into 'master'

Reorganize error related prefix content

See merge request !76
parents 324af4bf c398d8f7
Pipeline #30577 passed with stages
in 32 minutes and 37 seconds
......@@ -6,14 +6,14 @@ repos:
hooks:
- id: black
language_version: python3.6
exclude: beat/core/test/prefix/algorithms/user/syntax_error/1.py|beat/core/test/prefix/databases/invalid/1.py
exclude: beat/core/test/prefix/algorithms/errors/syntax_error/1.py|beat/core/test/prefix/databases/invalid/1.py
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
exclude: beat/core/test/prefix/algorithms/user/syntax_error/1.py|beat/core/test/prefix/databases/invalid/1.py
exclude: beat/core/test/prefix/algorithms/errors/syntax_error/1.py|beat/core/test/prefix/databases/invalid/1.py
- id: check-added-large-files
- id: check-docstring-first
- id: flake8
......@@ -23,7 +23,7 @@ repos:
rev: 'master' # Update me!
hooks:
- id: bandit
exclude: beat/editor/test|beat/core/test/prefix/algorithms/user/syntax_error/1.py|beat/core/test/prefix/databases/invalid/1.py
exclude: beat/core/test/prefix/algorithms/errors/syntax_error/1.py|beat/core/test/prefix/databases/invalid/1.py
- repo: local
hooks:
- id: sphinx-build
......
......@@ -9,7 +9,7 @@
},
"blocks": {
"echo": {
"algorithm": "user/prepare_error/1",
"algorithm": "errors/prepare_error/1",
"inputs": {
"in_data": "in"
},
......
......@@ -9,7 +9,7 @@
},
"blocks": {
"echo": {
"algorithm": "user/setup_error/1",
"algorithm": "errors/setup_error/1",
"inputs": {
"in_data": "in"
},
......
......@@ -9,7 +9,7 @@
},
"blocks": {
"echo": {
"algorithm": "user/integers_echo_error/1",
"algorithm": "errors/integers_echo_error/1",
"inputs": {
"in_data": "in"
},
......
......@@ -9,7 +9,7 @@
},
"blocks": {
"echo": {
"algorithm": "user/integers_echo_error/1",
"algorithm": "errors/integers_echo_error/1",
"inputs": {
"in_data": "in"
},
......
......@@ -27,7 +27,7 @@
}
},
"echo3": {
"algorithm": "user/too_many_nexts/1",
"algorithm": "errors/too_many_nexts/1",
"inputs": {
"in_data": "in",
"in_data2": "in2"
......
......@@ -52,6 +52,9 @@
"name": "Python 2.7",
"version": "1.3.0"
},
"queue": "queue"
"queue": "queue",
"user/integers_add/1": {
"offset": 1
}
}
}
......@@ -64,6 +64,9 @@
"name": "Python 2.7",
"version": "1.3.0"
},
"queue": "queue"
"queue": "queue",
"user/integers_add/1": {
"offset": 1
}
}
}
{
"blocks": {
"echo": {
"algorithm": "integers_echo",
"algorithm": "user/integers_echo/1",
"parameters": {
},
"inputs": {
......@@ -12,11 +12,21 @@
}
}
},
"analyzers": {
"analysis": {
"algorithm": "user/integers_analysis/1",
"parameters": {
},
"inputs": {
"input": "input"
}
}
},
"datasets": {
"integers": {
"database": "integers_db/1",
"protocol": "double",
"set": "default"
"set": "double"
}
},
"globals": {
......
......@@ -47,10 +47,13 @@
}
},
"globals": {
"environment": {
"name": "Python 2.7",
"version": "1.3.0"
},
"queue": "queue"
"environment": {
"name": "Python 2.7",
"version": "1.3.0"
},
"queue": "queue",
"user/db_input_loop/1" : {
"threshold": 9
}
}
}
......@@ -30,6 +30,9 @@
"environment": {
"name": "Python 2.7",
"version": "1.3.0"
},
"user/integers_add/1": {
"offset": 1
}
}
}
#!/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 sys
def f():
return "OK 2"
def pyver():
return "%d.%d 2" % sys.version_info[:2]
{
"dataformat": "plot/scatter/1",
"language": "python",
"parameters": {
"xlabel": {
"default": "X",
"type": "string",
"description": "The label of the X-axis (horizontal)"
},
"ylabel": {
"default": "Y",
"type": "string",
"description": "The label of the Y-axis (vertical)"
},
"title": {
"default": "Scatter plot",
"type": "string",
"description": "The title for this plot"
},
"xaxis_multiplier": {
"default": 1.0,
"type": "float64",
"description": "The multiplication factor for the X-axis (horizontal)"
},
"yaxis_multiplier": {
"default": 1.0,
"type": "float64",
"description": "The multiplication factor for the Y-axis (vertical)"
},
"line_attributes": {
"default": "",
"type": "string",
"description": "Scatter/Line attributes passed directly to Matplotlib"
},
"legend": {
"default": "",
"type": "string",
"description": "Short description of the data, to be added to the plot"
},
"grid": {
"default": false,
"type": "bool",
"description": "If we should draw grid lines or not for the plot"
},
"xaxis_log": {
"default": false,
"type": "bool",
"description": "If X-axis (horizontal) should be in log-scale"
},
"yaxis_log": {
"default": false,
"type": "bool",
"description": "If Y-axis (vertical) should be in log-scale"
},
"mimetype": {
"default": "image/png",
"description": "The type of image returned",
"type": "string",
"choice": [
"image/png",
"image/jpeg",
"application/pdf"
]
}
}
}
#!/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 six
import numpy
import itertools
# Make sure we won't require an X11 connection
import matplotlib
matplotlib.use("Agg") # noqa need to happen before further imports
from matplotlib.figure import Figure
import matplotlib.pyplot as pyplot
class Plotter:
def setup(self, parameters):
self.xlabel = parameters["xlabel"]
self.xaxis_multiplier = parameters["xaxis_multiplier"]
self.xaxis_log = parameters["xaxis_log"]
self.ylabel = parameters["ylabel"]
self.yaxis_multiplier = parameters["yaxis_multiplier"]
self.yaxis_log = parameters["yaxis_log"]
self.title = parameters["title"]
self.line_attributes = parameters["line_attributes"]
self.legend = parameters["legend"]
self.grid = parameters["grid"]
self.mimetype = parameters["mimetype"]
return True
def process(self, inputs):
# Creates the image to return
fig = Figure()
ax = fig.add_subplot(111)
if not isinstance(inputs, (list, tuple)):
inputs = [inputs]
self.legend = self.legend.split("&")
if isinstance(self.legend, str):
self.legend = [self.legend]
self.line_attributes = self.line_attributes.split("&")
if isinstance(self.line_attributes, str):
self.line_attributes = [self.line_attributes]
try:
Z = itertools.izip
except AttributeError:
Z = zip
C = itertools.cycle
for input, attributes, label in Z(
inputs, C(self.line_attributes), C(self.legend)
):
# Massages the input data
final_data = numpy.array([(k.x, k.y) for k in input.data])
x = final_data[:, 0]
y = final_data[:, 1]
x *= self.xaxis_multiplier
y *= self.yaxis_multiplier
args = (x, y)
if attributes:
args = args + (attributes,)
kwargs = {}
if label:
kwargs["label"] = label
# Plots
ax.plot(*args, **kwargs)
# Sets plot attributes
ax.set_xlabel(self.xlabel)
ax.set_ylabel(self.ylabel)
ax.set_title(self.title)
ax.grid(self.grid)
if self.xaxis_log:
ax.set_xscale("log")
if self.yaxis_log:
ax.set_yscale("log")
if any(self.legend):
ax.legend()
# Returns the image
if six.PY2:
sio = six.StringIO()
else:
sio = six.BytesIO()
if self.mimetype == "image/png":
pyplot.savefig(sio, format="png")
elif self.mimetype == "image/jpeg":
pyplot.savefig(sio, format="jpeg")
elif self.mimetype == "application/pdf":
from matplotlib.backends.backend_pdf import FigureCanvasPdf
canvas = FigureCanvasPdf(fig)
canvas.print_figure(sio)
return sio.getvalue()
{
"schema_version": 1,
"sets": [
{
"name": "small_data",
"outputs": {
"out": "user/single_integer/1"
}
}
]
}
{
"connections": [
{
"to": "echo1.in",
"from": "set.out",
"channel": "set"
},
{
"to": "echo2.in",
"from": "echo1.out",
"channel": "set"
},
{
"to": "analysis.in",
"from": "echo2.out",
"channel": "set"
}
],
"analyzers": [
{
"inputs": [
"in"
],
"synchronized_channel": "set",
"name": "analysis"
}
],
"datasets": [
{
"outputs": [
"out"
],
"name": "set"
}
],
"blocks": [
{
"inputs": [
"in"
],
"synchronized_channel": "set",
"name": "echo1",
"outputs": [
"out"
]
},
{
"inputs": [
"in"
],
"synchronized_channel": "set",
"name": "echo2",
"outputs": [
"out"
]
}
],
"representation": {
"connections": {
"set.out/echo1.in": [
{
"col": 4,
"row": 2
},
{
"col": 5,
"row": 2
},
{
"col": 6,
"row": 2
},
{
"col": 7,
"row": 2
}
],
"echo2.out/analysis.in": [
{
"col": 22,
"row": 2
},
{
"col": 23,
"row": 2
},
{
"col": 24,
"row": 2
},
{
"col": 25,
"row": 2
}
],
"echo1.out/echo2.in": [
{
"col": 13,
"row": 2
},
{
"col": 14,
"row": 2
},
{
"col": 15,
"row": 2
},
{
"col": 16,
"row": 2
}
]
},
"blocks": {
"set": {
"width": 5,
"height": 3,
"col": -1,
"row": 0
},
"analysis": {
"width": 6,
"height": 3,
"col": 25,
"row": 0
},
"echo2": {
"width": 6,
"height": 3,
"col": 16,
"row": 0
},
"echo1": {
"width": 6,
"height": 3,
"col": 7,
"row": 0
}
},
"channel_colors": {
"set": "#0000FF"
}
}
}
</
......@@ -109,7 +109,7 @@ def test_dependencies():
def test_invalid_dependencies():