diff --git a/.flake8 b/.flake8 index 5fabfeed91611982e96a84c038dbfe24b0708055..994815d8870e9822617c4578efdce0e121988c60 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] -max-line-length = 80 +max-line-length = 88 select = B,C,E,F,W,T4,B9,B950 -ignore = E501, W503 +ignore = E501, W503, E203 diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8d7af1de97c8aea738c0f7c503d1461ad413db4f --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,4 @@ +[settings] +line_length=88 +order_by_type=true +lines_between_types=1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4ee948878ad298b943d1fd097674fb3d78dd4be..b8be7b76e83826593fa81b855cb192d76e409f68 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,29 +1,37 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: - - repo: https://github.com/ambv/black + - repo: https://github.com/timothycrosley/isort + rev: 4.3.21-2 + hooks: + - id: isort + args: [-sl] + - repo: https://github.com/psf/black rev: stable 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 + - id: black + exclude: beat/backend/python/test/prefix/.*/syntax_error - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.0.0 hooks: + - id: check-ast + exclude: beat/backend/python/test/prefix/.*/syntax_error + - id: check-case-conflict - 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/backend/python/test/prefix/.*/syntax_error - id: check-added-large-files - id: check-docstring-first - id: flake8 + exclude: beat/backend/python/test/prefix/.*/(.*crash|syntax_error) - id: check-yaml exclude: conda/meta.yaml - repo: https://github.com/PyCQA/bandit 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/backend/python/test/prefix/.*/syntax_error - repo: local hooks: - id: sphinx-build diff --git a/beat/__init__.py b/beat/__init__.py index efd951b7ddd2ba0fcfc8d7af2b8dc4a9cfc15265..fbefb595c4507548b9f6585901016ea2578ec96c 100644 --- a/beat/__init__.py +++ b/beat/__init__.py @@ -34,4 +34,5 @@ ################################################################################### # see https://docs.python.org/3/library/pkgutil.html from pkgutil import extend_path + __path__ = extend_path(__path__, __name__) diff --git a/beat/backend/__init__.py b/beat/backend/__init__.py index efd951b7ddd2ba0fcfc8d7af2b8dc4a9cfc15265..fbefb595c4507548b9f6585901016ea2578ec96c 100644 --- a/beat/backend/__init__.py +++ b/beat/backend/__init__.py @@ -34,4 +34,5 @@ ################################################################################### # see https://docs.python.org/3/library/pkgutil.html from pkgutil import extend_path + __path__ = extend_path(__path__, __name__) diff --git a/beat/backend/python/__init__.py b/beat/backend/python/__init__.py index 61ffc198ee15428afd6e65adba12dfedc83d3cd7..efef23729349d56efc0ccf4256cfb7ef5678e0b4 100644 --- a/beat/backend/python/__init__.py +++ b/beat/backend/python/__init__.py @@ -31,4 +31,4 @@ # 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. # # # -################################################################################### \ No newline at end of file +################################################################################### diff --git a/beat/backend/python/algorithm.py b/beat/backend/python/algorithm.py index 4456a3119554f6c52f3877eef55f8603e68cb16c..2190b40d788d85416314b4a9d0d394524a0ad6a6 100644 --- a/beat/backend/python/algorithm.py +++ b/beat/backend/python/algorithm.py @@ -42,20 +42,19 @@ algorithm Validation for algorithms """ +import logging import os import sys -import logging -import six import numpy import simplejson as json +import six from . import dataformat from . import library from . import loader from . import utils - logger = logging.getLogger(__name__) diff --git a/beat/backend/python/baseformat.py b/beat/backend/python/baseformat.py index 5daaa7829b034dd7b0e9013a6d19def8d071a3cc..9e8267f7c4c37d99d529760764dc5e43873c6b8a 100644 --- a/beat/backend/python/baseformat.py +++ b/beat/backend/python/baseformat.py @@ -43,29 +43,31 @@ Base type for all data formats """ import struct + import numpy import six # This table defines what is the binary format for each supported basic type BINCODE = { - numpy.dtype('int8'): 'b', #signed char - numpy.dtype('int16'): 'h', #signed short - numpy.dtype('int32'): 'i', #signed int - numpy.dtype('int64'): 'q', #signed long long - numpy.dtype('uint8'): 'B', #unsigned char - numpy.dtype('uint16'): 'H', #unsigned short - numpy.dtype('uint32'): 'I', #unsigned int - numpy.dtype('uint64'): 'Q', #unsigned long long - numpy.dtype('float32'): 'f', #a single float - numpy.dtype('float64'): 'd', #a single double - numpy.dtype('complex64'): 'f', #two floats (real, imag) - numpy.dtype('complex128'): 'd', #two doubles (real, imag) - numpy.dtype('bool'): '?', #C99 Bool_ - } - -ENDIANNESS = '<' #little-endian -SIZE = 'Q' #64-bit unsigned -STRING = ENDIANNESS + SIZE + '%ds' + numpy.dtype("int8"): "b", # signed char + numpy.dtype("int16"): "h", # signed short + numpy.dtype("int32"): "i", # signed int + numpy.dtype("int64"): "q", # signed long long + numpy.dtype("uint8"): "B", # unsigned char + numpy.dtype("uint16"): "H", # unsigned short + numpy.dtype("uint32"): "I", # unsigned int + numpy.dtype("uint64"): "Q", # unsigned long long + numpy.dtype("float32"): "f", # a single float + numpy.dtype("float64"): "d", # a single double + numpy.dtype("complex64"): "f", # two floats (real, imag) + numpy.dtype("complex128"): "d", # two doubles (real, imag) + numpy.dtype("bool"): "?", # C99 Bool_ +} + +ENDIANNESS = "<" # little-endian +SIZE = "Q" # 64-bit unsigned +STRING = ENDIANNESS + SIZE + "%ds" + def setup_scalar(formatname, attrname, dtype, value, casting, add_defaults): """Casts the value to the the scalar type defined by dtype @@ -98,16 +100,20 @@ def setup_scalar(formatname, attrname, dtype, value, casting, add_defaults): """ - if hasattr(dtype, 'type') and issubclass(dtype.type, numpy.generic): + if hasattr(dtype, "type") and issubclass(dtype.type, numpy.generic): if value is None: # use the default for the type return dtype.type() else: - if value: # zero is classified as int64 which can't be safely casted to uint64 + if ( + value + ): # zero is classified as int64 which can't be safely casted to uint64 if not numpy.can_cast(numpy.array(value).dtype, dtype, casting=casting): - raise TypeError("cannot safely cast attribute `%s' on dataformat " \ - "`%s' with type `%s' to `%s' without precision loss" % \ - (attrname, formatname, numpy.array(value).dtype, dtype)) + raise TypeError( + "cannot safely cast attribute `%s' on dataformat " + "`%s' with type `%s' to `%s' without precision loss" + % (attrname, formatname, numpy.array(value).dtype, dtype) + ) return dtype.type(value) elif issubclass(dtype, str): # it is a string @@ -119,6 +125,7 @@ def setup_scalar(formatname, attrname, dtype, value, casting, add_defaults): else: # it is a dataformat return dtype().from_dict(value, casting=casting, add_defaults=add_defaults) + class _protected_str_ndarray(numpy.ndarray): """Increments :py:class:`numpy.ndarray` so that item assignment is checked """ @@ -126,9 +133,11 @@ class _protected_str_ndarray(numpy.ndarray): def __setitem__(self, key, value): """First checks for conformance and then assigns""" if not isinstance(value, six.string_types): - raise TypeError("string array requires string objects for " \ - "items but you passed `%s' (%s) while setting element " \ - "%s" % (value, type(value), key)) + raise TypeError( + "string array requires string objects for " + "items but you passed `%s' (%s) while setting element " + "%s" % (value, type(value), key) + ) return numpy.ndarray.__setitem__(self, key, value) @@ -140,14 +149,12 @@ class _protected_ndarray(numpy.ndarray): """First checks for conformance and then assigns""" value_ = self._format_dtype() value_.from_dict( - value, - casting=self._format_casting, - add_defaults=self._format_add_defaults, - ) + value, casting=self._format_casting, add_defaults=self._format_add_defaults, + ) return numpy.ndarray.__setitem__(self, key, value_) -def setup_array(formatname, attrname, shape, dtype, value, casting, - add_defaults): + +def setup_array(formatname, attrname, shape, dtype, value, casting, add_defaults): """Casts the value to the the array type defined by (shape, dtype) @@ -185,53 +192,57 @@ def setup_array(formatname, attrname, shape, dtype, value, casting, """ def is_empty(x): - if isinstance(x, (numpy.ndarray,)): return not x.size + if isinstance(x, (numpy.ndarray,)): + return not x.size return not x if is_empty(value): # creates an empty array that remains unchecked - if hasattr(dtype, 'type') and issubclass(dtype.type, numpy.generic): + if hasattr(dtype, "type") and issubclass(dtype.type, numpy.generic): retval = numpy.ndarray(shape, dtype=dtype) - elif issubclass(dtype, str): #it is a string + elif issubclass(dtype, str): # it is a string retval = numpy.ndarray(shape, dtype=object).view(_protected_str_ndarray) - retval[~retval.astype(bool)] = '' - else: #it is a dataformat + retval[~retval.astype(bool)] = "" + else: # it is a dataformat retval = numpy.ndarray(shape, dtype=object).view(_protected_ndarray) retval._format_dtype = dtype - retval._format_casting = 'safe' + retval._format_casting = "safe" retval._format_add_defaults = True else: - if hasattr(dtype, 'type'): + if hasattr(dtype, "type"): retval = numpy.array(value, dtype=dtype) else: - retval = numpy.array(value) #blindly converts data + retval = numpy.array(value) # blindly converts data if retval.ndim != len(shape): - raise TypeError("input argument for array attribute `%s' on " \ - "dataformat `%s' has %d dimensions and does not respect " \ - "what is requested in the data format (%d dimension(s))" % ( - attrname, formatname, retval.ndim, len(shape), - ) - ) + raise TypeError( + "input argument for array attribute `%s' on " + "dataformat `%s' has %d dimensions and does not respect " + "what is requested in the data format (%d dimension(s))" + % (attrname, formatname, retval.ndim, len(shape),) + ) for i, d in enumerate(retval.shape): if shape[i] and shape[i] != d: - raise TypeError("input argument for array attribute `%s' on " \ - "dataformat `%s' does not respect dimension " \ - "restrictions for dimension `%d' as requested in the " \ - "data format (%d != %d)" % (attrname, formatname, i, d, shape[i]) - ) - - if hasattr(dtype, 'type') and issubclass(dtype.type, numpy.generic): + raise TypeError( + "input argument for array attribute `%s' on " + "dataformat `%s' does not respect dimension " + "restrictions for dimension `%d' as requested in the " + "data format (%d != %d)" % (attrname, formatname, i, d, shape[i]) + ) + + if hasattr(dtype, "type") and issubclass(dtype.type, numpy.generic): if not numpy.can_cast(retval.dtype, dtype, casting=casting): - raise TypeError("cannot safely cast array attribute `%s' " \ - "on dataformat `%s' with type `%s' to `%s' without precision " \ - "loss" % (attrname, formatname, retval.dtype, dtype)) + raise TypeError( + "cannot safely cast array attribute `%s' " + "on dataformat `%s' with type `%s' to `%s' without precision " + "loss" % (attrname, formatname, retval.dtype, dtype) + ) return retval.astype(dtype) - elif issubclass(dtype, str): #it is a string + elif issubclass(dtype, str): # it is a string return numpy.array(retval, dtype=object).view(_protected_str_ndarray) # it is a dataformat @@ -242,10 +253,11 @@ def setup_array(formatname, attrname, shape, dtype, value, casting, retval = numpy.frompyfunc(constructor, 1, 1)(retval).view(_protected_ndarray) retval._format_dtype = dtype - retval._format_casting = 'safe' + retval._format_casting = "safe" retval._format_add_defaults = True return retval + def pack_array(dtype, value, fd): """Binary-encodes the array at ``value`` into the file descriptor ``fd`` @@ -265,18 +277,18 @@ def pack_array(dtype, value, fd): shape_format = ENDIANNESS + str(len(value.shape)) + SIZE fd.write(struct.pack(shape_format, *value.shape)) - if hasattr(dtype, 'type') and issubclass(dtype.type, numpy.generic): + if hasattr(dtype, "type") and issubclass(dtype.type, numpy.generic): # N.B.: this bit of code is optimized to reduce memory usage # if it is not C-style (row order) and memory contiguous, make a copy - value = numpy.require(value, requirements='C') # C_CONTIGUOUS + value = numpy.require(value, requirements="C") # C_CONTIGUOUS # makes sure endianness is respected, will copy otherwise value = value.astype(ENDIANNESS + value.dtype.str[1:], copy=False) fd.write(value.tostring()) elif issubclass(dtype, str): # it is a string for item in value.flat: - encoded = item.encode('utf-8') + encoded = item.encode("utf-8") length = len(encoded) fd.write(struct.pack(STRING % length, length, encoded)) @@ -300,15 +312,16 @@ def pack_scalar(dtype, value, fd): """ - if hasattr(dtype, 'type') and issubclass(dtype.type, numpy.generic): + if hasattr(dtype, "type") and issubclass(dtype.type, numpy.generic): if issubclass(dtype.type, numpy.complexfloating): - fd.write(struct.pack(ENDIANNESS + '2' + BINCODE[dtype], - value.real, value.imag)) + fd.write( + struct.pack(ENDIANNESS + "2" + BINCODE[dtype], value.real, value.imag) + ) else: fd.write(struct.pack(ENDIANNESS + BINCODE[dtype], value)) elif issubclass(dtype, str): # it is a string - encoded = value.encode('utf-8') + encoded = value.encode("utf-8") length = len(encoded) fd.write(struct.pack(STRING % length, length, encoded)) @@ -323,10 +336,10 @@ def read_some(format, fd): def read_string(fd): """Reads the next string from the file descriptor ``fd``""" - string_format = '%ds' % read_some(ENDIANNESS + SIZE, fd) + string_format = "%ds" % read_some(ENDIANNESS + SIZE, fd) retval = read_some(string_format, fd) if not isinstance(retval[0], str): - return (retval[0].decode('utf8'),) + return (retval[0].decode("utf8"),) return retval @@ -352,9 +365,9 @@ def unpack_array(shape, dtype, fd): """ # reads the actual array shape: remember, the declaration may have zeros - shape_ = read_some(ENDIANNESS + str(len(shape)) + 'Q', fd) + shape_ = read_some(ENDIANNESS + str(len(shape)) + "Q", fd) - if hasattr(dtype, 'type') and issubclass(dtype.type, numpy.generic): + if hasattr(dtype, "type") and issubclass(dtype.type, numpy.generic): # N.B.: this bit of code is optimized to reduce memory usage data_format = ENDIANNESS + dtype.str[1:] count = numpy.prod(shape_) @@ -395,10 +408,10 @@ def unpack_scalar(dtype, fd): """ - if hasattr(dtype, 'type') and issubclass(dtype.type, numpy.generic): + if hasattr(dtype, "type") and issubclass(dtype.type, numpy.generic): if issubclass(dtype.type, numpy.complexfloating): # complex - data_format = ENDIANNESS + '2' + BINCODE[dtype] + data_format = ENDIANNESS + "2" + BINCODE[dtype] a = read_some(data_format, fd) return dtype.type(complex(a[0], a[1])) @@ -431,9 +444,9 @@ class baseformat(object): def __init__(self, **kwargs): - self.from_dict(kwargs, casting='unsafe', add_defaults=True) + self.from_dict(kwargs, casting="unsafe", add_defaults=True) - def from_dict(self, data, casting='safe', add_defaults=False): + def from_dict(self, data, casting="safe", add_defaults=False): """Same as initializing the object, but with a less strict type casting Construction is, by default, set to using a **unsafe** data type @@ -459,7 +472,8 @@ class baseformat(object): """ - if data is None: data = {} + if data is None: + data = {} user_attributes = set([k for k in data.keys() if k != "__type__"]) declared_attributes = set(self._format.keys()) @@ -468,25 +482,29 @@ class baseformat(object): # in this case, the user must provide all attributes if user_attributes != declared_attributes: undeclared_attributes = declared_attributes - user_attributes - raise AttributeError("missing attributes (%s) for dataformat " \ - "`%s' which require `%s'" % ( - ', '.join(undeclared_attributes), - self._name, - ', '.join(declared_attributes), - ), - ) + raise AttributeError( + "missing attributes (%s) for dataformat " + "`%s' which require `%s'" + % ( + ", ".join(undeclared_attributes), + self._name, + ", ".join(declared_attributes), + ), + ) iterate_attributes = user_attributes else: # then, the user passed attributes must be a subset if not user_attributes.issubset(declared_attributes): unknown_attributes = user_attributes - declared_attributes - raise AttributeError("unexpected attribute (%s) for dataformat " \ - "`%s' which require `%s'" % ( - ', '.join(unknown_attributes), - self._name, - ', '.join(declared_attributes), - ), - ) + raise AttributeError( + "unexpected attribute (%s) for dataformat " + "`%s' which require `%s'" + % ( + ", ".join(unknown_attributes), + self._name, + ", ".join(declared_attributes), + ), + ) iterate_attributes = declared_attributes for k in iterate_attributes: @@ -505,15 +523,16 @@ class baseformat(object): if isinstance(self._format[key], list): dtype = getattr(self.__class__, key)[-1] - if (hasattr(dtype, 'type') and issubclass(dtype.type, numpy.generic)) \ - or dtype is str: + if ( + hasattr(dtype, "type") and issubclass(dtype.type, numpy.generic) + ) or dtype is str: retval[key] = v else: # it is an array of dataformat objects retval[key] = numpy.frompyfunc(lambda x: x.as_dict(), 1, 1)(v) retval[key] = retval[key].tolist() else: - retval[key] = v if not hasattr(v, 'as_dict') else v.as_dict() + retval[key] = v if not hasattr(v, "as_dict") else v.as_dict() return retval @@ -528,8 +547,10 @@ class baseformat(object): for key in sorted(self._format.keys()): dtype = getattr(self.__class__, key) value = getattr(self, key) - if isinstance(dtype, list): pack_array(dtype[-1], value, fd) - else: pack_scalar(dtype, value, fd) + if isinstance(dtype, list): + pack_array(dtype[-1], value, fd) + else: + pack_scalar(dtype, value, fd) def pack(self): """Creates a binary representation of this object as a string @@ -564,7 +585,6 @@ class baseformat(object): return self - def unpack(self, s): """Loads a binary representation of this object from a string @@ -574,7 +594,6 @@ class baseformat(object): return self.unpack_from(six.BytesIO(s)) - def isclose(self, other, *args, **kwargs): """Tests for closeness in the numerical sense. @@ -592,7 +611,8 @@ class baseformat(object): """ - if not isinstance(other, self.__class__): return False + if not isinstance(other, self.__class__): + return False for key in sorted(self._format.keys()): @@ -603,24 +623,31 @@ class baseformat(object): if isinstance(dtype, list): dtype = dtype[-1] - if hasattr(dtype, 'type'): # numpy array + if hasattr(dtype, "type"): # numpy array # note: avoid numpy.all(numpy.isclose()) for arrays # see bug https://github.com/numpy/numpy/issues/2280 if not numpy.allclose(this, that, *args, **kwargs): return False elif issubclass(dtype, six.string_types): # simple string - if not numpy.all(this == that): return False - else: #baseformat - isclose = numpy.frompyfunc(lambda x,y: x.isclose(y, *args, **kwargs), 2, 1) - if not numpy.all(isclose(this, that)): return False + if not numpy.all(this == that): + return False + else: # baseformat + isclose = numpy.frompyfunc( + lambda x, y: x.isclose(y, *args, **kwargs), 2, 1 + ) + if not numpy.all(isclose(this, that)): + return False else: - if hasattr(dtype, 'type'): # numpy scalar - if not numpy.isclose(this, that, *args, **kwargs): return False + if hasattr(dtype, "type"): # numpy scalar + if not numpy.isclose(this, that, *args, **kwargs): + return False elif issubclass(dtype, six.string_types): # simple string - if this != that: return False + if this != that: + return False else: # baseformat - if not this.isclose(that, *args, **kwargs): return False + if not this.isclose(that, *args, **kwargs): + return False # if you survived to this point, the objects are close return True @@ -641,15 +668,28 @@ class baseformat(object): dtype = getattr(self.__class__, key) if isinstance(dtype, list): - value = setup_array(self._name, key, dtype[:-1], dtype[-1], value, - casting=casting, add_defaults=add_defaults) + value = setup_array( + self._name, + key, + dtype[:-1], + dtype[-1], + value, + casting=casting, + add_defaults=add_defaults, + ) else: - value = setup_scalar(self._name, key, dtype, value, - casting=casting, add_defaults=add_defaults) + value = setup_scalar( + self._name, + key, + dtype, + value, + casting=casting, + add_defaults=add_defaults, + ) return object.__setattr__(self, key, value) def __setattr__(self, key, value): """Set an attribute, with validation""" - return self._setattr(key, value, 'safe', False) + return self._setattr(key, value, "safe", False) diff --git a/beat/backend/python/data.py b/beat/backend/python/data.py index 207d3bab83d2db7c550e1b2b2e500eeeaa96f805..b38b8b1b668abafde6a8902c941f22344308a735 100644 --- a/beat/backend/python/data.py +++ b/beat/backend/python/data.py @@ -42,23 +42,24 @@ data Data I/O classes and functions """ +import abc +import glob +import logging import os import re -import glob -import simplejson as json import time -import abc -import zmq -import logging -import six -from functools import reduce from collections import namedtuple +from functools import reduce + +import simplejson as json +import six +import zmq -from .hash import hashFileContents -from .dataformat import DataFormat from .algorithm import Algorithm +from .dataformat import DataFormat from .exceptions import RemoteException +from .hash import hashFileContents logger = logging.getLogger(__name__) @@ -107,8 +108,8 @@ def mixDataIndices(list_of_data_indices): for index in range(start, end + 1): done = False - for l in list_of_data_indices: - for indices in l: + for data_indices in list_of_data_indices: + for indices in data_indices: if indices[1] == index: result.append((current_start, index)) current_start = index + 1 diff --git a/beat/backend/python/data_loaders.py b/beat/backend/python/data_loaders.py index 429a26d4f29254b61d697f8f3aad8db8a0f37344..adbc41c1fc50695de72331410aa5eed2e9eee839 100644 --- a/beat/backend/python/data_loaders.py +++ b/beat/backend/python/data_loaders.py @@ -46,7 +46,6 @@ import six from .data import mixDataIndices - # ---------------------------------------------------------- diff --git a/beat/backend/python/database.py b/beat/backend/python/database.py index c6d2fa76b43fd1aa8b730f2d6e362126a70ff047..1f5ce1db050699dd7bc1583890f34c3727133c08 100644 --- a/beat/backend/python/database.py +++ b/beat/backend/python/database.py @@ -42,23 +42,22 @@ database Validation of databases """ +import itertools import os import sys -import six -import simplejson as json -import itertools -import numpy as np from collections import namedtuple +import numpy as np +import simplejson as json +import six + from . import loader from . import utils - -from .protocoltemplate import ProtocolTemplate from .dataformat import DataFormat -from .outputs import OutputList from .exceptions import OutputError - +from .outputs import OutputList +from .protocoltemplate import ProtocolTemplate # ---------------------------------------------------------- diff --git a/beat/backend/python/dataformat.py b/beat/backend/python/dataformat.py index fab6683dac59fc52dc432d0ac9a23fc134ab1eea..fba3199e166c02702266ddf354129a2fa75fa6d9 100644 --- a/beat/backend/python/dataformat.py +++ b/beat/backend/python/dataformat.py @@ -42,17 +42,16 @@ dataformat Validation and parsing for dataformats """ -import re import copy +import re -import six import numpy import simplejson as json +import six from . import utils from .baseformat import baseformat - # ---------------------------------------------------------- diff --git a/beat/backend/python/execution/__init__.py b/beat/backend/python/execution/__init__.py index a847978d9efae0834b457f20ef59ada590f3a688..fe09e1d41fa6994499396b7a3c38a9fa8a4fcf6c 100644 --- a/beat/backend/python/execution/__init__.py +++ b/beat/backend/python/execution/__init__.py @@ -34,9 +34,16 @@ ################################################################################### -from .database import DBExecutor from .algorithm import AlgorithmExecutor +from .database import DBExecutor from .loop import LoopExecutor - -from .messagehandlers import MessageHandler from .messagehandlers import LoopMessageHandler +from .messagehandlers import MessageHandler + +__all__ = [ + "AlgorithmExecutor", + "DBExecutor", + "LoopExecutor", + "LoopMessageHandler", + "MessageHandler", +] diff --git a/beat/backend/python/execution/algorithm.py b/beat/backend/python/execution/algorithm.py index d57f08c06c251e7cd04ca784e84c72617f0732b8..abda1faee489875756dfd08e92ce6d8d1a5ae55d 100644 --- a/beat/backend/python/execution/algorithm.py +++ b/beat/backend/python/execution/algorithm.py @@ -44,15 +44,15 @@ A class that can setup and execute algorithm blocks on the backend import logging import os + import simplejson import zmq +from .. import stats from ..algorithm import Algorithm +from ..helpers import AccessMode from ..helpers import create_inputs_from_configuration from ..helpers import create_outputs_from_configuration -from ..helpers import AccessMode -from .. import stats - from .loop import LoopChannel logger = logging.getLogger(__name__) diff --git a/beat/backend/python/execution/database.py b/beat/backend/python/execution/database.py index f4d4611fbabc55761a94aa69443af6fffa99b253..cd5fbe688d4b1175d960398177aece9d232ffe25 100644 --- a/beat/backend/python/execution/database.py +++ b/beat/backend/python/execution/database.py @@ -43,6 +43,7 @@ Execution utilities """ import os + import simplejson from ..database import Database diff --git a/beat/backend/python/execution/loop.py b/beat/backend/python/execution/loop.py index 8ec7610eb6ab19bccd0c043f03ff511c6427e01c..259c7147c4260604a1911939daf35d73e960d66b 100644 --- a/beat/backend/python/execution/loop.py +++ b/beat/backend/python/execution/loop.py @@ -42,21 +42,20 @@ executor A class that can setup and execute loop algorithm blocks on the backend """ +import json import logging import os -import json + import zmq from ..algorithm import Algorithm from ..dataformat import DataFormat +from ..exceptions import RemoteException +from ..helpers import AccessMode from ..helpers import create_inputs_from_configuration from ..helpers import create_outputs_from_configuration -from ..helpers import AccessMode -from ..exceptions import RemoteException - from .helpers import make_data_format - logger = logging.getLogger(__name__) diff --git a/beat/backend/python/execution/messagehandlers.py b/beat/backend/python/execution/messagehandlers.py index 544cb449ef3a86699d262f1ea3d4a76683912608..5ea36a5577a92a33ef0115f92c265c2c4bb4af7f 100644 --- a/beat/backend/python/execution/messagehandlers.py +++ b/beat/backend/python/execution/messagehandlers.py @@ -44,19 +44,16 @@ communication. """ import logging +import threading -import zmq import simplejson -import threading +import zmq +from .. import baseformat from ..dataformat import DataFormat from ..exceptions import RemoteException - -from .. import baseformat - from .helpers import make_data_format - logger = logging.getLogger(__name__) diff --git a/beat/backend/python/hash.py b/beat/backend/python/hash.py index 7d9c54e03ecbe2999d057a63732f320533aef4ca..c6a483bccf997a8fcb40132c49562575bb009312 100644 --- a/beat/backend/python/hash.py +++ b/beat/backend/python/hash.py @@ -42,13 +42,13 @@ hash Various functions for hashing platform contributions and others """ -import hashlib -import simplejson import collections import copy -import six +import hashlib import os +import simplejson +import six # ---------------------------------------------------------- @@ -59,9 +59,9 @@ def _sha256(s): """ if isinstance(s, six.string_types): try: - s = six.u(s).encode('utf-8') + s = six.u(s).encode("utf-8") except Exception: - s = s.encode('utf-8') + s = s.encode("utf-8") return hashlib.sha256(s).hexdigest() @@ -71,14 +71,14 @@ def _sha256(s): def _stringify(dictionary): names = sorted(dictionary.keys()) - converted_dictionary = '{' + converted_dictionary = "{" for name in names: converted_dictionary += '"%s":%s,' % (name, str(dictionary[name])) if len(converted_dictionary) > 1: converted_dictionary = converted_dictionary[:-1] - converted_dictionary += '}' + converted_dictionary += "}" return converted_dictionary @@ -87,13 +87,13 @@ def _stringify(dictionary): def _compact(text): - return text.replace(' ', '').replace('\n', '') + return text.replace(" ", "").replace("\n", "") # ---------------------------------------------------------- -def toPath(hash, suffix='.data'): +def toPath(hash, suffix=".data"): """ Returns the path on disk which corresponds to the hash given. Parameters: @@ -159,7 +159,7 @@ def hashJSON(contents, description): contents = copy.deepcopy(contents) # temporary copy del contents[description] contents = simplejson.dumps(contents, sort_keys=True) - return hashlib.sha256(contents.encode('utf-8')).hexdigest() + return hashlib.sha256(contents.encode("utf-8")).hexdigest() # ---------------------------------------------------------- @@ -175,11 +175,14 @@ def hashJSONFile(path, description): """ try: - with open(path, 'rb') as f: + with open(path, "rb") as f: # preserve order - return hashJSON(simplejson.loads(f.read().decode('utf-8'), - object_pairs_hook=collections.OrderedDict), - description) + return hashJSON( + simplejson.loads( + f.read().decode("utf-8"), object_pairs_hook=collections.OrderedDict + ), + description, + ) except simplejson.JSONDecodeError: # falls back to normal file content hashing return hashFileContents(path) @@ -195,9 +198,9 @@ def hashFileContents(path): str: hash """ - with open(path, 'rb') as f: + with open(path, "rb") as f: sha256 = hashlib.sha256() - for chunk in iter(lambda: f.read(sha256.block_size * 1000), b''): + for chunk in iter(lambda: f.read(sha256.block_size * 1000), b""): sha256.update(chunk) return sha256.hexdigest() @@ -218,9 +221,14 @@ def hashDataset(database_name, protocol_name, set_name): str: hash """ - s = _compact("""{ + s = ( + _compact( + """{ "database": "%s", "protocol": "%s", "set": "%s" -}""") % (database_name, protocol_name, set_name) +}""" + ) + % (database_name, protocol_name, set_name) + ) return hash(s) diff --git a/beat/backend/python/helpers.py b/beat/backend/python/helpers.py index e2aeed92f3db599b6fbcb6fc2ec688932f956500..521bc4dcadf8f33d9e847eae4b4339c4177e5d58 100644 --- a/beat/backend/python/helpers.py +++ b/beat/backend/python/helpers.py @@ -42,24 +42,24 @@ helpers This module implements various helper methods and classes """ -import os import errno import logging +import os +from .algorithm import Algorithm +from .data import CachedDataSink from .data import CachedDataSource from .data import RemoteDataSource -from .data import CachedDataSink from .data import getAllFilenames -from .data_loaders import DataLoaderList from .data_loaders import DataLoader -from .inputs import InputList +from .data_loaders import DataLoaderList from .inputs import Input from .inputs import InputGroup -from .outputs import SynchronizationListener -from .outputs import OutputList +from .inputs import InputList from .outputs import Output +from .outputs import OutputList from .outputs import RemotelySyncedOutput -from .algorithm import Algorithm +from .outputs import SynchronizationListener logger = logging.getLogger(__name__) diff --git a/beat/backend/python/inputs.py b/beat/backend/python/inputs.py index daf9e1867c2d002fa88f7f45ef86182966068b84..84cc6623e8300e867dd22be0e1172604bf08bc46 100644 --- a/beat/backend/python/inputs.py +++ b/beat/backend/python/inputs.py @@ -46,7 +46,6 @@ from functools import reduce import six - # ---------------------------------------------------------- diff --git a/beat/backend/python/library.py b/beat/backend/python/library.py index 8d91adcbc8b94ccf2f37b97298e30a4c233f4c87..22bd721bc20215f061a12d465bc2a4da31de3785 100644 --- a/beat/backend/python/library.py +++ b/beat/backend/python/library.py @@ -43,12 +43,12 @@ Validation for libraries """ import os + import simplejson as json from . import loader from . import utils - # ---------------------------------------------------------- diff --git a/beat/backend/python/loader.py b/beat/backend/python/loader.py index 831b1879e133877d835b82fd7c66f423336f9c9a..99a8715315852bceba860f2b97422dec49bda5c6 100644 --- a/beat/backend/python/loader.py +++ b/beat/backend/python/loader.py @@ -44,10 +44,10 @@ executor. Safe in this context means that if the method raises an exception, it will catch it and return in a suitable form to the caller. """ -import sys -import six import imp +import sys +import six # ---------------------------------------------------------- @@ -79,11 +79,11 @@ def load_module(name, path, uses): # loads used modules for k, v in uses.items(): - retval.__dict__[k] = load_module(k, v['path'], v['uses']) + retval.__dict__[k] = load_module(k, v["path"], v["uses"]) # execute the module code on the context of previously import modules with open(path, "rb") as f: - exec(compile(f.read(), path, 'exec'), retval.__dict__) + exec(compile(f.read(), path, "exec"), retval.__dict__) # nosec return retval @@ -118,7 +118,7 @@ def run(obj, method, exc=None, *args, **kwargs): """ try: - if method == '__new__': + if method == "__new__": return obj(*args, **kwargs) return getattr(obj, method)(*args, **kwargs) diff --git a/beat/backend/python/protocoltemplate.py b/beat/backend/python/protocoltemplate.py index b6bf9dc1ab0b72f564e53f797048a89979b2e3b3..a5ea0bd101c8daf7c8f99bb15cdb0cd490157bee 100644 --- a/beat/backend/python/protocoltemplate.py +++ b/beat/backend/python/protocoltemplate.py @@ -44,10 +44,8 @@ Validation of database protocol templates import simplejson as json -from .dataformat import DataFormat - from . import utils - +from .dataformat import DataFormat # ---------------------------------------------------------- diff --git a/beat/backend/python/scripts/__init__.py b/beat/backend/python/scripts/__init__.py index 61ffc198ee15428afd6e65adba12dfedc83d3cd7..efef23729349d56efc0ccf4256cfb7ef5678e0b4 100644 --- a/beat/backend/python/scripts/__init__.py +++ b/beat/backend/python/scripts/__init__.py @@ -31,4 +31,4 @@ # 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. # # # -################################################################################### \ No newline at end of file +################################################################################### diff --git a/beat/backend/python/scripts/databases_provider.py b/beat/backend/python/scripts/databases_provider.py index 50094958edd5419e9a4b167be08a20e2b8ef299b..ea7e90cd19e185d2a901a05e8885295b4d490eba 100644 --- a/beat/backend/python/scripts/databases_provider.py +++ b/beat/backend/python/scripts/databases_provider.py @@ -56,42 +56,38 @@ options: """ +import json import logging - import os +import pwd import sys + import docopt import simplejson -import pwd -import stat -import json - -import zmq +from beat.backend.python.exceptions import UserError from beat.backend.python.execution import DBExecutor from beat.backend.python.execution import MessageHandler -from beat.backend.python.exceptions import UserError - -#---------------------------------------------------------- +# ---------------------------------------------------------- def process_traceback(tb, prefix): import traceback - databases_prefix = os.path.join(prefix, 'databases') + os.sep + databases_prefix = os.path.join(prefix, "databases") + os.sep for first_line, line in enumerate(tb): if line[0].startswith(databases_prefix): break - s = ''.join(traceback.format_list(tb[first_line:])) - s = s.replace(databases_prefix, 'databases' + os.sep).strip() + s = "".join(traceback.format_list(tb[first_line:])) + s = s.replace(databases_prefix, "databases" + os.sep).strip() return s -#---------------------------------------------------------- +# ---------------------------------------------------------- def main(arguments=None): @@ -100,112 +96,123 @@ def main(arguments=None): if arguments is None: arguments = sys.argv[1:] - package = __name__.rsplit('.', 2)[0] - version = package + ' v' + \ - __import__('pkg_resources').require(package)[0].version + package = __name__.rsplit(".", 2)[0] + version = package + " v" + __import__("pkg_resources").require(package)[0].version prog = os.path.basename(sys.argv[0]) args = docopt.docopt( - __doc__ % dict(prog=prog, version=version), - argv=arguments, - version=version + __doc__ % dict(prog=prog, version=version), argv=arguments, version=version ) - # Setup the logging system - formatter = logging.Formatter(fmt="[%(asctime)s - databases_provider.py - " \ - "%(name)s] %(levelname)s: %(message)s", - datefmt="%d/%b/%Y %H:%M:%S") + formatter = logging.Formatter( + fmt="[%(asctime)s - databases_provider.py - " + "%(name)s] %(levelname)s: %(message)s", + datefmt="%d/%b/%Y %H:%M:%S", + ) handler = logging.StreamHandler() handler.setFormatter(formatter) - root_logger = logging.getLogger('beat.backend.python') + root_logger = logging.getLogger("beat.backend.python") root_logger.addHandler(handler) - if args['--debug']: + if args["--debug"]: root_logger.setLevel(logging.DEBUG) else: root_logger.setLevel(logging.INFO) - logger = logging.getLogger(__name__) - - # Create the message handler - message_handler = MessageHandler(args['<addr>']) - + message_handler = MessageHandler(args["<addr>"]) # If necessary, change to another user (with less privileges, but has access # to the databases) - with open(os.path.join(args['<dir>'], 'configuration.json'), 'r') as f: + with open(os.path.join(args["<dir>"], "configuration.json"), "r") as f: cfg = simplejson.load(f) - if 'datasets_uid' in cfg: + if "datasets_uid" in cfg: # First create the user (if it doesn't exists) try: - user = pwd.getpwuid(cfg['datasets_uid']) - except: - import subprocess - retcode = subprocess.call(['adduser', '--uid', str(cfg['datasets_uid']), - '--no-create-home', '--disabled-password', - '--disabled-login', '--gecos', '""', '-q', - 'beat-nobody']) + _ = pwd.getpwuid(cfg["datasets_uid"]) + except Exception: + import subprocess # nosec + + retcode = subprocess.call( # nosec + [ + "adduser", + "--uid", + str(cfg["datasets_uid"]), + "--no-create-home", + "--disabled-password", + "--disabled-login", + "--gecos", + '""', + "-q", + "beat-nobody", + ] + ) if retcode != 0: - message_handler.send_error('Failed to create an user with the UID %s' % args['uid'], 'sys') + message_handler.send_error( + "Failed to create an user with the UID %s" % args["uid"], "sys" + ) return 1 # Change the current user try: - os.setgid(cfg['datasets_uid']) - os.setuid(cfg['datasets_uid']) - except: + os.setgid(cfg["datasets_uid"]) + os.setuid(cfg["datasets_uid"]) + except Exception: import traceback - message_handler.send_error(traceback.format_exc(), 'sys') + + message_handler.send_error(traceback.format_exc(), "sys") message_handler.destroy() return 1 - try: # Check the dir - if not os.path.exists(args['<dir>']): - raise IOError("Running directory `%s' not found" % args['<dir>']) + if not os.path.exists(args["<dir>"]): + raise IOError("Running directory `%s' not found" % args["<dir>"]) # Sets up the execution dataformat_cache = {} database_cache = {} try: - configuration_path = os.path.join(args['<dir>'], 'configuration.json') + configuration_path = os.path.join(args["<dir>"], "configuration.json") if not os.path.exists(configuration_path): - raise RuntimeError("Configuration file '%s' not found" % - configuration_path) + raise RuntimeError( + "Configuration file '%s' not found" % configuration_path + ) with open(configuration_path) as f: configuration_data = json.load(f) - configuration_name = args.get('<conf_name>', None) + configuration_name = args.get("<conf_name>", None) if configuration_name is not None: - configuration_data = configuration_data.get(configuration_name, - None) + configuration_data = configuration_data.get(configuration_name, None) if configuration_data is None: - raise RuntimeError("Configuration section '%s' not found" % - configuration_name) - - dbexecutor = DBExecutor(message_handler, - os.path.join(args['<dir>'], 'prefix'), - args['<cache>'], - configuration_data, - dataformat_cache, - database_cache) + raise RuntimeError( + "Configuration section '%s' not found" % configuration_name + ) + + dbexecutor = DBExecutor( + message_handler, + os.path.join(args["<dir>"], "prefix"), + args["<cache>"], + configuration_data, + dataformat_cache, + database_cache, + ) except (MemoryError): raise except Exception as e: import traceback + exc_type, exc_value, exc_traceback = sys.exc_info() tb = traceback.extract_tb(exc_traceback) - s = process_traceback(tb, os.path.join(args['<dir>'], 'prefix')) + s = process_traceback(tb, os.path.join(args["<dir>"], "prefix")) raise UserError("%s%s: %s" % (s, type(e).__name__, e)) # Execute the code @@ -216,29 +223,33 @@ def main(arguments=None): raise except Exception as e: import traceback + exc_type, exc_value, exc_traceback = sys.exc_info() tb = traceback.extract_tb(exc_traceback) - s = process_traceback(tb, os.path.join(args['<dir>'], 'prefix')) + s = process_traceback(tb, os.path.join(args["<dir>"], "prefix")) raise UserError("%s%s: %s" % (s, type(e).__name__, e)) except UserError as e: - message_handler.send_error(str(e), 'usr') + message_handler.send_error(str(e), "usr") message_handler.destroy() return 1 - except MemoryError as e: + except MemoryError: # Say something meaningful to the user - msg = "The user process for this block ran out of memory. We " \ - "suggest you optimise your code to reduce memory usage or, " \ - "if this is not an option, choose an appropriate processing " \ - "queue with enough memory." - message_handler.send_error(msg, 'usr') + msg = ( + "The user process for this block ran out of memory. We " + "suggest you optimise your code to reduce memory usage or, " + "if this is not an option, choose an appropriate processing " + "queue with enough memory." + ) + message_handler.send_error(msg, "usr") message_handler.destroy() return 1 - except Exception as e: + except Exception: import traceback - message_handler.send_error(traceback.format_exc(), 'sys') + + message_handler.send_error(traceback.format_exc(), "sys") message_handler.destroy() return 1 @@ -247,6 +258,5 @@ def main(arguments=None): return 0 - -if __name__ == '__main__': +if __name__ == "__main__": sys.exit(main()) diff --git a/beat/backend/python/scripts/describe.py b/beat/backend/python/scripts/describe.py index 1b317e55420718149922bff5a947fcde002459e9..7bfc45635d61657f9c6d254b2a963694d8b26659 100644 --- a/beat/backend/python/scripts/describe.py +++ b/beat/backend/python/scripts/describe.py @@ -34,46 +34,47 @@ ################################################################################### -import sys +import collections import os import platform -import collections +import sys + import simplejson def main(): # resolve package name - name = 'environment' + name = "environment" if len(sys.argv) > 1: name = sys.argv[1] # resolve version - version = '1' + version = "1" if len(sys.argv) > 2: version = sys.argv[2] # use a configuration file if one exists databases = None capabilities = None - if os.path.exists('/etc/beat/environment.json'): - with open('/etc/beat/environment.json', 'r') as config_file: + if os.path.exists("/etc/beat/environment.json"): + with open("/etc/beat/environment.json", "r") as config_file: config = simplejson.load(config_file) - name = config.get('name', name) - version = config.get('version', version) - databases = config.get('databases', None) - capabilities = config.get('capabilities', None) + name = config.get("name", name) + version = config.get("version", version) + databases = config.get("databases", None) + capabilities = config.get("capabilities", None) # print the result retval = collections.OrderedDict() - retval['name'] = name - retval['version'] = version - retval['os'] = platform.uname() + retval["name"] = name + retval["version"] = version + retval["os"] = platform.uname() if databases is not None: - retval['databases'] = databases + retval["databases"] = databases if capabilities is not None: - retval['capabilities'] = capabilities + retval["capabilities"] = capabilities print(simplejson.dumps(retval, indent=2)) diff --git a/beat/backend/python/scripts/execute.py b/beat/backend/python/scripts/execute.py index ffc2947f4bda33909c05bb1ca0cd6c15cc860039..e12972d0e405fa8aaee96599b5654e126566622b 100644 --- a/beat/backend/python/scripts/execute.py +++ b/beat/backend/python/scripts/execute.py @@ -58,18 +58,16 @@ options: """ import logging - import os +import subprocess # nosec import sys + import docopt import simplejson -import subprocess # nosec - import zmq -from beat.backend.python.execution import AlgorithmExecutor from beat.backend.python.exceptions import UserError - +from beat.backend.python.execution import AlgorithmExecutor # ---------------------------------------------------------- diff --git a/beat/backend/python/scripts/index.py b/beat/backend/python/scripts/index.py index 3bf82a39be8acb410c83d63eb63ebd4a574ab2b5..d40c20251f4ebf0a2027c0fbdf9260f2cf8de315 100644 --- a/beat/backend/python/scripts/index.py +++ b/beat/backend/python/scripts/index.py @@ -59,18 +59,17 @@ options: """ import logging - import os +import pwd import sys + import docopt -import pwd from ..database import Database from ..hash import hashDataset from ..hash import toPath - -#---------------------------------------------------------- +# ---------------------------------------------------------- def main(arguments=None): @@ -79,105 +78,114 @@ def main(arguments=None): if arguments is None: arguments = sys.argv[1:] - package = __name__.rsplit('.', 2)[0] - version = package + ' v' + \ - __import__('pkg_resources').require(package)[0].version + package = __name__.rsplit(".", 2)[0] + version = package + " v" + __import__("pkg_resources").require(package)[0].version prog = os.path.basename(sys.argv[0]) args = docopt.docopt( - __doc__ % dict(prog=prog, version=version), - argv=arguments, - version=version + __doc__ % dict(prog=prog, version=version), argv=arguments, version=version ) - # Setup the logging system - formatter = logging.Formatter(fmt="[%(asctime)s - index.py - " \ - "%(name)s] %(levelname)s: %(message)s", - datefmt="%d/%b/%Y %H:%M:%S") + formatter = logging.Formatter( + fmt="[%(asctime)s - index.py - " "%(name)s] %(levelname)s: %(message)s", + datefmt="%d/%b/%Y %H:%M:%S", + ) handler = logging.StreamHandler() handler.setFormatter(formatter) - root_logger = logging.getLogger('beat.backend.python') + root_logger = logging.getLogger("beat.backend.python") root_logger.addHandler(handler) - if args['--debug']: + if args["--debug"]: root_logger.setLevel(logging.DEBUG) else: root_logger.setLevel(logging.INFO) logger = logging.getLogger(__name__) - - if args['--uid']: - uid = int(args['--uid']) + if args["--uid"]: + uid = int(args["--uid"]) # First create the user (if it doesn't exists) try: - user = pwd.getpwuid(uid) - except: - import subprocess - retcode = subprocess.call(['adduser', '--uid', str(uid), - '--no-create-home', '--disabled-password', - '--disabled-login', '--gecos', '""', '-q', - 'beat-nobody']) + _ = pwd.getpwuid(uid) + except Exception: + import subprocess # nosec + + retcode = subprocess.call( # nosec + [ + "adduser", + "--uid", + str(uid), + "--no-create-home", + "--disabled-password", + "--disabled-login", + "--gecos", + '""', + "-q", + "beat-nobody", + ] + ) if retcode != 0: - logger.error('Failed to create an user with the UID %d' % uid) + logger.error("Failed to create an user with the UID %d" % uid) return 1 # Change the current user try: os.setgid(uid) os.setuid(uid) - except: + except Exception: import traceback + logger.error(traceback.format_exc()) return 1 - # Check the paths - if not os.path.exists(args['<prefix>']): - logger.error('Invalid prefix path: %s' % args['<prefix>']) + if not os.path.exists(args["<prefix>"]): + logger.error("Invalid prefix path: %s" % args["<prefix>"]) return 1 - if not os.path.exists(args['<cache>']): - logger.error('Invalid cache path: %s' % args['<cache>']) + if not os.path.exists(args["<cache>"]): + logger.error("Invalid cache path: %s" % args["<cache>"]) return 1 - # Indexing try: - database = Database(args['<prefix>'], args['<database>']) + database = Database(args["<prefix>"], args["<database>"]) - if args['<protocol>'] is None: + if args["<protocol>"] is None: protocols = database.protocol_names else: - protocols = [ args['<protocol>'] ] + protocols = [args["<protocol>"]] for protocol in protocols: - if args['<set>'] is None: + if args["<set>"] is None: sets = database.set_names(protocol) else: - sets = [ args['<set>'] ] + sets = [args["<set>"]] for set_name in sets: - filename = toPath(hashDataset(args['<database>'], protocol, set_name), - suffix='.db') + filename = toPath( + hashDataset(args["<database>"], protocol, set_name), suffix=".db" + ) - view = database.view(protocol, set_name, root_folder=args['--db_root_folder']) - view.index(os.path.join(args['<cache>'], filename)) + view = database.view( + protocol, set_name, root_folder=args["--db_root_folder"] + ) + view.index(os.path.join(args["<cache>"], filename)) - except Exception as e: + except Exception: import traceback + logger.error(traceback.format_exc()) return 1 return 0 - -if __name__ == '__main__': +if __name__ == "__main__": sys.exit(main()) diff --git a/beat/backend/python/scripts/loop_execute.py b/beat/backend/python/scripts/loop_execute.py index 741989c4c37efc9273544bd8a1fcc66bbbcdfc76..24b142fdcf066bb2d4b8c39751415d881a3e4905 100644 --- a/beat/backend/python/scripts/loop_execute.py +++ b/beat/backend/python/scripts/loop_execute.py @@ -57,19 +57,17 @@ options: """ import logging - import os +import subprocess # nosec import sys + import docopt import simplejson as json -import subprocess # nosec - import zmq +from beat.backend.python.exceptions import UserError from beat.backend.python.execution import LoopExecutor from beat.backend.python.execution import LoopMessageHandler -from beat.backend.python.exceptions import UserError - # ---------------------------------------------------------- diff --git a/beat/backend/python/stats.py b/beat/backend/python/stats.py index c4372576f76a5fd2f6d52a2629fb04b8c72307ac..8f6495e87c0b8f91f32c9cbb9f47272e6ff49cf1 100644 --- a/beat/backend/python/stats.py +++ b/beat/backend/python/stats.py @@ -89,17 +89,14 @@ def io_statistics(configuration, input_list=None, output_list=None): write_time += duration blocks_written += output.nb_data_blocks_written - if 'result' in configuration: - hash = configuration['result']['path'].replace('/', '') + if "result" in configuration: + hash = configuration["result"]["path"].replace("/", "") else: - hash = configuration['outputs'][output.name]['path'].replace( - '/', '') + hash = configuration["outputs"][output.name]["path"].replace("/", "") - files.append(dict( - hash=hash, - size=size, - blocks=output.nb_data_blocks_written, - )) + files.append( + dict(hash=hash, size=size, blocks=output.nb_data_blocks_written,) + ) # Result return dict( @@ -128,13 +125,13 @@ def update(statistics, additional_statistics): """ for k in statistics.keys(): - if k == 'files': + if k == "files": continue for k2 in statistics[k].keys(): statistics[k][k2] += additional_statistics[k][k2] - if 'files' in statistics: - statistics['files'].extend(additional_statistics.get('files', [])) + if "files" in statistics: + statistics["files"].extend(additional_statistics.get("files", [])) else: - statistics['files'] = additional_statistics.get('files', []) + statistics["files"] = additional_statistics.get("files", []) diff --git a/beat/backend/python/test/__init__.py b/beat/backend/python/test/__init__.py index 335045c65c50b1e4f0953c0139c4de8285c89a6c..9b5a7da2dc82c7c3e1875918d424eec68611b4c4 100644 --- a/beat/backend/python/test/__init__.py +++ b/beat/backend/python/test/__init__.py @@ -34,4 +34,5 @@ ################################################################################### import pkg_resources -prefix = pkg_resources.resource_filename(__name__, 'prefix') + +prefix = pkg_resources.resource_filename(__name__, "prefix") diff --git a/beat/backend/python/test/mocks.py b/beat/backend/python/test/mocks.py index 038d2e4ee1d31bd115395d33bf4fc0ab094303bd..65f64c5581cb906522bc0f44f0d5aba1bae69fb8 100644 --- a/beat/backend/python/test/mocks.py +++ b/beat/backend/python/test/mocks.py @@ -38,42 +38,39 @@ import logging from collections import namedtuple -from ..data import DataSource from ..data import DataSink +from ..data import DataSource class MockDataSource(DataSource): - def __init__(self, data_and_indices): super(MockDataSource, self).__init__() - self.infos = [ (x[1], x[2]) for x in data_and_indices ] - self.data = [ x[0] for x in data_and_indices ] + self.infos = [(x[1], x[2]) for x in data_and_indices] + self.data = [x[0] for x in data_and_indices] def __getitem__(self, index): return (self.data[index], self.infos[index][0], self.infos[index][1]) -#---------------------------------------------------------- +# ---------------------------------------------------------- class CrashingDataSource(DataSource): - def __init__(self): super(CrashingDataSource, self).__init__() - Infos = namedtuple('Infos', ['start_index', 'end_index']) + Infos = namedtuple("Infos", ["start_index", "end_index"]) self.infos = [Infos(0, 0)] def __getitem__(self, index): - a = b + a = b # noqa return (None, None, None) -#---------------------------------------------------------- +# ---------------------------------------------------------- class MockDataSink(DataSink): - class WrittenData: def __init__(self, data, start, end): self.data = data @@ -86,7 +83,8 @@ class MockDataSink(DataSink): self.dataformat = dataformat def write(self, data, start_data_index, end_data_index): - if not(self.can_write): raise IOError + if not (self.can_write): + raise IOError self.written.append( MockDataSink.WrittenData(data, start_data_index, end_data_index) ) @@ -94,6 +92,7 @@ class MockDataSink(DataSink): def isConnected(self): return True + # Based on https://stackoverflow.com/a/20553331/5843716 class MockLoggingHandler(logging.Handler): """Mock logging handler to check for expected logs. @@ -104,9 +103,12 @@ class MockLoggingHandler(logging.Handler): def __init__(self, *args, **kwargs): self.messages = { - 'debug': [], 'info': [], - 'warning': [], 'error': [], - 'critical': [], 'extra': [] + "debug": [], + "info": [], + "warning": [], + "error": [], + "critical": [], + "extra": [], } super(MockLoggingHandler, self).__init__(*args, **kwargs) diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/add/1.json b/beat/backend/python/test/prefix/algorithms/autonomous/add/1.json index 0ec3448502ce407d6971b59a2073c1ecc7948228..61b4c2f221f2e5d10917d029592d96102867dfa9 100644 --- a/beat/backend/python/test/prefix/algorithms/autonomous/add/1.json +++ b/beat/backend/python/test/prefix/algorithms/autonomous/add/1.json @@ -27,4 +27,4 @@ } } ] -} \ No newline at end of file +} diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/add/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/add/1.py index d473d82e7ccfa5a8d8365a8e2134be7eb2b8f59c..fecf0c1aa09b00a8efb8f90afe7fdde44212ae53 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/add/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/add/1.py @@ -35,24 +35,18 @@ class Algorithm: - def setup(self, parameters): - self.sync = parameters['sync'] + self.sync = parameters["sync"] return True - def process(self, data_loaders, outputs): - data_loader = data_loaders.loaderOf('in1') + 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 - ) + outputs["out"].write({"value": data["in1"].value + data["in2"].value}, end) return True diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/add2/1.json b/beat/backend/python/test/prefix/algorithms/autonomous/add2/1.json index 966623ea711f2e7d413c5615939890f7bdc01ee5..ae67a982673f361cfd3f2644f2101d49486b9f0a 100644 --- a/beat/backend/python/test/prefix/algorithms/autonomous/add2/1.json +++ b/beat/backend/python/test/prefix/algorithms/autonomous/add2/1.json @@ -25,4 +25,4 @@ } } ] -} \ No newline at end of file +} diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/add2/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/add2/1.py index 2b204417f9179ebe24701120553a8daf5ef92395..7674616acbc29db49a878766a4671191eced8c95 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/add2/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/add2/1.py @@ -35,26 +35,20 @@ class Algorithm: - def prepare(self, data_loaders): - data_loader = data_loaders.loaderOf('in2') + data_loader = data_loaders.loaderOf("in2") (data, start, end) = data_loader[0] - self.offset = data['in2'].value + self.offset = data["in2"].value return True - def process(self, data_loaders, outputs): - data_loader = data_loaders.loaderOf('in1') + data_loader = data_loaders.loaderOf("in1") for i in range(data_loader.count()): (data, start, end) = data_loader[i] - outputs['out'].write({ - 'value': data['in1'].value + self.offset, - }, - end - ) + outputs["out"].write({"value": data["in1"].value + self.offset}, end) return True diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/add3/1.json b/beat/backend/python/test/prefix/algorithms/autonomous/add3/1.json index cefb5e014be1e718321ba5a7e13854e23fe131ca..ab5d326e6ba588cd0aed6e3a9a00b3ad55cbbeb5 100644 --- a/beat/backend/python/test/prefix/algorithms/autonomous/add3/1.json +++ b/beat/backend/python/test/prefix/algorithms/autonomous/add3/1.json @@ -28,4 +28,4 @@ } } ] -} \ No newline at end of file +} diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/add3/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/add3/1.py index 69686cf9665bf46ad0d1515b05010c91bf192fb9..65af3ecd0b65e61e63f7a700d999cc7c31ea4f41 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/add3/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/add3/1.py @@ -35,21 +35,18 @@ class Algorithm: - def process(self, data_loaders, outputs): - values = data_loaders.loaderOf('value') - offsets = data_loaders.loaderOf('offset') + values = data_loaders.loaderOf("value") + offsets = data_loaders.loaderOf("offset") for i in range(values.count()): (data, start, end) = values[i] - offset_index = data['offset_index'].value + offset_index = data["offset_index"].value (data2, start2, end2) = offsets[offset_index] - outputs['out'].write({ - 'value': data['value'].value + data2['offset'].value, - }, - end + outputs["out"].write( + {"value": data["value"].value + data2["offset"].value}, end ) return True diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/echo/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/echo/1.py index f5eb2bf20da2db2ac6ef56a854d19d706092da2c..62e1db7d22b4f69cf8d8d96cfe5d5fa80bdaa61f 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/echo/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/echo/1.py @@ -35,17 +35,12 @@ class Algorithm: - def process(self, data_loaders, outputs): - data_loader = data_loaders.loaderOf('in') + data_loader = data_loaders.loaderOf("in") for i in range(data_loader.count()): (data, start, end) = data_loader[i] - outputs['out'].write({ - 'value': data['in'].value, - }, - end - ) + outputs["out"].write({"value": data["in"].value}, end) return True diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/no_prepare/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/no_prepare/1.py index b8f66a850c5f48e596829377faf68417d2716268..d42545b009595bcfb17ef587e5d554578723af5f 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/no_prepare/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/no_prepare/1.py @@ -35,6 +35,5 @@ class Algorithm: - def process(self, data_loaders, outputs): return True diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/no_setup/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/no_setup/1.py index c20717d1a66824e469695c89f66c88f7a2c6b1fd..c5b1c86ed5b6dedef5dd25a6ce5165f80d8a974e 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/no_setup/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/no_setup/1.py @@ -35,7 +35,6 @@ class Algorithm: - def prepare(self, data_loaders): return True diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/parametrized/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/parametrized/1.py index 51d86deca79ddf80fbf90d3a7e796cbc98cffd9c..bc78541f614eed1f689841057c53a6ec3e0b33f1 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/parametrized/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/parametrized/1.py @@ -35,40 +35,39 @@ class Algorithm: - def setup(self, parameters): - self.int8_value = parameters['int8_value'] - self.int8_range = parameters['int8_range'] - self.int8_choices = parameters['int8_choices'] - self.int16_value = parameters['int16_value'] - self.int16_range = parameters['int16_range'] - self.int16_choices = parameters['int16_choices'] - self.int32_value = parameters['int32_value'] - self.int32_range = parameters['int32_range'] - self.int32_choices = parameters['int32_choices'] - self.int64_value = parameters['int64_value'] - self.int64_range = parameters['int64_range'] - self.int64_choices = parameters['int64_choices'] - self.uint8_value = parameters['uint8_value'] - self.uint8_range = parameters['uint8_range'] - self.uint8_choices = parameters['uint8_choices'] - self.uint16_value = parameters['uint16_value'] - self.uint16_range = parameters['uint16_range'] - self.uint16_choices = parameters['uint16_choices'] - self.uint32_value = parameters['uint32_value'] - self.uint32_range = parameters['uint32_range'] - self.uint32_choices = parameters['uint32_choices'] - self.uint64_value = parameters['uint64_value'] - self.uint64_range = parameters['uint64_range'] - self.uint64_choices = parameters['uint64_choices'] - self.float32_value = parameters['float32_value'] - self.float32_range = parameters['float32_range'] - self.float32_choices = parameters['float32_choices'] - self.float64_value = parameters['float64_value'] - self.float64_range = parameters['float64_range'] - self.float64_choices = parameters['float64_choices'] - self.bool_value = parameters['bool_value'] - self.string_value = parameters['string_value'] + self.int8_value = parameters["int8_value"] + self.int8_range = parameters["int8_range"] + self.int8_choices = parameters["int8_choices"] + self.int16_value = parameters["int16_value"] + self.int16_range = parameters["int16_range"] + self.int16_choices = parameters["int16_choices"] + self.int32_value = parameters["int32_value"] + self.int32_range = parameters["int32_range"] + self.int32_choices = parameters["int32_choices"] + self.int64_value = parameters["int64_value"] + self.int64_range = parameters["int64_range"] + self.int64_choices = parameters["int64_choices"] + self.uint8_value = parameters["uint8_value"] + self.uint8_range = parameters["uint8_range"] + self.uint8_choices = parameters["uint8_choices"] + self.uint16_value = parameters["uint16_value"] + self.uint16_range = parameters["uint16_range"] + self.uint16_choices = parameters["uint16_choices"] + self.uint32_value = parameters["uint32_value"] + self.uint32_range = parameters["uint32_range"] + self.uint32_choices = parameters["uint32_choices"] + self.uint64_value = parameters["uint64_value"] + self.uint64_range = parameters["uint64_range"] + self.uint64_choices = parameters["uint64_choices"] + self.float32_value = parameters["float32_value"] + self.float32_range = parameters["float32_range"] + self.float32_choices = parameters["float32_choices"] + self.float64_value = parameters["float64_value"] + self.float64_range = parameters["float64_range"] + self.float64_choices = parameters["float64_choices"] + self.bool_value = parameters["bool_value"] + self.string_value = parameters["string_value"] return True def process(self, data_loaders, outputs): diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/prepare_crash/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/prepare_crash/1.py index 6baa70fa8289dcd2ccc73ad78f61a6c388d0826d..7613c560ae83a8fa3ec046624234320ef2011385 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/prepare_crash/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/prepare_crash/1.py @@ -35,7 +35,6 @@ class Algorithm: - def prepare(self, data_loaders): a = b return True diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/prepare_fail/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/prepare_fail/1.py index b5a91c86f390a8fef9f5fb5b7d43df45485a5eaf..ec35cda6005c669913a751b825591ae40eeb5e63 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/prepare_fail/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/prepare_fail/1.py @@ -35,7 +35,6 @@ class Algorithm: - def prepare(self, data_loaders): return False diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/process_crash/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/process_crash/1.py index 1764aa3ac677ab87695ec4ae4275c5ab1c388a8b..363dd05431d6addfab34f344e26faae041cf0362 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/process_crash/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/process_crash/1.py @@ -35,7 +35,6 @@ class Algorithm: - def process(self, data_loaders, outputs): a = b return True diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/setup_crash/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/setup_crash/1.py index 1d9656b9e484a26c896b2f6718080dd7dc5c9397..bcfb17bdc1436d0b9a01f0cdb9db604db2d7be3a 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/setup_crash/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/setup_crash/1.py @@ -35,7 +35,6 @@ class Algorithm: - def setup(self, parameters): a = b return True diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/setup_fail/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/setup_fail/1.py index a3f7fb081bdadb463781d0da211bf681ae901a83..d6ee28a1358518d0892a90605ee7446c4180aead 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/setup_fail/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/setup_fail/1.py @@ -35,7 +35,6 @@ class Algorithm: - def setup(self, parameters): return False diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/valid_algorithm/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/valid_algorithm/1.py index a9c42ecf1139d018a646fca5b66edab62c68607e..a91aa2a4bee5fedd9e8956e30f09aa850718dc4d 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/valid_algorithm/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/valid_algorithm/1.py @@ -35,7 +35,6 @@ class Algorithm: - def setup(self, parameters): return True diff --git a/beat/backend/python/test/prefix/algorithms/autonomous/valid_analysis/1.py b/beat/backend/python/test/prefix/algorithms/autonomous/valid_analysis/1.py index 3316c1c932bbe353826c2f61b01570b1534a51df..6739f2dbe34ec67f9dca135af7db8a9cf1ef8ca5 100755 --- a/beat/backend/python/test/prefix/algorithms/autonomous/valid_analysis/1.py +++ b/beat/backend/python/test/prefix/algorithms/autonomous/valid_analysis/1.py @@ -35,7 +35,6 @@ class Algorithm: - def setup(self, parameters): return True diff --git a/beat/backend/python/test/prefix/algorithms/legacy/add/1.json b/beat/backend/python/test/prefix/algorithms/legacy/add/1.json index 51ba4f232957d6368a27abe23abe139e909a6abe..b1a0101df0af914c49e3696cff984de5c840ace2 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/add/1.json +++ b/beat/backend/python/test/prefix/algorithms/legacy/add/1.json @@ -24,4 +24,4 @@ } } ] -} \ No newline at end of file +} diff --git a/beat/backend/python/test/prefix/algorithms/legacy/add/1.py b/beat/backend/python/test/prefix/algorithms/legacy/add/1.py index 4672ee59494671668d80387a8e3cf5442d7cffa7..a1ef20a048a6459079939433e5fc1148d0e58cd0 100755 --- a/beat/backend/python/test/prefix/algorithms/legacy/add/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/add/1.py @@ -35,16 +35,14 @@ class Algorithm: - def setup(self, parameters): - self.sync = parameters['sync'] + self.sync = parameters["sync"] return True - def process(self, inputs, outputs): if inputs[self.sync].isDataUnitDone(): - outputs['out'].write({ - 'value': inputs['in1'].data.value + inputs['in2'].data.value, - }) + outputs["out"].write( + {"value": inputs["in1"].data.value + inputs["in2"].data.value} + ) return True diff --git a/beat/backend/python/test/prefix/algorithms/legacy/add2/1.json b/beat/backend/python/test/prefix/algorithms/legacy/add2/1.json index 20715dc20bbb0b65df1afd6ee5d432de32f7d45b..c55c48d0cf5d15e9e0608754109996c31b5e7e56 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/add2/1.json +++ b/beat/backend/python/test/prefix/algorithms/legacy/add2/1.json @@ -22,4 +22,4 @@ } } ] -} \ No newline at end of file +} diff --git a/beat/backend/python/test/prefix/algorithms/legacy/add2/1.py b/beat/backend/python/test/prefix/algorithms/legacy/add2/1.py index 27569adbfac984a5b7de40d7ff8114e8d113fe18..a3648e27ced2634a7d1b58d3f4077785b76dd2b1 100755 --- a/beat/backend/python/test/prefix/algorithms/legacy/add2/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/add2/1.py @@ -35,18 +35,15 @@ class Algorithm: - def __init__(self): self.offset = None def process(self, inputs, outputs): if self.offset is None: - group = inputs.groupOf('in2') + group = inputs.groupOf("in2") group.next() - self.offset = group['in2'].data.value + self.offset = group["in2"].data.value - outputs['out'].write({ - 'value': inputs['in1'].data.value + self.offset, - }) + outputs["out"].write({"value": inputs["in1"].data.value + self.offset}) return True diff --git a/beat/backend/python/test/prefix/algorithms/legacy/echo/1.py b/beat/backend/python/test/prefix/algorithms/legacy/echo/1.py index bb539b5d7fe336a2cc3dd2506d0117bd6e0d3f5a..617a535ef3c71c6bf48c0f986615303ef3e7952a 100755 --- a/beat/backend/python/test/prefix/algorithms/legacy/echo/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/echo/1.py @@ -35,7 +35,6 @@ class Algorithm: - def process(self, inputs, outputs): - outputs['out'].write(inputs['in'].data) + outputs["out"].write(inputs["in"].data) return True diff --git a/beat/backend/python/test/prefix/algorithms/legacy/no_class/1.py b/beat/backend/python/test/prefix/algorithms/legacy/no_class/1.py index 74316022bb9df16b5d7c219f39723f3fb8e24a28..a511954e13f46ac43fd9413aab29f865e980face 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/no_class/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/no_class/1.py @@ -35,6 +35,5 @@ class InvalidAlgorithmClassName: - def process(self, inputs, outputs): return True diff --git a/beat/backend/python/test/prefix/algorithms/legacy/no_setup/1.py b/beat/backend/python/test/prefix/algorithms/legacy/no_setup/1.py index 7cf2d9a6025fffa5195e38a41d2b91c9905ca454..164f5ad741e0db32021d2f210243cf9871ba449b 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/no_setup/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/no_setup/1.py @@ -35,6 +35,5 @@ class Algorithm: - def process(self, inputs, outputs): return True diff --git a/beat/backend/python/test/prefix/algorithms/legacy/parametrized/1.py b/beat/backend/python/test/prefix/algorithms/legacy/parametrized/1.py index 9cd88363672c5f2ca0c4327817fbb3eab693fea6..b80a6f0ab25e4c7467a0b7a8b7f936616b2dde50 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/parametrized/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/parametrized/1.py @@ -35,40 +35,39 @@ class Algorithm: - def setup(self, parameters): - self.int8_value = parameters['int8_value'] - self.int8_range = parameters['int8_range'] - self.int8_choices = parameters['int8_choices'] - self.int16_value = parameters['int16_value'] - self.int16_range = parameters['int16_range'] - self.int16_choices = parameters['int16_choices'] - self.int32_value = parameters['int32_value'] - self.int32_range = parameters['int32_range'] - self.int32_choices = parameters['int32_choices'] - self.int64_value = parameters['int64_value'] - self.int64_range = parameters['int64_range'] - self.int64_choices = parameters['int64_choices'] - self.uint8_value = parameters['uint8_value'] - self.uint8_range = parameters['uint8_range'] - self.uint8_choices = parameters['uint8_choices'] - self.uint16_value = parameters['uint16_value'] - self.uint16_range = parameters['uint16_range'] - self.uint16_choices = parameters['uint16_choices'] - self.uint32_value = parameters['uint32_value'] - self.uint32_range = parameters['uint32_range'] - self.uint32_choices = parameters['uint32_choices'] - self.uint64_value = parameters['uint64_value'] - self.uint64_range = parameters['uint64_range'] - self.uint64_choices = parameters['uint64_choices'] - self.float32_value = parameters['float32_value'] - self.float32_range = parameters['float32_range'] - self.float32_choices = parameters['float32_choices'] - self.float64_value = parameters['float64_value'] - self.float64_range = parameters['float64_range'] - self.float64_choices = parameters['float64_choices'] - self.bool_value = parameters['bool_value'] - self.string_value = parameters['string_value'] + self.int8_value = parameters["int8_value"] + self.int8_range = parameters["int8_range"] + self.int8_choices = parameters["int8_choices"] + self.int16_value = parameters["int16_value"] + self.int16_range = parameters["int16_range"] + self.int16_choices = parameters["int16_choices"] + self.int32_value = parameters["int32_value"] + self.int32_range = parameters["int32_range"] + self.int32_choices = parameters["int32_choices"] + self.int64_value = parameters["int64_value"] + self.int64_range = parameters["int64_range"] + self.int64_choices = parameters["int64_choices"] + self.uint8_value = parameters["uint8_value"] + self.uint8_range = parameters["uint8_range"] + self.uint8_choices = parameters["uint8_choices"] + self.uint16_value = parameters["uint16_value"] + self.uint16_range = parameters["uint16_range"] + self.uint16_choices = parameters["uint16_choices"] + self.uint32_value = parameters["uint32_value"] + self.uint32_range = parameters["uint32_range"] + self.uint32_choices = parameters["uint32_choices"] + self.uint64_value = parameters["uint64_value"] + self.uint64_range = parameters["uint64_range"] + self.uint64_choices = parameters["uint64_choices"] + self.float32_value = parameters["float32_value"] + self.float32_range = parameters["float32_range"] + self.float32_choices = parameters["float32_choices"] + self.float64_value = parameters["float64_value"] + self.float64_range = parameters["float64_range"] + self.float64_choices = parameters["float64_choices"] + self.bool_value = parameters["bool_value"] + self.string_value = parameters["string_value"] return True def process(self, inputs, outputs): diff --git a/beat/backend/python/test/prefix/algorithms/legacy/prepare/1.json b/beat/backend/python/test/prefix/algorithms/legacy/prepare/1.json index 51ba4f232957d6368a27abe23abe139e909a6abe..b1a0101df0af914c49e3696cff984de5c840ace2 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/prepare/1.json +++ b/beat/backend/python/test/prefix/algorithms/legacy/prepare/1.json @@ -24,4 +24,4 @@ } } ] -} \ No newline at end of file +} diff --git a/beat/backend/python/test/prefix/algorithms/legacy/prepare/1.py b/beat/backend/python/test/prefix/algorithms/legacy/prepare/1.py index b85d1497c014d00487a290710a363d3fce882099..d7e842a594c83890a9f816adaa3b520723b39ae1 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/prepare/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/prepare/1.py @@ -35,18 +35,17 @@ class Algorithm: - def setup(self, parameters): - self.sync = parameters['sync'] + self.sync = parameters["sync"] return True def prepare(self): - return True + return True def process(self, inputs, outputs): if inputs[self.sync].isDataUnitDone(): - outputs['out'].write({ - 'value': inputs['in1'].data.value + inputs['in2'].data.value, - }) + outputs["out"].write( + {"value": inputs["in1"].data.value + inputs["in2"].data.value} + ) return True diff --git a/beat/backend/python/test/prefix/algorithms/legacy/process_crash/1.py b/beat/backend/python/test/prefix/algorithms/legacy/process_crash/1.py index 4d539211a248422983bfc90bde72ae696f4558b7..bec1160e777e8b957341e054c47d473a71b89875 100755 --- a/beat/backend/python/test/prefix/algorithms/legacy/process_crash/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/process_crash/1.py @@ -35,7 +35,6 @@ class Algorithm: - def process(self, inputs, outputs): a = b return True diff --git a/beat/backend/python/test/prefix/algorithms/legacy/setup_crash/1.py b/beat/backend/python/test/prefix/algorithms/legacy/setup_crash/1.py index 5e9344e1690f6fb3bc200d137b629ada7c17d545..7a2c23054471b0c29446b5eb2f299fe7cbcfc507 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/setup_crash/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/setup_crash/1.py @@ -35,7 +35,6 @@ class Algorithm: - def setup(self, parameters): a = b return True diff --git a/beat/backend/python/test/prefix/algorithms/legacy/setup_fail/1.py b/beat/backend/python/test/prefix/algorithms/legacy/setup_fail/1.py index f4cf20867a5c64f1a7a868290f2edf32528dc1d6..0c7621126ca743ed45896cbf9cb9c27a58a236d9 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/setup_fail/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/setup_fail/1.py @@ -35,7 +35,6 @@ class Algorithm: - def setup(self, parameters): return False diff --git a/beat/backend/python/test/prefix/algorithms/legacy/valid_algorithm/1.py b/beat/backend/python/test/prefix/algorithms/legacy/valid_algorithm/1.py index 7cf2d9a6025fffa5195e38a41d2b91c9905ca454..164f5ad741e0db32021d2f210243cf9871ba449b 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/valid_algorithm/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/valid_algorithm/1.py @@ -35,6 +35,5 @@ class Algorithm: - def process(self, inputs, outputs): return True diff --git a/beat/backend/python/test/prefix/algorithms/legacy/valid_analysis/1.py b/beat/backend/python/test/prefix/algorithms/legacy/valid_analysis/1.py index bdfc072a1d4e92e2d4d3eca332a53467a7cf903c..cca68694a3f204656a86d92275c4c76e56d50584 100644 --- a/beat/backend/python/test/prefix/algorithms/legacy/valid_analysis/1.py +++ b/beat/backend/python/test/prefix/algorithms/legacy/valid_analysis/1.py @@ -35,6 +35,5 @@ class Algorithm: - def process(self, inputs, output): return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/add/1.json b/beat/backend/python/test/prefix/algorithms/sequential/add/1.json index 9f4576d52619443a800ec1f98fd51675bc57ecec..8a6217cf6825553b8216d8f2b0d6adb6e6782174 100644 --- a/beat/backend/python/test/prefix/algorithms/sequential/add/1.json +++ b/beat/backend/python/test/prefix/algorithms/sequential/add/1.json @@ -27,4 +27,4 @@ } } ] -} \ No newline at end of file +} diff --git a/beat/backend/python/test/prefix/algorithms/sequential/add/1.py b/beat/backend/python/test/prefix/algorithms/sequential/add/1.py index a264b3f7e85f450fa552abb792512b009b9d947c..705c0c3e627c2467bcc7bd351bfe0987053b81c8 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/add/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/add/1.py @@ -35,16 +35,14 @@ class Algorithm: - def setup(self, parameters): - self.sync = parameters['sync'] + self.sync = parameters["sync"] return True - def process(self, inputs, data_loaders, outputs): if inputs[self.sync].isDataUnitDone(): - outputs['out'].write({ - 'value': inputs['in1'].data.value + inputs['in2'].data.value, - }) + outputs["out"].write( + {"value": inputs["in1"].data.value + inputs["in2"].data.value} + ) return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/add2/1.json b/beat/backend/python/test/prefix/algorithms/sequential/add2/1.json index 69d95bfd64e36dd83fd6d5968319412792aa4fe2..34eaad0afbd6ff649d39848a0c3eae0451da4a03 100644 --- a/beat/backend/python/test/prefix/algorithms/sequential/add2/1.json +++ b/beat/backend/python/test/prefix/algorithms/sequential/add2/1.json @@ -25,4 +25,4 @@ } } ] -} \ No newline at end of file +} diff --git a/beat/backend/python/test/prefix/algorithms/sequential/add2/1.py b/beat/backend/python/test/prefix/algorithms/sequential/add2/1.py index ab96080808bf3adb85437de0e24f41ff40551fd8..5e92ca03db1e2266f5171c7216d38660709c2f27 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/add2/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/add2/1.py @@ -35,19 +35,15 @@ class Algorithm: - def prepare(self, data_loaders): - data_loader = data_loaders.loaderOf('in2') + data_loader = data_loaders.loaderOf("in2") (data, start, end) = data_loader[0] - self.offset = data['in2'].value + self.offset = data["in2"].value return True - def process(self, inputs, data_loaders, outputs): - outputs['out'].write({ - 'value': inputs['in1'].data.value + self.offset, - }) + outputs["out"].write({"value": inputs["in1"].data.value + self.offset}) return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/add3/1.json b/beat/backend/python/test/prefix/algorithms/sequential/add3/1.json index a46209696a54d08fe30dea6e2efe76e292a2c2d5..db8588f73c9fe950bde2c6503f63b2fe9198299d 100644 --- a/beat/backend/python/test/prefix/algorithms/sequential/add3/1.json +++ b/beat/backend/python/test/prefix/algorithms/sequential/add3/1.json @@ -28,4 +28,4 @@ } } ] -} \ No newline at end of file +} diff --git a/beat/backend/python/test/prefix/algorithms/sequential/add3/1.py b/beat/backend/python/test/prefix/algorithms/sequential/add3/1.py index 87e8636132c4384fd823b72dc5f25d659505c6ca..b9bcd0b5aec8b4aff4e59803cc81c0094ec49d2c 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/add3/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/add3/1.py @@ -35,15 +35,14 @@ class Algorithm: - def process(self, inputs, data_loaders, outputs): - offset_index = inputs['offset_index'].data.value + offset_index = inputs["offset_index"].data.value - data_loader = data_loaders.loaderOf('offset') + data_loader = data_loaders.loaderOf("offset") (data, start, end) = data_loader[offset_index] - outputs['out'].write({ - 'value': inputs['value'].data.value + data['offset'].value, - }) + outputs["out"].write( + {"value": inputs["value"].data.value + data["offset"].value} + ) return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/echo/1.py b/beat/backend/python/test/prefix/algorithms/sequential/echo/1.py index e7d9d7dafd5874a6e9ceca17cee819ef9383ebc9..987dea5cee5724a391f51ea2dc8570d5c3774366 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/echo/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/echo/1.py @@ -35,7 +35,6 @@ class Algorithm: - def process(self, inputs, data_loaders, outputs): - outputs['out'].write(inputs['in'].data) + outputs["out"].write(inputs["in"].data) return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/no_prepare/1.py b/beat/backend/python/test/prefix/algorithms/sequential/no_prepare/1.py index 88c5e50f7ec24372988986b58e8f5177be1e9aa1..c042564edbc1e65f624b8d192f4a3927f8cd9c0e 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/no_prepare/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/no_prepare/1.py @@ -35,6 +35,5 @@ class Algorithm: - def process(self, inputs, data_loaders, outputs): return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/no_setup/1.py b/beat/backend/python/test/prefix/algorithms/sequential/no_setup/1.py index c20717d1a66824e469695c89f66c88f7a2c6b1fd..c5b1c86ed5b6dedef5dd25a6ce5165f80d8a974e 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/no_setup/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/no_setup/1.py @@ -35,7 +35,6 @@ class Algorithm: - def prepare(self, data_loaders): return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/parametrized/1.py b/beat/backend/python/test/prefix/algorithms/sequential/parametrized/1.py index 7f566c53f84fc78550b4f465f3ad725727855575..dac535dbd756a9713376d3b22285454dc526e042 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/parametrized/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/parametrized/1.py @@ -35,40 +35,39 @@ class Algorithm: - def setup(self, parameters): - self.int8_value = parameters['int8_value'] - self.int8_range = parameters['int8_range'] - self.int8_choices = parameters['int8_choices'] - self.int16_value = parameters['int16_value'] - self.int16_range = parameters['int16_range'] - self.int16_choices = parameters['int16_choices'] - self.int32_value = parameters['int32_value'] - self.int32_range = parameters['int32_range'] - self.int32_choices = parameters['int32_choices'] - self.int64_value = parameters['int64_value'] - self.int64_range = parameters['int64_range'] - self.int64_choices = parameters['int64_choices'] - self.uint8_value = parameters['uint8_value'] - self.uint8_range = parameters['uint8_range'] - self.uint8_choices = parameters['uint8_choices'] - self.uint16_value = parameters['uint16_value'] - self.uint16_range = parameters['uint16_range'] - self.uint16_choices = parameters['uint16_choices'] - self.uint32_value = parameters['uint32_value'] - self.uint32_range = parameters['uint32_range'] - self.uint32_choices = parameters['uint32_choices'] - self.uint64_value = parameters['uint64_value'] - self.uint64_range = parameters['uint64_range'] - self.uint64_choices = parameters['uint64_choices'] - self.float32_value = parameters['float32_value'] - self.float32_range = parameters['float32_range'] - self.float32_choices = parameters['float32_choices'] - self.float64_value = parameters['float64_value'] - self.float64_range = parameters['float64_range'] - self.float64_choices = parameters['float64_choices'] - self.bool_value = parameters['bool_value'] - self.string_value = parameters['string_value'] + self.int8_value = parameters["int8_value"] + self.int8_range = parameters["int8_range"] + self.int8_choices = parameters["int8_choices"] + self.int16_value = parameters["int16_value"] + self.int16_range = parameters["int16_range"] + self.int16_choices = parameters["int16_choices"] + self.int32_value = parameters["int32_value"] + self.int32_range = parameters["int32_range"] + self.int32_choices = parameters["int32_choices"] + self.int64_value = parameters["int64_value"] + self.int64_range = parameters["int64_range"] + self.int64_choices = parameters["int64_choices"] + self.uint8_value = parameters["uint8_value"] + self.uint8_range = parameters["uint8_range"] + self.uint8_choices = parameters["uint8_choices"] + self.uint16_value = parameters["uint16_value"] + self.uint16_range = parameters["uint16_range"] + self.uint16_choices = parameters["uint16_choices"] + self.uint32_value = parameters["uint32_value"] + self.uint32_range = parameters["uint32_range"] + self.uint32_choices = parameters["uint32_choices"] + self.uint64_value = parameters["uint64_value"] + self.uint64_range = parameters["uint64_range"] + self.uint64_choices = parameters["uint64_choices"] + self.float32_value = parameters["float32_value"] + self.float32_range = parameters["float32_range"] + self.float32_choices = parameters["float32_choices"] + self.float64_value = parameters["float64_value"] + self.float64_range = parameters["float64_range"] + self.float64_choices = parameters["float64_choices"] + self.bool_value = parameters["bool_value"] + self.string_value = parameters["string_value"] return True def process(self, inputs, data_loaders, outputs): diff --git a/beat/backend/python/test/prefix/algorithms/sequential/prepare_crash/1.py b/beat/backend/python/test/prefix/algorithms/sequential/prepare_crash/1.py index 7aee81e2402c9ea6a2051bb1c1b8a4f69b45e445..94555de404295c6db638f89e332e841735c84279 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/prepare_crash/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/prepare_crash/1.py @@ -35,7 +35,6 @@ class Algorithm: - def prepare(self, data_loaders): a = b return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/prepare_fail/1.py b/beat/backend/python/test/prefix/algorithms/sequential/prepare_fail/1.py index aa554a6aac4fa6271e34ecf036fa9e1b3bd37d6a..d108c0bef168a2a3e4977fcb86844e62a243e715 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/prepare_fail/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/prepare_fail/1.py @@ -35,7 +35,6 @@ class Algorithm: - def prepare(self, data_loaders): return False diff --git a/beat/backend/python/test/prefix/algorithms/sequential/process_crash/1.py b/beat/backend/python/test/prefix/algorithms/sequential/process_crash/1.py index 2897e76cc03bada124e65543889fb30eb85c58e0..5c66a9f8d2a671bd525d59797ac2321ca322615b 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/process_crash/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/process_crash/1.py @@ -35,7 +35,6 @@ class Algorithm: - def process(self, inputs, data_loaders, outputs): a = b return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/setup_crash/1.py b/beat/backend/python/test/prefix/algorithms/sequential/setup_crash/1.py index 964b6df608acce0aa6da24bab5adac621c6259b5..1c004f3ea133ed8f43e234d99c7eedf188e041a3 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/setup_crash/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/setup_crash/1.py @@ -35,7 +35,6 @@ class Algorithm: - def setup(self, parameters): a = b return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/setup_fail/1.py b/beat/backend/python/test/prefix/algorithms/sequential/setup_fail/1.py index acb524702e0da977932937b3031905f91417ecbe..921890b3b4c1d78179da6ca91662589b76cc8f90 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/setup_fail/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/setup_fail/1.py @@ -35,7 +35,6 @@ class Algorithm: - def setup(self, parameters): return False diff --git a/beat/backend/python/test/prefix/algorithms/sequential/valid_algorithm/1.py b/beat/backend/python/test/prefix/algorithms/sequential/valid_algorithm/1.py index 982c1e2bb853f551b4e6d650be55065acbacc5bf..3b19beb98b11bb7d8234bf072ccbe5ab974a0327 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/valid_algorithm/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/valid_algorithm/1.py @@ -35,7 +35,6 @@ class Algorithm: - def setup(self, parameters): return True diff --git a/beat/backend/python/test/prefix/algorithms/sequential/valid_analysis/1.py b/beat/backend/python/test/prefix/algorithms/sequential/valid_analysis/1.py index 9b55464de176ee04c12e9316130f6c1c9de469b7..8caf7a45b06bfd8c37179f5bcf4799e65032603f 100755 --- a/beat/backend/python/test/prefix/algorithms/sequential/valid_analysis/1.py +++ b/beat/backend/python/test/prefix/algorithms/sequential/valid_analysis/1.py @@ -35,7 +35,6 @@ class Algorithm: - def setup(self, parameters): return True diff --git a/beat/backend/python/test/prefix/databases/crash/1.py b/beat/backend/python/test/prefix/databases/crash/1.py index 956d118d6a10fda8feae928975715d8cb543a102..abf25bbdba51793df441731ffaee3e50aab5ed52 100755 --- a/beat/backend/python/test/prefix/databases/crash/1.py +++ b/beat/backend/python/test/prefix/databases/crash/1.py @@ -34,12 +34,12 @@ ################################################################################### -from beat.backend.python.database import View from collections import namedtuple +from beat.backend.python.database import View -class IndexCrashes(View): +class IndexCrashes(View): def index(self, *args, **kwargs): a = b return [] @@ -48,14 +48,13 @@ class IndexCrashes(View): return 0 -#---------------------------------------------------------- +# ---------------------------------------------------------- class GetCrashes(View): - def index(self, *args, **kwargs): - Entry = namedtuple('Entry', ['out']) - return [ Entry(1) ] + Entry = namedtuple("Entry", ["out"]) + return [Entry(1)] def get(self, *args, **kwargs): a = b diff --git a/beat/backend/python/test/prefix/databases/duplicate_key_error/1.py b/beat/backend/python/test/prefix/databases/duplicate_key_error/1.py index e7037b89f938a8ad9aa3fdf04ac047716528a287..1ffca6f03a97be87fb4cb0a76e023230a2551bee 100644 --- a/beat/backend/python/test/prefix/databases/duplicate_key_error/1.py +++ b/beat/backend/python/test/prefix/databases/duplicate_key_error/1.py @@ -34,9 +34,10 @@ ################################################################################### +from collections import namedtuple + import numpy -from collections import namedtuple from beat.backend.python.database import View as BaseView diff --git a/beat/backend/python/test/prefix/databases/integers_db/1.py b/beat/backend/python/test/prefix/databases/integers_db/1.py index f9fd5c46887d08edc45b0444b0f2438722cfe055..859044fbd84cd1aaacc97831766797d347cca0e3 100755 --- a/beat/backend/python/test/prefix/databases/integers_db/1.py +++ b/beat/backend/python/test/prefix/databases/integers_db/1.py @@ -34,16 +34,16 @@ ################################################################################### -import random -import numpy from collections import namedtuple + +import numpy + from beat.backend.python.database import View class Double(View): - def index(self, root_folder, parameters): - Entry = namedtuple('Entry', ['a', 'b', 'sum']) + Entry = namedtuple("Entry", ["a", "b", "sum"]) return [ Entry(1, 10, 11), @@ -57,37 +57,27 @@ class Double(View): Entry(9, 90, 99), ] - def get(self, output, index): obj = self.objs[index] - if output == 'a': - return { - 'value': numpy.int32(obj.a) - } + if output == "a": + return {"value": numpy.int32(obj.a)} - elif output == 'b': - return { - 'value': numpy.int32(obj.b) - } + elif output == "b": + return {"value": numpy.int32(obj.b)} - elif output == 'sum': - return { - 'value': numpy.int32(obj.sum) - } - elif output == 'class': - return { - 'value': numpy.int32(obj.cls) - } + elif output == "sum": + return {"value": numpy.int32(obj.sum)} + elif output == "class": + return {"value": numpy.int32(obj.cls)} -#---------------------------------------------------------- +# ---------------------------------------------------------- class Triple(View): - def index(self, root_folder, parameters): - Entry = namedtuple('Entry', ['a', 'b', 'c', 'sum']) + Entry = namedtuple("Entry", ["a", "b", "c", "sum"]) return [ Entry(1, 10, 100, 111), @@ -101,79 +91,63 @@ class Triple(View): Entry(9, 90, 900, 999), ] - def get(self, output, index): obj = self.objs[index] - if output == 'a': - return { - 'value': numpy.int32(obj.a) - } + if output == "a": + return {"value": numpy.int32(obj.a)} - elif output == 'b': - return { - 'value': numpy.int32(obj.b) - } + elif output == "b": + return {"value": numpy.int32(obj.b)} - elif output == 'c': - return { - 'value': numpy.int32(obj.c) - } + elif output == "c": + return {"value": numpy.int32(obj.c)} - elif output == 'sum': - return { - 'value': numpy.int32(obj.sum) - } + elif output == "sum": + return {"value": numpy.int32(obj.sum)} -#---------------------------------------------------------- +# ---------------------------------------------------------- class Labelled(View): - def index(self, root_folder, parameters): - Entry = namedtuple('Entry', ['label', 'value']) + Entry = namedtuple("Entry", ["label", "value"]) return [ - Entry('A', 1), - Entry('A', 2), - Entry('A', 3), - Entry('A', 4), - Entry('A', 5), - Entry('B', 10), - Entry('B', 20), - Entry('B', 30), - Entry('B', 40), - Entry('B', 50), - Entry('C', 100), - Entry('C', 200), - Entry('C', 300), - Entry('C', 400), - Entry('C', 500), + Entry("A", 1), + Entry("A", 2), + Entry("A", 3), + Entry("A", 4), + Entry("A", 5), + Entry("B", 10), + Entry("B", 20), + Entry("B", 30), + Entry("B", 40), + Entry("B", 50), + Entry("C", 100), + Entry("C", 200), + Entry("C", 300), + Entry("C", 400), + Entry("C", 500), ] - def get(self, output, index): obj = self.objs[index] - if output == 'label': - return { - 'value': obj.label - } + if output == "label": + return {"value": obj.label} - elif output == 'value': - return { - 'value': numpy.int32(obj.value) - } + elif output == "value": + return {"value": numpy.int32(obj.value)} -#---------------------------------------------------------- +# ---------------------------------------------------------- class DifferentFrequencies(View): - def index(self, root_folder, parameters): - Entry = namedtuple('Entry', ['a', 'b']) + Entry = namedtuple("Entry", ["a", "b"]) return [ Entry(1, 10), @@ -186,16 +160,11 @@ class DifferentFrequencies(View): Entry(2, 80), ] - def get(self, output, index): obj = self.objs[index] - if output == 'a': - return { - 'value': numpy.int32(obj.a) - } + if output == "a": + return {"value": numpy.int32(obj.a)} - elif output == 'b': - return { - 'value': numpy.int32(obj.b) - } + elif output == "b": + return {"value": numpy.int32(obj.b)} diff --git a/beat/backend/python/test/prefix/databases/integers_db/2.py b/beat/backend/python/test/prefix/databases/integers_db/2.py index 0ebebd6c4debec559f8a853830073e92a8b71bd5..859044fbd84cd1aaacc97831766797d347cca0e3 100644 --- a/beat/backend/python/test/prefix/databases/integers_db/2.py +++ b/beat/backend/python/test/prefix/databases/integers_db/2.py @@ -34,8 +34,10 @@ ################################################################################### -import numpy from collections import namedtuple + +import numpy + from beat.backend.python.database import View diff --git a/beat/backend/python/test/prefix/databases/integers_db_env/1.py b/beat/backend/python/test/prefix/databases/integers_db_env/1.py index 0ebebd6c4debec559f8a853830073e92a8b71bd5..859044fbd84cd1aaacc97831766797d347cca0e3 100755 --- a/beat/backend/python/test/prefix/databases/integers_db_env/1.py +++ b/beat/backend/python/test/prefix/databases/integers_db_env/1.py @@ -34,8 +34,10 @@ ################################################################################### -import numpy from collections import namedtuple + +import numpy + from beat.backend.python.database import View diff --git a/beat/backend/python/test/prefix/databases/integers_db_env/2.py b/beat/backend/python/test/prefix/databases/integers_db_env/2.py index 0ebebd6c4debec559f8a853830073e92a8b71bd5..859044fbd84cd1aaacc97831766797d347cca0e3 100644 --- a/beat/backend/python/test/prefix/databases/integers_db_env/2.py +++ b/beat/backend/python/test/prefix/databases/integers_db_env/2.py @@ -34,8 +34,10 @@ ################################################################################### -import numpy from collections import namedtuple + +import numpy + from beat.backend.python.database import View diff --git a/beat/backend/python/test/prefix/databases/python_keyword/1.py b/beat/backend/python/test/prefix/databases/python_keyword/1.py index 34b7e83b0886273ccb45216eace1d7269c04ac0d..8011b6d5d031a1f33381fe6774e9bbb883426d08 100755 --- a/beat/backend/python/test/prefix/databases/python_keyword/1.py +++ b/beat/backend/python/test/prefix/databases/python_keyword/1.py @@ -34,22 +34,20 @@ ################################################################################### -import random -import numpy from collections import namedtuple + +import numpy + from beat.backend.python.database import View class Keyword(View): def __init__(self): super(Keyword, self) - self.output_member_map = { - 'class': 'cls', - 'def': 'definition' - } + self.output_member_map = {"class": "cls", "def": "definition"} def index(self, root_folder, parameters): - Entry = namedtuple('Entry', ['cls', 'definition', 'sum']) + Entry = namedtuple("Entry", ["cls", "definition", "sum"]) return [ Entry(1, 10, 11), @@ -63,21 +61,12 @@ class Keyword(View): Entry(9, 90, 99), ] - def get(self, output, index): obj = self.objs[index] - if output == 'class': - return { - 'value': numpy.int32(obj.cls) - } - elif output == 'def': - return { - 'value': numpy.int32(obj.definition) - } - elif output == 'sum': - return { - 'value': numpy.int32(obj.sum) - } - - + if output == "class": + return {"value": numpy.int32(obj.cls)} + elif output == "def": + return {"value": numpy.int32(obj.definition)} + elif output == "sum": + return {"value": numpy.int32(obj.sum)} diff --git a/beat/backend/python/test/prefix/databases/with_parameters/1.py b/beat/backend/python/test/prefix/databases/with_parameters/1.py index 8e75c18a14752b8171c5f1266f35d5b91dd30579..4df9c1ea5a551de3c7d8e46920498b67ad893897 100644 --- a/beat/backend/python/test/prefix/databases/with_parameters/1.py +++ b/beat/backend/python/test/prefix/databases/with_parameters/1.py @@ -34,9 +34,10 @@ ################################################################################### +from collections import namedtuple + import numpy -from collections import namedtuple from beat.backend.python.database import View as BaseView diff --git a/beat/backend/python/test/prefix/databases/with_parameters/2.py b/beat/backend/python/test/prefix/databases/with_parameters/2.py index 8e75c18a14752b8171c5f1266f35d5b91dd30579..4df9c1ea5a551de3c7d8e46920498b67ad893897 100644 --- a/beat/backend/python/test/prefix/databases/with_parameters/2.py +++ b/beat/backend/python/test/prefix/databases/with_parameters/2.py @@ -34,9 +34,10 @@ ################################################################################### +from collections import namedtuple + import numpy -from collections import namedtuple from beat.backend.python.database import View as BaseView diff --git a/beat/backend/python/test/prefix/dataformats/user/3d_array_of_complexes/1.json b/beat/backend/python/test/prefix/dataformats/user/3d_array_of_complexes/1.json index 5c27e0579e302c2acb0815be4fe5e1c4ebd03dd1..2587023b5acf9d20c35958c0fcae726c076d8c6f 100644 --- a/beat/backend/python/test/prefix/dataformats/user/3d_array_of_complexes/1.json +++ b/beat/backend/python/test/prefix/dataformats/user/3d_array_of_complexes/1.json @@ -1,4 +1,3 @@ { "value": [5, 30, 10, "complex128"] } - diff --git a/beat/backend/python/test/prefix/dataformats/user/3d_array_of_floats/1.json b/beat/backend/python/test/prefix/dataformats/user/3d_array_of_floats/1.json index 37b52c4d9bd64f305b69389d6511ba2fa00fdadc..8f3108677e4862fa24f4a48e460ab25a43377bb7 100644 --- a/beat/backend/python/test/prefix/dataformats/user/3d_array_of_floats/1.json +++ b/beat/backend/python/test/prefix/dataformats/user/3d_array_of_floats/1.json @@ -1,4 +1,3 @@ { "value": [0, 0, 0, "float64"] } - diff --git a/beat/backend/python/test/prefix/dataformats/user/single_bytes/1.json b/beat/backend/python/test/prefix/dataformats/user/single_bytes/1.json new file mode 100644 index 0000000000000000000000000000000000000000..a3ad982f95bc7a47d097d8a453c63453f4c92382 --- /dev/null +++ b/beat/backend/python/test/prefix/dataformats/user/single_bytes/1.json @@ -0,0 +1,3 @@ +{ + "value": "bytes" +} diff --git a/beat/backend/python/test/prefix/dataformats/user/single_bytes/1.rst b/beat/backend/python/test/prefix/dataformats/user/single_bytes/1.rst new file mode 100644 index 0000000000000000000000000000000000000000..e62c1c42520de03eed49b89f3ed95fce122745de --- /dev/null +++ b/beat/backend/python/test/prefix/dataformats/user/single_bytes/1.rst @@ -0,0 +1 @@ +Test documentation diff --git a/beat/backend/python/test/test_algorithm.py b/beat/backend/python/test/test_algorithm.py index 8b90e6fe19dfad498c875f87a4789accb29227df..6a9e694c69c6bd28b7cf3515d46861a7627d0502 100644 --- a/beat/backend/python/test/test_algorithm.py +++ b/beat/backend/python/test/test_algorithm.py @@ -34,34 +34,31 @@ ################################################################################### -import unittest -import six -import os import glob -import tempfile import logging +import os +import tempfile +import unittest import numpy as np +import six from ..algorithm import Algorithm -from ..data_loaders import DataLoaderList -from ..data_loaders import DataLoader -from ..dataformat import DataFormat from ..data import CachedDataSink from ..data import CachedDataSource +from ..data_loaders import DataLoader +from ..data_loaders import DataLoaderList +from ..dataformat import DataFormat from ..inputs import Input from ..inputs import InputGroup from ..inputs import InputList from ..outputs import Output from ..outputs import OutputList from ..outputs import SynchronizationListener - +from . import prefix from .mocks import MockDataSink from .mocks import MockLoggingHandler -from . import prefix - - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_data.py b/beat/backend/python/test/test_data.py index 4bd14bf49e0900c92e17afdeba1e52fed026a237..bedfaa5ec4a7eecf7b0484ad0d8ab8d5313db47a 100644 --- a/beat/backend/python/test/test_data.py +++ b/beat/backend/python/test/test_data.py @@ -34,24 +34,22 @@ ################################################################################### -import unittest -import os import glob +import os import pickle # nosec -import tempfile import shutil +import tempfile +import unittest -from ..data import mixDataIndices -from ..data import CachedDataSource from ..data import CachedDataSink -from ..data import getAllFilenames +from ..data import CachedDataSource from ..data import foundSplitRanges -from ..dataformat import DataFormat +from ..data import getAllFilenames +from ..data import mixDataIndices from ..database import Database - +from ..dataformat import DataFormat from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_data_loaders.py b/beat/backend/python/test/test_data_loaders.py index 5c7ad1ec81aad5ddb3b188e6401adc6be8a8ed33..a5d7795fefe238a573ff01156688caba5480f273 100644 --- a/beat/backend/python/test/test_data_loaders.py +++ b/beat/backend/python/test/test_data_loaders.py @@ -34,21 +34,20 @@ ################################################################################### -import unittest -import os import glob +import os import tempfile +import unittest + import numpy as np +from ..data import CachedDataSink +from ..data import CachedDataSource from ..data_loaders import DataLoader from ..data_loaders import DataLoaderList from ..dataformat import DataFormat -from ..data import CachedDataSink -from ..data import CachedDataSource - from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_database.py b/beat/backend/python/test/test_database.py index 7720fce7a68b4c60d91cb5e13c1d5c72a8744df2..146176862d591680c107fd4a963cbed3ce61b184 100644 --- a/beat/backend/python/test/test_database.py +++ b/beat/backend/python/test/test_database.py @@ -35,11 +35,10 @@ import nose.tools -from ..database import Database +from ..database import Database from . import prefix - INTEGERS_DBS = ["integers_db/{}".format(i) for i in range(1, 3)] diff --git a/beat/backend/python/test/test_database_view.py b/beat/backend/python/test/test_database_view.py index 77c1df7b5b1d4017d428b9ce0fae0b7d43fa30e6..18d2a73fc1afc36703dc4f81cf56e1e22294a9a3 100644 --- a/beat/backend/python/test/test_database_view.py +++ b/beat/backend/python/test/test_database_view.py @@ -34,20 +34,17 @@ ################################################################################### -import unittest -import tempfile -import shutil import os +import shutil +import tempfile +import unittest from ddt import ddt from ddt import idata from ..database import Database - -from .test_database import INTEGERS_DBS - from . import prefix - +from .test_database import INTEGERS_DBS # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_databases_index.py b/beat/backend/python/test/test_databases_index.py index 1cbaafb7961adfff9f08dbf88d532a8caeea0559..c652fe003f39d07c596038a58e2dd6fee7cb34b8 100644 --- a/beat/backend/python/test/test_databases_index.py +++ b/beat/backend/python/test/test_databases_index.py @@ -36,24 +36,20 @@ # Tests for experiment execution -import os - -import unittest import multiprocessing -import tempfile +import os import shutil +import tempfile +import unittest from ddt import ddt from ddt import idata -from ..scripts import index from ..hash import hashDataset from ..hash import toPath - -from .test_database import INTEGERS_DBS - +from ..scripts import index from . import prefix - +from .test_database import INTEGERS_DBS # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_databases_provider.py b/beat/backend/python/test/test_databases_provider.py index bf707cae3e79f3f68331a60366a7475ac63f33c2..53755890182d5e74644ba4fe4d0c5604cf500af4 100644 --- a/beat/backend/python/test/test_databases_provider.py +++ b/beat/backend/python/test/test_databases_provider.py @@ -36,30 +36,27 @@ # Tests for experiment execution -import os -import socket - -import unittest import json import multiprocessing -import tempfile +import os import shutil +import socket +import tempfile +import unittest + +from contextlib import closing + import zmq from ddt import ddt from ddt import idata -from contextlib import closing - -from ..scripts import databases_provider -from ..database import Database from ..data import RemoteDataSource from ..data import RemoteException - -from .test_database import INTEGERS_DBS - +from ..database import Database +from ..scripts import databases_provider from . import prefix - +from .test_database import INTEGERS_DBS # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_dbexecutor.py b/beat/backend/python/test/test_dbexecutor.py index cc5db3b569a46a8dec3eaf4fcdeb01ef77e08d5f..62543d72bfb3cea7005a2cb53dc232d27833e4a1 100644 --- a/beat/backend/python/test/test_dbexecutor.py +++ b/beat/backend/python/test/test_dbexecutor.py @@ -37,26 +37,24 @@ # Tests for experiment execution import os +import shutil +import tempfile import unittest + import zmq -import tempfile -import shutil from ddt import ddt from ddt import idata +from ..data import RemoteDataSource +from ..data_loaders import DataLoader +from ..database import Database from ..execution import DBExecutor from ..execution import MessageHandler -from ..database import Database -from ..data_loaders import DataLoader -from ..data import RemoteDataSource from ..hash import hashDataset from ..hash import toPath - -from .test_database import INTEGERS_DBS - from . import prefix - +from .test_database import INTEGERS_DBS # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_executor.py b/beat/backend/python/test/test_executor.py index 4a8e36612f9cff5134bf8229330398c98ca4ab8a..3ff2d070c4269d27201a5fe01531cc9d6497bab1 100644 --- a/beat/backend/python/test/test_executor.py +++ b/beat/backend/python/test/test_executor.py @@ -34,55 +34,41 @@ ################################################################################### -import unittest import logging -import tempfile -import simplejson import os -import zmq import shutil -import numpy as np +import tempfile +import unittest + from copy import deepcopy -from ..execution import AlgorithmExecutor -from ..execution import MessageHandler -from ..inputs import InputList +import numpy as np +import simplejson +import zmq + from ..algorithm import Algorithm -from ..dataformat import DataFormat from ..data import CachedDataSink from ..data import CachedDataSource +from ..dataformat import DataFormat +from ..execution import AlgorithmExecutor +from ..execution import MessageHandler from ..helpers import convert_experiment_configuration_to_container -from ..helpers import AccessMode - from . import prefix from .mocks import MockLoggingHandler - CONFIGURATION = { - 'algorithm': '', - 'channel': 'main', - 'parameters': { - }, - 'inputs': { - 'in': { - 'path': 'INPUT', - 'channel': 'main', - } - }, - 'outputs': { - 'out': { - 'path': 'OUTPUT', - 'channel': 'main' - } - }, + "algorithm": "", + "channel": "main", + "parameters": {}, + "inputs": {"in": {"path": "INPUT", "channel": "main"}}, + "outputs": {"out": {"path": "OUTPUT", "channel": "main"}}, } -#---------------------------------------------------------- +# ---------------------------------------------------------- class TestAlgorithmExecutor(unittest.TestCase): - def setUp(self): self.cache_root = tempfile.mkdtemp(prefix=__name__) self.working_dir = tempfile.mkdtemp(prefix=__name__) @@ -90,7 +76,6 @@ class TestAlgorithmExecutor(unittest.TestCase): self.executor_socket = None self.zmq_context = None - def tearDown(self): shutil.rmtree(self.cache_root) shutil.rmtree(self.working_dir) @@ -108,15 +93,18 @@ class TestAlgorithmExecutor(unittest.TestCase): self.executor_socket = None self.zmq_context = None - def writeData(self, input_name, indices, start_value): - filename = os.path.join(self.cache_root, CONFIGURATION['inputs'][input_name]['path'] + '.data') + filename = os.path.join( + self.cache_root, CONFIGURATION["inputs"][input_name]["path"] + ".data" + ) - dataformat = DataFormat(prefix, 'user/single_integer/1') + dataformat = DataFormat(prefix, "user/single_integer/1") self.assertTrue(dataformat.valid) data_sink = CachedDataSink() - self.assertTrue(data_sink.setup(filename, dataformat, indices[0][0], indices[-1][1])) + self.assertTrue( + data_sink.setup(filename, dataformat, indices[0][0], indices[-1][1]) + ) for i in indices: data = dataformat.type() @@ -130,26 +118,25 @@ class TestAlgorithmExecutor(unittest.TestCase): data_sink.close() del data_sink - def process(self, algorithm_name): - self.writeData('in', [(0, 0), (1, 1), (2, 2), (3, 3)], 1000) + self.writeData("in", [(0, 0), (1, 1), (2, 2), (3, 3)], 1000) config = deepcopy(CONFIGURATION) - config['algorithm'] = algorithm_name + config["algorithm"] = algorithm_name config = convert_experiment_configuration_to_container(config) - with open(os.path.join(self.working_dir, 'configuration.json'), 'wb') as f: - data = simplejson.dumps(config, indent=4).encode('utf-8') + with open(os.path.join(self.working_dir, "configuration.json"), "wb") as f: + data = simplejson.dumps(config, indent=4).encode("utf-8") f.write(data) - working_prefix = os.path.join(self.working_dir, 'prefix') + working_prefix = os.path.join(self.working_dir, "prefix") if not os.path.exists(working_prefix): os.makedirs(working_prefix) algorithm = Algorithm(prefix, algorithm_name) algorithm.export(working_prefix) - self.message_handler = MessageHandler('127.0.0.1') + self.message_handler = MessageHandler("127.0.0.1") self.message_handler.start() @@ -157,14 +144,23 @@ class TestAlgorithmExecutor(unittest.TestCase): self.executor_socket = self.zmq_context.socket(zmq.PAIR) self.executor_socket.connect(self.message_handler.address) - executor = AlgorithmExecutor(self.executor_socket, self.working_dir, cache_root=self.cache_root) + executor = AlgorithmExecutor( + self.executor_socket, self.working_dir, cache_root=self.cache_root + ) self.assertTrue(executor.setup()) self.assertTrue(executor.prepare()) self.assertTrue(executor.process()) cached_file = CachedDataSource() - self.assertTrue(cached_file.setup(os.path.join(self.cache_root, CONFIGURATION['outputs']['out']['path'] + '.data'), prefix)) + self.assertTrue( + cached_file.setup( + os.path.join( + self.cache_root, CONFIGURATION["outputs"]["out"]["path"] + ".data" + ), + prefix, + ) + ) for i in range(len(cached_file)): data, start, end = cached_file[i] @@ -172,22 +168,22 @@ class TestAlgorithmExecutor(unittest.TestCase): self.assertEqual(start, i) self.assertEqual(end, i) - def test_legacy_echo_1(self): - log_handler = MockLoggingHandler(level='DEBUG') + log_handler = MockLoggingHandler(level="DEBUG") logging.getLogger().addHandler(log_handler) log_messages = log_handler.messages - self.process('legacy/echo/1') + self.process("legacy/echo/1") - info_len = len(log_messages['warning']) + info_len = len(log_messages["warning"]) self.assertEqual(info_len, 1) - self.assertEqual(log_messages['warning'][info_len - 1], 'legacy/echo/1 is using LEGACY I/O API, please upgrade this algorithm as soon as possible') - + self.assertEqual( + log_messages["warning"][info_len - 1], + "legacy/echo/1 is using LEGACY I/O API, please upgrade this algorithm as soon as possible", + ) def test_sequential_echo_1(self): - self.process('sequential/echo/1') - + self.process("sequential/echo/1") def test_autonomous_echo_1(self): - self.process('autonomous/echo/1') + self.process("autonomous/echo/1") diff --git a/beat/backend/python/test/test_format_array.py b/beat/backend/python/test/test_format_array.py index 54f409d183a2dac40434dec60e8c78c4da7faea1..8698a01144b38b8fd0c84dd77ab514f6b6d46ad1 100644 --- a/beat/backend/python/test/test_format_array.py +++ b/beat/backend/python/test/test_format_array.py @@ -34,14 +34,12 @@ ################################################################################### -import numpy import nose.tools +import numpy from ..dataformat import DataFormat - from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_format_extends.py b/beat/backend/python/test/test_format_extends.py index 8a7ff81cdfd3b54cac9763f88c9b0cebdc8e81ef..faccc97c0372ffdb3144abf699f2d8c34248ca04 100644 --- a/beat/backend/python/test/test_format_extends.py +++ b/beat/backend/python/test/test_format_extends.py @@ -34,14 +34,12 @@ ################################################################################### -import numpy import nose.tools +import numpy from ..dataformat import DataFormat - from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_format_missing_attributes.py b/beat/backend/python/test/test_format_missing_attributes.py index 8e0938680149fbeb8af84de00ac6e24fcbf9f0a6..73490bc450b0152d1bfcefe5f860d36a7a7f3932 100644 --- a/beat/backend/python/test/test_format_missing_attributes.py +++ b/beat/backend/python/test/test_format_missing_attributes.py @@ -37,10 +37,8 @@ import nose.tools from ..dataformat import DataFormat - from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_format_object.py b/beat/backend/python/test/test_format_object.py index f88358a74f912a8ae5a8420e1f5d582410f37da3..6e5322b044aacce92d797a76edf5a57a69abd645 100644 --- a/beat/backend/python/test/test_format_object.py +++ b/beat/backend/python/test/test_format_object.py @@ -34,14 +34,12 @@ ################################################################################### -import numpy import nose.tools +import numpy from ..dataformat import DataFormat - from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_format_simple.py b/beat/backend/python/test/test_format_simple.py index ddbfba674e09af7da315bd6c9cd0bb8684d244bb..5538b72b774cd206fbe5562b5a2e2c1dbcbf3839 100644 --- a/beat/backend/python/test/test_format_simple.py +++ b/beat/backend/python/test/test_format_simple.py @@ -34,14 +34,12 @@ ################################################################################### -import numpy import nose.tools +import numpy from ..dataformat import DataFormat - from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_format_unsafe_cast.py b/beat/backend/python/test/test_format_unsafe_cast.py index e3d41786ea6aa0d19ab3ae9e998ba13e8c9cb658..c1335625815329a03333e1fd733dba82066cb475 100644 --- a/beat/backend/python/test/test_format_unsafe_cast.py +++ b/beat/backend/python/test/test_format_unsafe_cast.py @@ -34,14 +34,12 @@ ################################################################################### -import six import nose.tools +import six from ..dataformat import DataFormat - from . import prefix - number42L = long(42) if six.PY2 else int(42) # noqa diff --git a/beat/backend/python/test/test_format_valid_cast.py b/beat/backend/python/test/test_format_valid_cast.py index 04f8ed7a9afcf7d43b9d1c67b0544344974da43c..7be5e5a7a84fa8d7cd79d2b3e40a82be6cf3b401 100644 --- a/beat/backend/python/test/test_format_valid_cast.py +++ b/beat/backend/python/test/test_format_valid_cast.py @@ -34,14 +34,12 @@ ################################################################################### -import numpy import nose.tools +import numpy from ..dataformat import DataFormat - from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_hash.py b/beat/backend/python/test/test_hash.py index f8a641cc530e061e7be17eab8dfc53966a75947e..809de4596f4f3a370014e8e8599647fc722b4e47 100644 --- a/beat/backend/python/test/test_hash.py +++ b/beat/backend/python/test/test_hash.py @@ -39,7 +39,6 @@ import six from .. import hash - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_helpers.py b/beat/backend/python/test/test_helpers.py index 701bf2e0edcc81786a9226c2865f0749aa9e0651..84cb91f8982c897a1f59e1eb5d9eabcf3bda92c1 100644 --- a/beat/backend/python/test/test_helpers.py +++ b/beat/backend/python/test/test_helpers.py @@ -37,22 +37,21 @@ # Tests for experiment execution import os +import shutil +import tempfile import unittest + import zmq -import tempfile -import shutil +from ..algorithm import Algorithm from ..database import Database +from ..execution import MessageHandler from ..hash import hashDataset from ..hash import toPath -from ..algorithm import Algorithm -from ..helpers import create_inputs_from_configuration from ..helpers import AccessMode -from ..execution import MessageHandler - +from ..helpers import create_inputs_from_configuration from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_inputs.py b/beat/backend/python/test/test_inputs.py index ace05f2d14419a19a0531644cf3c3b5784c45f7a..208a6a7857ca4f4477e6547cc2f76b6ca39612fe 100644 --- a/beat/backend/python/test/test_inputs.py +++ b/beat/backend/python/test/test_inputs.py @@ -36,66 +36,59 @@ import unittest -from .mocks import MockDataSource - -from ..outputs import SynchronizationListener +from ..dataformat import DataFormat from ..inputs import Input from ..inputs import InputGroup from ..inputs import InputList -from ..dataformat import DataFormat -from ..data import CachedDataSink - +from ..outputs import SynchronizationListener from . import prefix +from .mocks import MockDataSource - -#---------------------------------------------------------- +# ---------------------------------------------------------- class InputTest(unittest.TestCase): - def test_creation(self): data_source = MockDataSource([]) - input = Input('test', 'mock', data_source) + input = Input("test", "mock", data_source) self.assertTrue(input.data is None) self.assertTrue(input.group is None) - self.assertEqual(input.data_format, 'mock') + self.assertEqual(input.data_format, "mock") self.assertEqual(input.data_index, -1) self.assertEqual(input.data_index_end, -1) self.assertTrue(input.data_same_as_previous) self.assertEqual(input.data_source, data_source) - self.assertEqual(input.name, 'test') + self.assertEqual(input.name, "test") self.assertEqual(input.nb_data_blocks_read, 0) - def test_no_more_data(self): data_source = MockDataSource([]) - input = Input('test', 'mock', data_source) + input = Input("test", "mock", data_source) self.assertFalse(input.hasMoreData()) - def test_has_more_data(self): - dataformat = DataFormat(prefix, 'user/single_integer/1') + dataformat = DataFormat(prefix, "user/single_integer/1") - data_source = MockDataSource([ (dataformat.type(value=10), 0, 0) ]) + data_source = MockDataSource([(dataformat.type(value=10), 0, 0)]) - input = Input('test', 'mock', data_source) + input = Input("test", "mock", data_source) self.assertTrue(input.hasMoreData()) - def test_retrieve_one_data_unit(self): - group = InputGroup('channel1', restricted_access=False) + group = InputGroup("channel1", restricted_access=False) - dataformat = DataFormat(prefix, 'user/single_integer/1') + dataformat = DataFormat(prefix, "user/single_integer/1") - data_source = MockDataSource([ (dataformat.type(value=10), 0, 0), - (dataformat.type(value=20), 1, 1) ]) + data_source = MockDataSource( + [(dataformat.type(value=10), 0, 0), (dataformat.type(value=20), 1, 1)] + ) - input = Input('test', 'mock', data_source) + input = Input("test", "mock", data_source) group.add(input) @@ -116,14 +109,13 @@ class InputTest(unittest.TestCase): self.assertTrue(input.hasDataChanged()) self.assertTrue(input.isDataUnitDone()) - def test_retrieve_all_data_units(self): - group = InputGroup('channel1', restricted_access=False) + group = InputGroup("channel1", restricted_access=False) - dataformat = DataFormat(prefix, 'user/single_integer/1') + dataformat = DataFormat(prefix, "user/single_integer/1") - data_source = MockDataSource([ (dataformat.type(value=10), 0, 0) ]) - input = Input('test', 'mock', data_source) + data_source = MockDataSource([(dataformat.type(value=10), 0, 0)]) + input = Input("test", "mock", data_source) group.add(input) @@ -144,14 +136,13 @@ class InputTest(unittest.TestCase): self.assertTrue(input.hasDataChanged()) self.assertTrue(input.isDataUnitDone()) - def test_restricted_access(self): - group = InputGroup('channel1', restricted_access=True) + group = InputGroup("channel1", restricted_access=True) - dataformat = DataFormat(prefix, 'user/single_integer/1') + dataformat = DataFormat(prefix, "user/single_integer/1") - data_source = MockDataSource([ (dataformat.type(value=10), 0, 0) ]) - input = Input('test', 'mock', data_source) + data_source = MockDataSource([(dataformat.type(value=10), 0, 0)]) + input = Input("test", "mock", data_source) group.add(input) @@ -163,46 +154,43 @@ class InputTest(unittest.TestCase): input.next() -#---------------------------------------------------------- +# ---------------------------------------------------------- class RestrictedInputGroupTest(unittest.TestCase): - def test_creation(self): - group = InputGroup('channel1') + group = InputGroup("channel1") self.assertTrue(group.restricted_access) self.assertTrue(group.synchronization_listener is None) - self.assertEqual(group.channel, 'channel1') + self.assertEqual(group.channel, "channel1") self.assertEqual(len(group), 0) self.assertEqual(group.data_index, -1) self.assertEqual(group.data_index_end, -1) self.assertEqual(group.first_data_index, -1) self.assertEqual(group.last_data_index, -1) - def test_add_one_input(self): data_source = MockDataSource([]) - input = Input('input1', 'mock', data_source) + input = Input("input1", "mock", data_source) - group = InputGroup('channel1') + group = InputGroup("channel1") group.add(input) self.assertEqual(input.group, group) self.assertEqual(len(group), 1) - self.assertEqual(group['input1'], input) - + self.assertEqual(group["input1"], input) def test_add_two_inputs(self): data_source1 = MockDataSource([]) - input1 = Input('input1', 'mock', data_source1) + input1 = Input("input1", "mock", data_source1) data_source2 = MockDataSource([]) - input2 = Input('input2', 'mock', data_source2) + input2 = Input("input2", "mock", data_source2) - group = InputGroup('channel1') + group = InputGroup("channel1") group.add(input1) group.add(input2) @@ -210,75 +198,71 @@ class RestrictedInputGroupTest(unittest.TestCase): self.assertEqual(input1.group, group) self.assertEqual(input2.group, group) self.assertEqual(len(group), 2) - self.assertEqual(group['input1'], input1) - self.assertEqual(group['input2'], input2) - + self.assertEqual(group["input1"], input1) + self.assertEqual(group["input2"], input2) def test_no_more_data(self): data_source1 = MockDataSource([]) - input1 = Input('input1', 'mock', data_source1) + input1 = Input("input1", "mock", data_source1) data_source2 = MockDataSource([]) - input2 = Input('input2', 'mock', data_source2) + input2 = Input("input2", "mock", data_source2) - group = InputGroup('channel1') + group = InputGroup("channel1") group.add(input1) group.add(input2) self.assertFalse(group.hasMoreData()) - def test_has_more_data(self): - dataformat = DataFormat(prefix, 'user/single_integer/1') + dataformat = DataFormat(prefix, "user/single_integer/1") - data_source1 = MockDataSource([ (dataformat.type(value=10), 0, 0) ]) - input1 = Input('input1', 'mock', data_source1) + data_source1 = MockDataSource([(dataformat.type(value=10), 0, 0)]) + input1 = Input("input1", "mock", data_source1) - data_source2 = MockDataSource([ (dataformat.type(value=10), 0, 0) ]) - input2 = Input('input2', 'mock', data_source2) + data_source2 = MockDataSource([(dataformat.type(value=10), 0, 0)]) + input2 = Input("input2", "mock", data_source2) - group = InputGroup('channel1') + group = InputGroup("channel1") group.add(input1) group.add(input2) self.assertTrue(group.hasMoreData()) - def test_restricted_access(self): - group = InputGroup('channel1') + group = InputGroup("channel1") with self.assertRaises(RuntimeError): group.next() -#---------------------------------------------------------- +# ---------------------------------------------------------- class InputGroupTest(unittest.TestCase): - def test_creation(self): - group = InputGroup('channel1', restricted_access=False) + group = InputGroup("channel1", restricted_access=False) self.assertFalse(group.restricted_access) self.assertTrue(group.synchronization_listener is None) - self.assertEqual(group.channel, 'channel1') + self.assertEqual(group.channel, "channel1") self.assertEqual(len(group), 0) self.assertEqual(group.data_index, -1) self.assertEqual(group.data_index_end, -1) self.assertEqual(group.first_data_index, -1) self.assertEqual(group.last_data_index, -1) - def test_creation_with_listener(self): listener = SynchronizationListener() - group = InputGroup('channel1', synchronization_listener=listener, - restricted_access=False) + group = InputGroup( + "channel1", synchronization_listener=listener, restricted_access=False + ) self.assertFalse(group.restricted_access) self.assertEqual(group.synchronization_listener, listener) - self.assertEqual(group.channel, 'channel1') + self.assertEqual(group.channel, "channel1") self.assertEqual(len(group), 0) self.assertEqual(group.data_index, -1) self.assertEqual(group.data_index_end, -1) @@ -288,29 +272,27 @@ class InputGroupTest(unittest.TestCase): self.assertEqual(listener.data_index_start, -1) self.assertEqual(listener.data_index_end, -1) - def test_add_one_input(self): data_source = MockDataSource([]) - input = Input('input1', 'mock', data_source) + input = Input("input1", "mock", data_source) - group = InputGroup('channel1', restricted_access=False) + group = InputGroup("channel1", restricted_access=False) group.add(input) self.assertEqual(input.group, group) self.assertEqual(len(group), 1) - self.assertEqual(group['input1'], input) - + self.assertEqual(group["input1"], input) def test_add_two_inputs(self): data_source1 = MockDataSource([]) - input1 = Input('input1', 'mock', data_source1) + input1 = Input("input1", "mock", data_source1) data_source2 = MockDataSource([]) - input2 = Input('input2', 'mock', data_source2) + input2 = Input("input2", "mock", data_source2) - group = InputGroup('channel1', restricted_access=False) + group = InputGroup("channel1", restricted_access=False) group.add(input1) group.add(input2) @@ -318,58 +300,58 @@ class InputGroupTest(unittest.TestCase): self.assertEqual(input1.group, group) self.assertEqual(input2.group, group) self.assertEqual(len(group), 2) - self.assertEqual(group['input1'], input1) - self.assertEqual(group['input2'], input2) - + self.assertEqual(group["input1"], input1) + self.assertEqual(group["input2"], input2) def test_no_more_data(self): data_source1 = MockDataSource([]) - input1 = Input('input1', 'mock', data_source1) + input1 = Input("input1", "mock", data_source1) data_source2 = MockDataSource([]) - input2 = Input('input2', 'mock', data_source2) + input2 = Input("input2", "mock", data_source2) - group = InputGroup('channel1', restricted_access=False) + group = InputGroup("channel1", restricted_access=False) group.add(input1) group.add(input2) self.assertFalse(group.hasMoreData()) - def test_has_more_data(self): - dataformat = DataFormat(prefix, 'user/single_integer/1') + dataformat = DataFormat(prefix, "user/single_integer/1") - data_source1 = MockDataSource([ (dataformat.type(value=10), 0, 0) ]) - input1 = Input('input1', 'mock', data_source1) + data_source1 = MockDataSource([(dataformat.type(value=10), 0, 0)]) + input1 = Input("input1", "mock", data_source1) - data_source2 = MockDataSource([ (dataformat.type(value=10), 0, 0) ]) - input2 = Input('input2', 'mock', data_source2) + data_source2 = MockDataSource([(dataformat.type(value=10), 0, 0)]) + input2 = Input("input2", "mock", data_source2) - group = InputGroup('channel1', restricted_access=False) + group = InputGroup("channel1", restricted_access=False) group.add(input1) group.add(input2) self.assertTrue(group.hasMoreData()) - def test_retrieve_one_input_iteration(self): - indices = [ (0, 0), (1, 1), (2, 3), (4, 4), (5, 5) ] + indices = [(0, 0), (1, 1), (2, 3), (4, 4), (5, 5)] expected_hasMoreData = [True, True, True, True, False] expected_isDataUnitDone = [True, True, True, True, True] expected_hasDataChanged = [True, True, True, True, True] + dataformat = DataFormat(prefix, "user/single_integer/1") - dataformat = DataFormat(prefix, 'user/single_integer/1') - - data_source = MockDataSource([ (dataformat.type(value=x), indices[x][0], indices[x][1] ) - for x in range(0, len(indices)) ]) + data_source = MockDataSource( + [ + (dataformat.type(value=x), indices[x][0], indices[x][1]) + for x in range(0, len(indices)) + ] + ) - input = Input('input', 'mock', data_source) + input = Input("input", "mock", data_source) - group = InputGroup('channel1', restricted_access=False) + group = InputGroup("channel1", restricted_access=False) group.add(input) @@ -400,33 +382,43 @@ class InputGroupTest(unittest.TestCase): self.assertEqual(input.isDataUnitDone(), expected_isDataUnitDone[i]) self.assertEqual(input.hasDataChanged(), expected_hasDataChanged[i]) - def test_retrieve_three_inputs_iteration__same_frequency(self): - indices = [ (0, 0), (1, 1), (2, 2), (3, 3), (4, 4) ] + indices = [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)] expected_hasMoreData = [True, True, True, True, False] expected_isDataUnitDone = [True, True, True, True, True] expected_hasDataChanged = [True, True, True, True, True] + dataformat = DataFormat(prefix, "user/single_integer/1") - dataformat = DataFormat(prefix, 'user/single_integer/1') - - data_source1 = MockDataSource([ (dataformat.type(value=x), indices[x][0], indices[x][1] ) - for x in range(0, len(indices)) ]) + data_source1 = MockDataSource( + [ + (dataformat.type(value=x), indices[x][0], indices[x][1]) + for x in range(0, len(indices)) + ] + ) - input1 = Input('input1', 'mock', data_source1) + input1 = Input("input1", "mock", data_source1) - data_source2 = MockDataSource([ (dataformat.type(value=x + 10), indices[x][0], indices[x][1] ) - for x in range(0, len(indices)) ]) + data_source2 = MockDataSource( + [ + (dataformat.type(value=x + 10), indices[x][0], indices[x][1]) + for x in range(0, len(indices)) + ] + ) - input2 = Input('input2', 'mock', data_source2) + input2 = Input("input2", "mock", data_source2) - data_source3 = MockDataSource([ (dataformat.type(value=x + 20), indices[x][0], indices[x][1] ) - for x in range(0, len(indices)) ]) + data_source3 = MockDataSource( + [ + (dataformat.type(value=x + 20), indices[x][0], indices[x][1]) + for x in range(0, len(indices)) + ] + ) - input3 = Input('input3', 'mock', data_source3) + input3 = Input("input3", "mock", data_source3) - group = InputGroup('channel1', restricted_access=False) + group = InputGroup("channel1", restricted_access=False) group.add(input1) group.add(input2) @@ -489,11 +481,10 @@ class InputGroupTest(unittest.TestCase): self.assertEqual(input2.hasDataChanged(), expected_hasDataChanged[i]) self.assertEqual(input3.hasDataChanged(), expected_hasDataChanged[i]) - def test_retrieve_three_inputs_iteration__different_frequencies(self): - indices1 = [ (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5) ] - indices2 = [ (0, 1), (2, 3), (4, 5) ] - indices3 = [ (0, 5) ] + indices1 = [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)] + indices2 = [(0, 1), (2, 3), (4, 5)] + indices3 = [(0, 5)] expected_hasMoreData_1 = [True, True, True, True, True, False] expected_hasMoreData_2 = [True, True, True, True, False, False] @@ -507,25 +498,36 @@ class InputGroupTest(unittest.TestCase): expected_hasDataChanged_2 = [True, False, True, False, True, False] expected_hasDataChanged_3 = [True, False, False, False, False, False] + dataformat = DataFormat(prefix, "user/single_integer/1") - dataformat = DataFormat(prefix, 'user/single_integer/1') - - data_source1 = MockDataSource([ (dataformat.type(value=x), indices1[x][0], indices1[x][1] ) - for x in range(0, len(indices1)) ]) + data_source1 = MockDataSource( + [ + (dataformat.type(value=x), indices1[x][0], indices1[x][1]) + for x in range(0, len(indices1)) + ] + ) - input1 = Input('input1', 'mock', data_source1) + input1 = Input("input1", "mock", data_source1) - data_source2 = MockDataSource([ (dataformat.type(value=x + 10), indices2[x][0], indices2[x][1] ) - for x in range(0, len(indices2)) ]) + data_source2 = MockDataSource( + [ + (dataformat.type(value=x + 10), indices2[x][0], indices2[x][1]) + for x in range(0, len(indices2)) + ] + ) - input2 = Input('input2', 'mock', data_source2) + input2 = Input("input2", "mock", data_source2) - data_source3 = MockDataSource([ (dataformat.type(value=x + 20), indices3[x][0], indices3[x][1] ) - for x in range(0, len(indices3)) ]) + data_source3 = MockDataSource( + [ + (dataformat.type(value=x + 20), indices3[x][0], indices3[x][1]) + for x in range(0, len(indices3)) + ] + ) - input3 = Input('input3', 'mock', data_source3) + input3 = Input("input3", "mock", data_source3) - group = InputGroup('channel1', restricted_access=False) + group = InputGroup("channel1", restricted_access=False) group.add(input1) group.add(input2) @@ -586,42 +588,102 @@ class InputGroupTest(unittest.TestCase): self.assertEqual(input2.hasDataChanged(), expected_hasDataChanged_2[i]) self.assertEqual(input3.hasDataChanged(), expected_hasDataChanged_3[i]) - def test_retrieve_two_inputs_iteration__desynchronized_frequencies(self): - indices1 = [ (0, 2), (3, 5), (6, 8), (9, 11), (12, 14), (15, 17) ] - indices2 = [ (0, 4), (5, 10), (11, 17) ] + indices1 = [(0, 2), (3, 5), (6, 8), (9, 11), (12, 14), (15, 17)] + indices2 = [(0, 4), (5, 10), (11, 17)] expected_values_1 = [0, 1, 1, 2, 3, 3, 4, 5] expected_values_2 = [0, 0, 1, 1, 1, 2, 2, 2] - expected_group_indices1 = [(0, 4), (0, 5), (3, 10), (5, 10), (5, 11), (9, 17), (11, 17), (11, 17)] - expected_group_indices2 = [(0, 2), (3, 4), (5, 5), (6, 8), (9, 10), (11, 11), (12, 14), (15, 17)] - expected_indices_1 = [(0, 2), (3, 5), (3, 5), (6, 8), (9, 11), (9, 11), (12, 14), (15, 17)] - expected_indices_2 = [(0, 4), (0, 4), (5, 10), (5, 10), (5, 10), (11, 17), (11, 17), (11, 17)] - - expected_hasMoreData_1 = [True, True, True, True, True, True, True, False] + expected_group_indices1 = [ + (0, 4), + (0, 5), + (3, 10), + (5, 10), + (5, 11), + (9, 17), + (11, 17), + (11, 17), + ] + expected_group_indices2 = [ + (0, 2), + (3, 4), + (5, 5), + (6, 8), + (9, 10), + (11, 11), + (12, 14), + (15, 17), + ] + expected_indices_1 = [ + (0, 2), + (3, 5), + (3, 5), + (6, 8), + (9, 11), + (9, 11), + (12, 14), + (15, 17), + ] + expected_indices_2 = [ + (0, 4), + (0, 4), + (5, 10), + (5, 10), + (5, 10), + (11, 17), + (11, 17), + (11, 17), + ] + + expected_hasMoreData_1 = [True, True, True, True, True, True, True, False] expected_hasMoreData_2 = [True, True, True, True, True, False, False, False] - expected_isDataUnitDone_1 = [True, False, True, True, False, True, True, True] - expected_isDataUnitDone_2 = [False, True, False, False, True, False, False, True] - - expected_hasDataChanged_1 = [True, True, False, True, True, False, True, True] - expected_hasDataChanged_2 = [True, False, True, False, False, True, False, False] - - - dataformat = DataFormat(prefix, 'user/single_integer/1') - - data_source1 = MockDataSource([ (dataformat.type(value=x), indices1[x][0], indices1[x][1] ) - for x in range(0, len(indices1)) ]) - - input1 = Input('input1', 'mock', data_source1) - - data_source2 = MockDataSource([ (dataformat.type(value=x), indices2[x][0], indices2[x][1] ) - for x in range(0, len(indices2)) ]) - - input2 = Input('input2', 'mock', data_source2) - - group = InputGroup('channel1', restricted_access=False) + expected_isDataUnitDone_1 = [True, False, True, True, False, True, True, True] + expected_isDataUnitDone_2 = [ + False, + True, + False, + False, + True, + False, + False, + True, + ] + + expected_hasDataChanged_1 = [True, True, False, True, True, False, True, True] + expected_hasDataChanged_2 = [ + True, + False, + True, + False, + False, + True, + False, + False, + ] + + dataformat = DataFormat(prefix, "user/single_integer/1") + + data_source1 = MockDataSource( + [ + (dataformat.type(value=x), indices1[x][0], indices1[x][1]) + for x in range(0, len(indices1)) + ] + ) + + input1 = Input("input1", "mock", data_source1) + + data_source2 = MockDataSource( + [ + (dataformat.type(value=x), indices2[x][0], indices2[x][1]) + for x in range(0, len(indices2)) + ] + ) + + input2 = Input("input2", "mock", data_source2) + + group = InputGroup("channel1", restricted_access=False) group.add(input1) group.add(input2) @@ -665,37 +727,61 @@ class InputGroupTest(unittest.TestCase): self.assertEqual(input1.hasDataChanged(), expected_hasDataChanged_1[i]) self.assertEqual(input2.hasDataChanged(), expected_hasDataChanged_2[i]) - def test_retrieve_two_inputs_iteration__different_frequencies(self): - indices1 = [ (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7) ] - indices2 = [ (0, 3), (4, 7) ] + indices1 = [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + indices2 = [(0, 3), (4, 7)] expected_values_1 = [0, 1, 2, 3, 4, 5, 6, 7] expected_values_2 = [0, 0, 0, 0, 1, 1, 1, 1] - expected_hasMoreData_1 = [True, True, True, True, True, True, True, False] + expected_hasMoreData_1 = [True, True, True, True, True, True, True, False] expected_hasMoreData_2 = [True, True, True, True, False, False, False, False] - expected_isDataUnitDone_1 = [True, True, True, True, True, True, True, True] - expected_isDataUnitDone_2 = [False, False, False, True, False, False, False, True] - - expected_hasDataChanged_1 = [True, True, True, True, True, True, True, True] - expected_hasDataChanged_2 = [True, False, False, False, True, False, False, False] - - - dataformat = DataFormat(prefix, 'user/single_integer/1') - - data_source1 = MockDataSource([ (dataformat.type(value=x), indices1[x][0], indices1[x][1] ) - for x in range(0, len(indices1)) ]) - - input1 = Input('input1', 'mock', data_source1) - - data_source2 = MockDataSource([ (dataformat.type(value=x), indices2[x][0], indices2[x][1] ) - for x in range(0, len(indices2)) ]) - - input2 = Input('input2', 'mock', data_source2) - - group = InputGroup('channel1', restricted_access=False) + expected_isDataUnitDone_1 = [True, True, True, True, True, True, True, True] + expected_isDataUnitDone_2 = [ + False, + False, + False, + True, + False, + False, + False, + True, + ] + + expected_hasDataChanged_1 = [True, True, True, True, True, True, True, True] + expected_hasDataChanged_2 = [ + True, + False, + False, + False, + True, + False, + False, + False, + ] + + dataformat = DataFormat(prefix, "user/single_integer/1") + + data_source1 = MockDataSource( + [ + (dataformat.type(value=x), indices1[x][0], indices1[x][1]) + for x in range(0, len(indices1)) + ] + ) + + input1 = Input("input1", "mock", data_source1) + + data_source2 = MockDataSource( + [ + (dataformat.type(value=x), indices2[x][0], indices2[x][1]) + for x in range(0, len(indices2)) + ] + ) + + input2 = Input("input2", "mock", data_source2) + + group = InputGroup("channel1", restricted_access=False) group.add(input1) group.add(input2) @@ -740,11 +826,10 @@ class InputGroupTest(unittest.TestCase): self.assertEqual(input2.hasDataChanged(), expected_hasDataChanged_2[i]) -#---------------------------------------------------------- +# ---------------------------------------------------------- class InputListTest(unittest.TestCase): - def test_creation(self): inputs = InputList() @@ -753,26 +838,23 @@ class InputListTest(unittest.TestCase): self.assertEqual(len(inputs), 0) self.assertFalse(inputs.hasMoreData()) - def test_list_unkown_input_retrieval(self): inputs = InputList() - self.assertTrue(inputs['unknown'] is None) - + self.assertTrue(inputs["unknown"] is None) def test_list_group_of_unknown_input_retrieval(self): inputs = InputList() - self.assertTrue(inputs.groupOf('unknown') is None) - + self.assertTrue(inputs.groupOf("unknown") is None) def test_list_one_group_one_input(self): inputs = InputList() data_source = MockDataSource([]) - input = Input('input1', 'mock', data_source) + input = Input("input1", "mock", data_source) - group = InputGroup('channel1') + group = InputGroup("channel1") group.add(input) inputs.add(group) @@ -781,22 +863,21 @@ class InputListTest(unittest.TestCase): self.assertEqual(inputs.nbGroups(), 1) self.assertEqual(len(inputs), 1) - self.assertEqual(inputs['input1'], input) + self.assertEqual(inputs["input1"], input) self.assertEqual(inputs[0], input) - self.assertEqual(inputs.groupOf('input1'), group) - + self.assertEqual(inputs.groupOf("input1"), group) def test_list_one_group_two_inputs(self): inputs = InputList() data_source1 = MockDataSource([]) - input1 = Input('input1', 'mock', data_source1) + input1 = Input("input1", "mock", data_source1) data_source2 = MockDataSource([]) - input2 = Input('input2', 'mock', data_source2) + input2 = Input("input2", "mock", data_source2) - group = InputGroup('channel1') + group = InputGroup("channel1") group.add(input1) group.add(input2) @@ -807,35 +888,34 @@ class InputListTest(unittest.TestCase): self.assertEqual(inputs.nbGroups(), 1) self.assertEqual(len(inputs), 2) - self.assertEqual(inputs['input1'], input1) + self.assertEqual(inputs["input1"], input1) self.assertEqual(inputs[0], input1) - self.assertEqual(inputs['input2'], input2) + self.assertEqual(inputs["input2"], input2) self.assertEqual(inputs[1], input2) - self.assertEqual(inputs.groupOf('input1'), group) - self.assertEqual(inputs.groupOf('input2'), group) - + self.assertEqual(inputs.groupOf("input1"), group) + self.assertEqual(inputs.groupOf("input2"), group) def test_list_two_groups_three_inputs(self): inputs = InputList() - group1 = InputGroup('channel1') + group1 = InputGroup("channel1") data_source1 = MockDataSource([]) - input1 = Input('input1', 'mock', data_source1) + input1 = Input("input1", "mock", data_source1) group1.add(input1) data_source2 = MockDataSource([]) - input2 = Input('input2', 'mock', data_source2) + input2 = Input("input2", "mock", data_source2) group1.add(input2) inputs.add(group1) - group2 = InputGroup('channel2', restricted_access=False) + group2 = InputGroup("channel2", restricted_access=False) data_source3 = MockDataSource([]) - input3 = Input('input3', 'mock', data_source3) + input3 = Input("input3", "mock", data_source3) group2.add(input3) inputs.add(group2) @@ -844,18 +924,18 @@ class InputListTest(unittest.TestCase): self.assertEqual(inputs.nbGroups(), 2) self.assertEqual(len(inputs), 3) - self.assertEqual(inputs['input1'], input1) + self.assertEqual(inputs["input1"], input1) self.assertEqual(inputs[0], input1) - self.assertEqual(inputs['input2'], input2) + self.assertEqual(inputs["input2"], input2) self.assertEqual(inputs[1], input2) - self.assertEqual(inputs['input3'], input3) + self.assertEqual(inputs["input3"], input3) self.assertEqual(inputs[2], input3) - self.assertEqual(inputs.groupOf('input1'), group1) - self.assertEqual(inputs.groupOf('input2'), group1) - self.assertEqual(inputs.groupOf('input3'), group2) + self.assertEqual(inputs.groupOf("input1"), group1) + self.assertEqual(inputs.groupOf("input2"), group1) + self.assertEqual(inputs.groupOf("input3"), group2) counter = 0 for input in inputs: diff --git a/beat/backend/python/test/test_loop_executor.py b/beat/backend/python/test/test_loop_executor.py index f2486178f122b98419568a5a3ba3b8e8e00bc0fe..c48a572e422efd413b6cd589d0205e6aae5107d8 100644 --- a/beat/backend/python/test/test_loop_executor.py +++ b/beat/backend/python/test/test_loop_executor.py @@ -37,31 +37,28 @@ # Tests for experiment execution import os -import unittest -import zmq -import tempfile import shutil -import simplejson -import numpy as np +import tempfile +import unittest from copy import deepcopy -from ..execution import AlgorithmExecutor -from ..execution import LoopExecutor -from ..execution import MessageHandler -from ..execution import LoopMessageHandler -from ..exceptions import RemoteException +import numpy as np +import simplejson +import zmq from ..algorithm import Algorithm -from ..dataformat import DataFormat from ..data import CachedDataSink from ..data import CachedDataSource - +from ..dataformat import DataFormat +from ..exceptions import RemoteException +from ..execution import AlgorithmExecutor +from ..execution import LoopExecutor +from ..execution import LoopMessageHandler +from ..execution import MessageHandler from ..helpers import convert_experiment_configuration_to_container - from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_message_handler.py b/beat/backend/python/test/test_message_handler.py index 5930219121862de0ac33fd691aa2aa5cb0df0a34..5f1c7b12ff48d2c335957e6c44be969c9219a5cb 100644 --- a/beat/backend/python/test/test_message_handler.py +++ b/beat/backend/python/test/test_message_handler.py @@ -34,24 +34,23 @@ ################################################################################### -import unittest -import zmq -import os import glob +import os import tempfile +import unittest + import numpy as np +import zmq -from ..execution import MessageHandler -from ..dataformat import DataFormat -from ..data import RemoteException +from ..data import CachedDataSink from ..data import CachedDataSource from ..data import RemoteDataSource -from ..data import CachedDataSink +from ..data import RemoteException from ..data_loaders import DataLoader - -from .mocks import CrashingDataSource +from ..dataformat import DataFormat +from ..execution import MessageHandler from . import prefix - +from .mocks import CrashingDataSource # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_outputs.py b/beat/backend/python/test/test_outputs.py index 748e03d1212dc325c9d4f1fbb9333f9960eafc60..7e6120820f1a80edc499cddf08d3ef1dda8c5413 100644 --- a/beat/backend/python/test/test_outputs.py +++ b/beat/backend/python/test/test_outputs.py @@ -34,18 +34,18 @@ ################################################################################### -import six -import numpy import nose.tools +import numpy +import six -from .mocks import MockDataSink - -from ..outputs import Output, OutputList, SynchronizationListener -from ..dataformat import DataFormat from beat.backend.python.baseformat import baseformat +from ..dataformat import DataFormat +from ..outputs import Output +from ..outputs import OutputList +from ..outputs import SynchronizationListener from . import prefix - +from .mocks import MockDataSink # ---------------------------------------------------------- diff --git a/beat/backend/python/test/test_protocoltemplate.py b/beat/backend/python/test/test_protocoltemplate.py index b6162a0b6cd451ff7703f9acb338fdeae0b1dc58..cf5454f7af416f3b6f7b4de1e1c5f89e5dcb6d10 100644 --- a/beat/backend/python/test/test_protocoltemplate.py +++ b/beat/backend/python/test/test_protocoltemplate.py @@ -35,11 +35,10 @@ import nose.tools -from ..protocoltemplate import ProtocolTemplate +from ..protocoltemplate import ProtocolTemplate from . import prefix - # ---------------------------------------------------------- diff --git a/beat/backend/python/utils.py b/beat/backend/python/utils.py index b98058876838416d08f5a902821504de5fe1a058..3c74478100157c3c9dc6d5f21f18c67791d7bfe6 100644 --- a/beat/backend/python/utils.py +++ b/beat/backend/python/utils.py @@ -42,16 +42,16 @@ utils This module implements helper classes and functions. """ +import collections import os import shutil -import collections + import numpy import simplejson import six from . import hash - # ---------------------------------------------------------- diff --git a/doc/conf.py b/doc/conf.py index d085a898b9ad46713a84399ae89232d4b2a797b1..ac1169be42c642fcc9dea5e5279811c55637e8c7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -2,29 +2,38 @@ # -*- coding: utf-8 -*- import os +import time + import pkg_resources +# For inter-documentation mapping: +from bob.extension.utils import link_documentation +from bob.extension.utils import load_requirements + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +import sphinx_rtd_theme + # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = '1.3' +needs_sphinx = "1.3" # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.ifconfig', - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx.ext.doctest', - 'sphinx.ext.graphviz', - 'sphinx.ext.intersphinx', - 'sphinx.ext.napoleon', - 'sphinx.ext.viewcode', - 'sphinx.ext.mathjax', - #'matplotlib.sphinxext.plot_directive' - ] + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.ifconfig", + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.doctest", + "sphinx.ext.graphviz", + "sphinx.ext.intersphinx", + "sphinx.ext.napoleon", + "sphinx.ext.viewcode", + "sphinx.ext.mathjax", +] # Be picky about warnings nitpicky = True @@ -33,13 +42,13 @@ nitpicky = True nitpick_ignore = [] # Allows the user to override warnings from a separate file -if os.path.exists('nitpick-exceptions.txt'): - for line in open('nitpick-exceptions.txt'): +if os.path.exists("nitpick-exceptions.txt"): + for line in open("nitpick-exceptions.txt"): if line.strip() == "" or line.startswith("#"): continue dtype, target = line.split(None, 1) target = target.strip() - try: # python 2.x + try: # python 2.x target = unicode(target) except NameError: pass @@ -55,25 +64,25 @@ autosummary_generate = True numfig = True # If we are on OSX, the 'dvipng' path maybe different -dvipng_osx = '/Library/TeX/texbin/dvipng' -if os.path.exists(dvipng_osx): pngmath_dvipng = dvipng_osx +dvipng_osx = "/Library/TeX/texbin/dvipng" +if os.path.exists(dvipng_osx): + pngmath_dvipng = dvipng_osx # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'beat.backend.python' -import time -copyright = u'%s, Idiap Research Institute' % time.strftime('%Y') +project = u"beat.backend.python" +copyright = u"%s, Idiap Research Institute" % time.strftime("%Y") # Grab the setup entry distribution = pkg_resources.require(project)[0] @@ -89,123 +98,120 @@ release = distribution.version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['links.rst'] +exclude_patterns = ["links.rst"] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # Some variables which are useful for generated material -project_variable = project.replace('.', '_') -short_description = u'BEAT Platform (Python backend)' -owner = [u'Idiap Research Institute'] +project_variable = project.replace(".", "_") +short_description = u"BEAT Platform (Python backend)" +owner = [u"Idiap Research Institute"] # -- Options for HTML output --------------------------------------------------- -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -import sphinx_rtd_theme -html_theme = 'sphinx_rtd_theme' +html_theme = "sphinx_rtd_theme" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = project_variable +# html_short_title = project_variable # The name of an image file (relative to this directory) to place at the top # of the sidebar. -html_logo = 'img/logo.png' +html_logo = "img/logo.png" # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -html_favicon = 'img/favicon.ico' +html_favicon = "img/favicon.ico" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -#html_static_path = ['_static'] +# html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = project_variable + u'_doc' +htmlhelp_basename = project_variable + u"_doc" # -- Post configuration -------------------------------------------------------- @@ -215,53 +221,57 @@ rst_epilog = """ .. |project| replace:: BEAT .. |version| replace:: %s .. |current-year| date:: %%Y -""" % (version,) +""" % ( + version, +) # Default processing flags for sphinx -autoclass_content = 'class' -autodoc_member_order = 'bysource' +autoclass_content = "class" +autodoc_member_order = "bysource" autodoc_default_flags = [ - 'members', - 'undoc-members', - 'show-inheritance', - ] + "members", + "undoc-members", + "show-inheritance", +] + +if "BOB_DOCUMENTATION_SERVER" not in os.environ: + # notice we need to overwrite this for BEAT projects - defaults from Bob are + # not OK + os.environ[ + "BOB_DOCUMENTATION_SERVER" + ] = "https://www.idiap.ch/software/beat/docs/beat/%(name)s/%(version)s/|https://www.idiap.ch/software/beat/docs/beat/%(name)s/master/" -if not 'BOB_DOCUMENTATION_SERVER' in os.environ: - # notice we need to overwrite this for BEAT projects - defaults from Bob are - # not OK - os.environ['BOB_DOCUMENTATION_SERVER'] = "https://www.idiap.ch/software/beat/docs/beat/%(name)s/%(version)s/|https://www.idiap.ch/software/beat/docs/beat/%(name)s/master/" - -# For inter-documentation mapping: -from bob.extension.utils import link_documentation, load_requirements sphinx_requirements = "extra-intersphinx.txt" if os.path.exists(sphinx_requirements): - intersphinx_mapping = link_documentation( - additional_packages=['python','numpy'] + \ - load_requirements(sphinx_requirements)) + intersphinx_mapping = link_documentation( + additional_packages=["python", "numpy"] + load_requirements(sphinx_requirements) + ) else: - intersphinx_mapping = link_documentation() + intersphinx_mapping = link_documentation() # Adds simplejson, pyzmq links -intersphinx_mapping['http://simplejson.readthedocs.io/en/stable/'] = None -intersphinx_mapping['http://pyzmq.readthedocs.io/en/stable/'] = None +intersphinx_mapping["http://simplejson.readthedocs.io/en/stable/"] = None +intersphinx_mapping["http://pyzmq.readthedocs.io/en/stable/"] = None # We want to remove all private (i.e. _. or __.__) members # that are not in the list of accepted functions -accepted_private_functions = ['__array__'] +accepted_private_functions = ["__array__"] + def member_function_test(app, what, name, obj, skip, options): - # test if we have a private function - if len(name) > 1 and name[0] == '_': - # test if this private function should be allowed - if name not in accepted_private_functions: - # omit private functions that are not in the list of accepted private - # functions - return skip - else: - # test if the method is documented - if not hasattr(obj, '__doc__') or not obj.__doc__: - return skip - return False + # test if we have a private function + if len(name) > 1 and name[0] == "_": + # test if this private function should be allowed + if name not in accepted_private_functions: + # omit private functions that are not in the list of accepted private + # functions + return skip + else: + # test if the method is documented + if not hasattr(obj, "__doc__") or not obj.__doc__: + return skip + return False + def setup(app): - app.connect('autodoc-skip-member', member_function_test) + app.connect("autodoc-skip-member", member_function_test) diff --git a/doc/links.rst b/doc/links.rst index 534225523ed6edd5d837d5b92106b03a4a2879af..5b8e30ff3bc73d90896e3436e8fb6371b36a2d13 100644 --- a/doc/links.rst +++ b/doc/links.rst @@ -28,4 +28,4 @@ .. 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. -.. _BEAT documentation: https://www.idiap.ch/software/beat/documentation \ No newline at end of file +.. _BEAT documentation: https://www.idiap.ch/software/beat/documentation diff --git a/setup.py b/setup.py index 24366082c2f43465d1fe0d8289a03e62e0f429f1..dd7b83f439ec57df4f4a6318c8a17858a934bd1c 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,8 @@ ################################################################################### # Define package version -from setuptools import setup, find_packages +from setuptools import find_packages +from setuptools import setup version = open("version.txt").read().rstrip() diff --git a/version.txt b/version.txt index ed60f001ccb3a260983c6f307a4739efd7c51b08..bf32221d6ec631d3e42a998ccdb5b97c65eeed38 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.7.11b0 \ No newline at end of file +1.7.11b0