diff --git a/beat/backend/python/algorithm.py b/beat/backend/python/algorithm.py index 883c7e7eb62239cfc0d7d352d7e3ebb183b32aa1..217cf322942a8d5b6f51ba435602a1688f98fb1b 100644 --- a/beat/backend/python/algorithm.py +++ b/beat/backend/python/algorithm.py @@ -367,8 +367,7 @@ class Runner(object): return loader.run(self.obj, "read", self.exc, inputs) def __getattr__(self, key): - """Returns an attribute of the algorithm - only called at last resort - """ + """Returns an attribute of the algorithm - only called at last resort""" return getattr(self.obj, key) @@ -522,8 +521,7 @@ class Algorithm(object): self._update_dataformat_cache(entry["type"], dataformat_cache) def _load_dataformats(self, dataformat_cache): - """Makes sure we can load all requested formats - """ + """Makes sure we can load all requested formats""" for group in self.groups: self._update_dataformat_cache_for_group(group["inputs"], dataformat_cache) @@ -546,8 +544,7 @@ class Algorithm(object): self._update_dataformat_cache(result_type, dataformat_cache) def _convert_parameter_types(self): - """Converts types to numpy equivalents, checks defaults, ranges and choices - """ + """Converts types to numpy equivalents, checks defaults, ranges and choices""" def _try_convert(name, tp, value, desc): try: @@ -637,8 +634,7 @@ class Algorithm(object): @property def name(self): - """The name of this object - """ + """The name of this object""" return self._name or "__unnamed_algorithm__" @name.setter @@ -680,7 +676,7 @@ class Algorithm(object): @property def is_autonomous(self): - """ Returns whether the algorithm is in the autonomous category""" + """Returns whether the algorithm is in the autonomous category""" return self.type in [ Algorithm.AUTONOMOUS, Algorithm.AUTONOMOUS_LOOP_EVALUATOR, @@ -689,7 +685,7 @@ class Algorithm(object): @property def is_sequential(self): - """ Returns whether the algorithm is in the sequential category""" + """Returns whether the algorithm is in the sequential category""" return self.type in [ Algorithm.SEQUENTIAL, Algorithm.SEQUENTIAL_LOOP_EVALUATOR, diff --git a/beat/backend/python/baseformat.py b/beat/backend/python/baseformat.py index 9e8267f7c4c37d99d529760764dc5e43873c6b8a..4ec15de6c131c8fa5e95cdd2ed9c78e4d746a6de 100644 --- a/beat/backend/python/baseformat.py +++ b/beat/backend/python/baseformat.py @@ -127,8 +127,7 @@ def setup_scalar(formatname, attrname, dtype, value, casting, add_defaults): class _protected_str_ndarray(numpy.ndarray): - """Increments :py:class:`numpy.ndarray` so that item assignment is checked - """ + """Increments :py:class:`numpy.ndarray` so that item assignment is checked""" def __setitem__(self, key, value): """First checks for conformance and then assigns""" @@ -142,14 +141,15 @@ class _protected_str_ndarray(numpy.ndarray): class _protected_ndarray(numpy.ndarray): - """Increments :py:class:`numpy.ndarray` so that item assignment is checked - """ + """Increments :py:class:`numpy.ndarray` so that item assignment is checked""" def __setitem__(self, key, value): """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_) @@ -221,7 +221,12 @@ def setup_array(formatname, attrname, shape, dtype, value, casting, add_defaults "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),) + % ( + attrname, + formatname, + retval.ndim, + len(shape), + ) ) for i, d in enumerate(retval.shape): @@ -653,8 +658,7 @@ class baseformat(object): return True def __str__(self): - """Stringified representation for this object, uses :py:meth:`as_dict`. - """ + """Stringified representation for this object, uses :py:meth:`as_dict`.""" return str(self.as_dict()) diff --git a/beat/backend/python/data.py b/beat/backend/python/data.py index b38b8b1b668abafde6a8902c941f22344308a735..bcd4b00bc74a2b1d99d3bbc985b4c8e07a26b794 100644 --- a/beat/backend/python/data.py +++ b/beat/backend/python/data.py @@ -391,9 +391,9 @@ class CachedDataSource(DataSource): def check_consistency(data_filenames, checksum_filenames): """Perform some sanity check on the data/checksum files on disk: - 1. One-to-one mapping between data and checksum files - 2. Checksum comparison between hash(data) and checksum files - 3. Contiguous indices if they are present + 1. One-to-one mapping between data and checksum files + 2. Checksum comparison between hash(data) and checksum files + 3. Contiguous indices if they are present """ # Make sure that we have a perfect match between data files and @@ -995,8 +995,7 @@ class CachedDataSink(DataSink): return True def close(self): - """Closes the data sink - """ + """Closes the data sink""" if self.data_file is not None: self.data_file.close() @@ -1012,8 +1011,10 @@ class CachedDataSink(DataSink): if self.last_written_data_index is None: message = "No data written" else: - message = "No enough data written: last written {} vs end {}".format( - self.last_written_data_index, self.end_index + message = ( + "No enough data written: last written {} vs end {}".format( + self.last_written_data_index, self.end_index + ) ) logger.warning("Removing cache files: {}".format(message)) @@ -1044,8 +1045,7 @@ class CachedDataSink(DataSink): return True def __del__(self): - """Make sure the files are closed when the object is deleted - """ + """Make sure the files are closed when the object is deleted""" self.close() def write(self, data, start_data_index, end_data_index): @@ -1209,8 +1209,7 @@ def load_data_index_db(cache_root, hash_path): def _foundCommonIndices(lst): - """Returns the list of common indices, given a list of list of indices - """ + """Returns the list of common indices, given a list of list of indices""" if lst == []: return lst @@ -1224,7 +1223,7 @@ def _foundCommonIndices(lst): def foundSplitRanges(lst, n_split): """Splits a list of lists of indices into n splits for parallelization - purposes. """ + purposes.""" if [] in lst or lst == []: return [] diff --git a/beat/backend/python/data_loaders.py b/beat/backend/python/data_loaders.py index adbc41c1fc50695de72331410aa5eed2e9eee839..e59ebb8791e1ec3eb57806ed3d6985f433080228 100644 --- a/beat/backend/python/data_loaders.py +++ b/beat/backend/python/data_loaders.py @@ -261,7 +261,7 @@ class DataLoader(object): return self.nb_data_units def view(self, input_name, index): - """ Returns the view associated with this data loader + """Returns the view associated with this data loader Parameters: input_name (str): Name of the input to get data from diff --git a/beat/backend/python/database.py b/beat/backend/python/database.py index d9af1c2c7f7cc9540a7e5bc17fff0fe88f217f5b..b2a39c7e48c4bd15b0a2e9233f922e2146cbb183 100644 --- a/beat/backend/python/database.py +++ b/beat/backend/python/database.py @@ -328,8 +328,7 @@ class Database(object): @property def name(self): - """The full (valid) name of this database - """ + """The full (valid) name of this database""" return self._name or "__unnamed_database__" @name.setter diff --git a/beat/backend/python/dataformat.py b/beat/backend/python/dataformat.py index de44081b0cb9a54ff7f250120866232ad6aa1038..5849617c81f15f68babc65d4a846f4c3096b63e4 100644 --- a/beat/backend/python/dataformat.py +++ b/beat/backend/python/dataformat.py @@ -275,8 +275,7 @@ class DataFormat(object): @property def extends(self): - """If this dataformat extends another one, this is it, otherwise ``None`` - """ + """If this dataformat extends another one, this is it, otherwise ``None``""" return self.data.get("#extends") @property diff --git a/beat/backend/python/execution/algorithm.py b/beat/backend/python/execution/algorithm.py index abda1faee489875756dfd08e92ce6d8d1a5ae55d..dd03689c493a6d3e8bae037ae79894b171cf1553 100644 --- a/beat/backend/python/execution/algorithm.py +++ b/beat/backend/python/execution/algorithm.py @@ -88,7 +88,7 @@ class AlgorithmExecutor(object): may greatly speed-up library loading times as libraries that are already loaded may be re-used. If you use this parameter, you must guarantee that the cache is refreshed as appropriate in case the - underlying libraries change. """ + underlying libraries change.""" def __init__( self, @@ -207,8 +207,7 @@ class AlgorithmExecutor(object): return retval def process(self): - """Executes the user algorithm code using the current interpreter. - """ + """Executes the user algorithm code using the current interpreter.""" if self.algorithm.is_autonomous: if self.analysis: @@ -322,7 +321,6 @@ class AlgorithmExecutor(object): @property def analysis(self): - """A boolean that indicates if the current block is an analysis block - """ + """A boolean that indicates if the current block is an analysis block""" return "result" in self.data diff --git a/beat/backend/python/execution/database.py b/beat/backend/python/execution/database.py index cd5fbe688d4b1175d960398177aece9d232ffe25..afcc279b8d3bbeedd18a9180fc03594a6fa4aa80 100644 --- a/beat/backend/python/execution/database.py +++ b/beat/backend/python/execution/database.py @@ -200,13 +200,13 @@ class DBExecutor(object): self.message_handler.set_data_sources(self.data_sources) def process(self): - """ Starts the message handler""" + """Starts the message handler""" self.message_handler.start() @property def address(self): - """ Address of the message handler""" + """Address of the message handler""" return self.message_handler.address diff --git a/beat/backend/python/execution/loop.py b/beat/backend/python/execution/loop.py index 259c7147c4260604a1911939daf35d73e960d66b..51d9389ba3e032a11218f06fa8232d45429ebaab 100644 --- a/beat/backend/python/execution/loop.py +++ b/beat/backend/python/execution/loop.py @@ -60,12 +60,12 @@ logger = logging.getLogger(__name__) class LoopChannel(object): - """ The LoopChannel class is a direct communication link between a loop + """The LoopChannel class is a direct communication link between a loop using algorithm and the loop itself """ def __init__(self, socket): - """ Constructor + """Constructor Parameters: socket (:py:class:`zmq.Socket`): Socket for zmq communication @@ -74,7 +74,7 @@ class LoopChannel(object): self.socket = socket def setup(self, algorithm, prefix): - """ Setup the channel internals + """Setup the channel internals Parameters: algorithm (:py:class:`.algorithm.Algorithm`) : algorithm for which @@ -90,7 +90,7 @@ class LoopChannel(object): self.answer_data_format = DataFormat(prefix, answer_format_name) def validate(self, hypothesis): - """ This method will request validation for the hypothesis passed in + """This method will request validation for the hypothesis passed in parameter. Parameters: @@ -147,7 +147,7 @@ class LoopExecutor(object): may greatly speed-up library loading times as libraries that are already loaded may be re-used. If you use this parameter, you must guarantee that the cache is refreshed as appropriate in case the - underlying libraries change. """ + underlying libraries change.""" def __init__( self, @@ -246,8 +246,7 @@ class LoopExecutor(object): return retval def process(self): - """Executes the user algorithm code using the current interpreter. - """ + """Executes the user algorithm code using the current interpreter.""" self.message_handler.start() @@ -278,7 +277,7 @@ class LoopExecutor(object): @property def address(self): - """ Address of the message handler""" + """Address of the message handler""" return self.message_handler.address diff --git a/beat/backend/python/execution/messagehandlers.py b/beat/backend/python/execution/messagehandlers.py index 5ea36a5577a92a33ef0115f92c265c2c4bb4af7f..fcebb94e6f254e8a3886a0c2f8228ae5f655fc99 100644 --- a/beat/backend/python/execution/messagehandlers.py +++ b/beat/backend/python/execution/messagehandlers.py @@ -343,7 +343,7 @@ class MessageHandler(threading.Thread): class LoopMessageHandler(MessageHandler): - """ Custom message handler that will handle validation request from loop + """Custom message handler that will handle validation request from loop using algorithm """ @@ -363,7 +363,7 @@ class LoopMessageHandler(MessageHandler): self.executor = None def setup(self, algorithm, prefix): - """ Setup the loop internals + """Setup the loop internals Parameters: algorithm (:py:class:`.algorithm.Algorithm`) : algorithm for which @@ -379,7 +379,7 @@ class LoopMessageHandler(MessageHandler): self.answer_data_format = DataFormat(prefix, answer_format_name) def set_executor(self, executor): - """ Set the executor for validation + """Set the executor for validation Parameters: executor (:py:class:`.loop.LoopExecutor`) : Loop executor @@ -387,7 +387,7 @@ class LoopMessageHandler(MessageHandler): self.executor = executor def validate(self, result): - """ Validate the result received and send back a boolean answer about + """Validate the result received and send back a boolean answer about the validity of it as well as additional data for the loop using algorithm to process @@ -411,7 +411,7 @@ class LoopMessageHandler(MessageHandler): self.socket.send(data.pack()) def write(self, processor_output_name, end_data_index): - """ Trigger a write on the output""" + """Trigger a write on the output""" processor_output_name = processor_output_name.decode("utf-8") end_data_index = end_data_index.decode("utf-8") diff --git a/beat/backend/python/hash.py b/beat/backend/python/hash.py index c6a483bccf997a8fcb40132c49562575bb009312..f15076e189831c6484bfb6e0355de4f419a16a3f 100644 --- a/beat/backend/python/hash.py +++ b/beat/backend/python/hash.py @@ -94,7 +94,7 @@ def _compact(text): def toPath(hash, suffix=".data"): - """ Returns the path on disk which corresponds to the hash given. + """Returns the path on disk which corresponds to the hash given. Parameters: hash (str): Hash from which the path is generated diff --git a/beat/backend/python/inputs.py b/beat/backend/python/inputs.py index 84cc6623e8300e867dd22be0e1172604bf08bc46..26bba4afaf468d7535662d1168dea6f6e6b37163 100644 --- a/beat/backend/python/inputs.py +++ b/beat/backend/python/inputs.py @@ -50,8 +50,7 @@ import six def first(iterable, default=None): - """Get the first item of a list or default - """ + """Get the first item of a list or default""" return next(iter(iterable), default) @@ -113,8 +112,7 @@ class Input(object): self.data_source = data_source def isDataUnitDone(self): - """Indicates if the current data unit will change at the next iteration - """ + """Indicates if the current data unit will change at the next iteration""" if (self.data_index_end >= 0) and (self.group.last_data_index == -1): return True diff --git a/beat/backend/python/protocoltemplate.py b/beat/backend/python/protocoltemplate.py index a5ea0bd101c8daf7c8f99bb15cdb0cd490157bee..7840a4b0597aecffcb9484e31372045f361768d4 100644 --- a/beat/backend/python/protocoltemplate.py +++ b/beat/backend/python/protocoltemplate.py @@ -167,8 +167,7 @@ class ProtocolTemplate(object): @property def name(self): - """Returns the name of this object - """ + """Returns the name of this object""" return self._name or "__unnamed_protocoltemplate__" @name.setter diff --git a/beat/backend/python/stats.py b/beat/backend/python/stats.py index 8f6495e87c0b8f91f32c9cbb9f47272e6ff49cf1..33354b778dc4c18e97136933988fd22b502c385e 100644 --- a/beat/backend/python/stats.py +++ b/beat/backend/python/stats.py @@ -95,7 +95,11 @@ def io_statistics(configuration, input_list=None, output_list=None): hash = configuration["outputs"][output.name]["path"].replace("/", "") files.append( - dict(hash=hash, size=size, blocks=output.nb_data_blocks_written,) + dict( + hash=hash, + size=size, + blocks=output.nb_data_blocks_written, + ) ) # Result diff --git a/beat/backend/python/utils.py b/beat/backend/python/utils.py index 3c74478100157c3c9dc6d5f21f18c67791d7bfe6..b60d101c737cb8df6c90649a54a0aa05077f7234 100644 --- a/beat/backend/python/utils.py +++ b/beat/backend/python/utils.py @@ -56,8 +56,7 @@ from . import hash def hashed_or_simple(prefix, what, path, suffix=".json"): - """Returns a hashed path or simple path depending on where the resource is - """ + """Returns a hashed path or simple path depending on where the resource is""" username, right_bit = path.split("/", 1) hashed_prefix = hash.toUserPath(username)