diff --git a/beat/backend/python/algorithm.py b/beat/backend/python/algorithm.py index 217cf322942a8d5b6f51ba435602a1688f98fb1b..cc249c40714e627b0b7a70dd64a62a73e5a8c5ae 100644 --- a/beat/backend/python/algorithm.py +++ b/beat/backend/python/algorithm.py @@ -77,7 +77,6 @@ class Storage(utils.CodeStorage): asset_folder = "algorithms" def __init__(self, prefix, name, language=None): - if name.count("/") != 2: raise RuntimeError("invalid algorithm name: `%s'" % name) @@ -116,7 +115,6 @@ class Runner(object): """ def __init__(self, module, obj_name, algorithm, exc=None): - try: class_ = getattr(module, obj_name) except Exception: @@ -162,7 +160,6 @@ class Runner(object): retval = dict() for key, definition in algo_parameters.items(): - if key in parameters: try: value = self.algorithm.clean_parameter(key, parameters[key]) @@ -443,7 +440,6 @@ class Algorithm(object): dataformat_klass = dataformat.DataFormat def __init__(self, prefix, name, dataformat_cache=None, library_cache=None): - self._name = None self.storage = None self.prefix = prefix @@ -535,7 +531,6 @@ class Algorithm(object): self._update_dataformat_cache_for_group(group["loop"], dataformat_cache) if self.results: - for name, result in self.results.items(): result_type = result["type"] # results can only contain base types and plots therefore, only @@ -621,13 +616,10 @@ class Algorithm(object): ) def _load_libraries(self, library_cache): - # all used libraries must be loadable; cannot use self as a library if self.uses: - for name, value in self.uses.items(): - self.libraries[value] = library_cache.setdefault( value, library.Library(self.prefix, value, library_cache) ) diff --git a/beat/backend/python/baseformat.py b/beat/backend/python/baseformat.py index 4ec15de6c131c8fa5e95cdd2ed9c78e4d746a6de..42cabaac8d6edee65e1a0e8ec9fe13e879c26f28 100644 --- a/beat/backend/python/baseformat.py +++ b/beat/backend/python/baseformat.py @@ -101,7 +101,6 @@ def setup_scalar(formatname, attrname, dtype, value, casting, add_defaults): """ if hasattr(dtype, "type") and issubclass(dtype.type, numpy.generic): - if value is None: # use the default for the type return dtype.type() else: @@ -283,7 +282,6 @@ def pack_array(dtype, value, fd): fd.write(struct.pack(shape_format, *value.shape)) 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 @@ -414,7 +412,6 @@ def unpack_scalar(dtype, fd): """ if hasattr(dtype, "type") and issubclass(dtype.type, numpy.generic): - if issubclass(dtype.type, numpy.complexfloating): # complex data_format = ENDIANNESS + "2" + BINCODE[dtype] a = read_some(data_format, fd) @@ -448,7 +445,6 @@ class baseformat(object): """ def __init__(self, **kwargs): - self.from_dict(kwargs, casting="unsafe", add_defaults=True) def from_dict(self, data, casting="safe", add_defaults=False): @@ -523,7 +519,6 @@ class baseformat(object): retval = dict() for key in self._format: - v = getattr(self, key) if isinstance(self._format[key], list): @@ -577,7 +572,6 @@ class baseformat(object): """ for key in sorted(self._format.keys()): - # get the data type for this object dtype = getattr(self.__class__, key) @@ -620,7 +614,6 @@ class baseformat(object): return False for key in sorted(self._format.keys()): - # get the data type for this object dtype = getattr(self.__class__, key) this = getattr(self, key) diff --git a/beat/backend/python/database.py b/beat/backend/python/database.py index b2a39c7e48c4bd15b0a2e9233f922e2146cbb183..6cc419c88d231d4652e0b5e3502b1447d93a1ad6 100644 --- a/beat/backend/python/database.py +++ b/beat/backend/python/database.py @@ -78,7 +78,6 @@ class Storage(utils.CodeStorage): asset_folder = "databases" def __init__(self, prefix, name): - if name.count("/") != 1: raise RuntimeError("invalid database name: `%s'" % name) @@ -120,7 +119,6 @@ class Runner(object): """ def __init__(self, module, definition, prefix, root_folder, exc=None): - try: class_ = getattr(module, definition["view"]) except Exception: @@ -246,7 +244,6 @@ class Database(object): """ def __init__(self, prefix, name, dataformat_cache=None): - self._name = None self.prefix = prefix self.dataformats = {} # preloaded dataformats @@ -262,7 +259,6 @@ class Database(object): def _update_dataformat_cache(self, outputs, dataformat_cache): for key, value in outputs.items(): - if value in self.dataformats: continue @@ -678,7 +674,6 @@ class View(object): raise NotImplementedError def setup(self, root_folder, parameters, objs, start_index=None, end_index=None): - # Initialisation self.root_folder = root_folder self.parameters = parameters diff --git a/beat/backend/python/dataformat.py b/beat/backend/python/dataformat.py index 5849617c81f15f68babc65d4a846f4c3096b63e4..bd2fd851f6e674861b20a2343021ed7caa6bc280 100644 --- a/beat/backend/python/dataformat.py +++ b/beat/backend/python/dataformat.py @@ -71,7 +71,6 @@ class Storage(utils.Storage): asset_folder = "dataformats" def __init__(self, prefix, name): - if name.count("/") != 2: raise RuntimeError("invalid dataformat name: `%s'" % name) @@ -141,7 +140,6 @@ class DataFormat(object): """ def __init__(self, prefix, data, parent=None, dataformat_cache=None): - self._name = None self.storage = None self.resolved = None @@ -209,9 +207,7 @@ class DataFormat(object): """Tries to load a given dataformat from its relative path""" if isinstance(obj, six.string_types) and obj.find("/") != -1: # load it - if obj in dataformat_cache: # reuse - if dataformat_cache[obj] is None: # recursion detected return self @@ -244,7 +240,6 @@ class DataFormat(object): # ``self.resolved``. We treat the "#extends" property, which requires a # special handling, given its nature. if "#extends" in self.resolved: - ext = self.data["#extends"] self.referenced[ext] = maybe_load_format(self._name, ext, dataformat_cache) basetype = self.resolved["#extends"] @@ -325,7 +320,6 @@ class DataFormat(object): # create the converters for the class we're about to return for k, v in self.resolved.items(): - if isinstance(v, list): # it is an array attributes[k] = copy.deepcopy(v) if isinstance(v[-1], DataFormat): @@ -375,7 +369,6 @@ class DataFormat(object): @documentation.setter def documentation(self, value): - if not self._name: raise RuntimeError("dataformat has no name") diff --git a/beat/backend/python/execution/algorithm.py b/beat/backend/python/execution/algorithm.py index dd03689c493a6d3e8bae037ae79894b171cf1553..7e3eb8142b7ada5fad7cbc8cf68bf1b011664990 100644 --- a/beat/backend/python/execution/algorithm.py +++ b/beat/backend/python/execution/algorithm.py @@ -101,7 +101,6 @@ class AlgorithmExecutor(object): db_socket=None, loop_socket=None, ): - self.socket = socket self.db_socket = db_socket self.loop_socket = loop_socket diff --git a/beat/backend/python/execution/database.py b/beat/backend/python/execution/database.py index afcc279b8d3bbeedd18a9180fc03594a6fa4aa80..25b711d36851fd6c3f735c3bb37d70743f19313f 100644 --- a/beat/backend/python/execution/database.py +++ b/beat/backend/python/execution/database.py @@ -113,7 +113,6 @@ class DBExecutor(object): dataformat_cache=None, database_cache=None, ): - # Initialisation self.prefix = prefix self.databases = {} @@ -150,7 +149,6 @@ class DBExecutor(object): # Load the database if details["database"] not in self.databases: - if details["database"] in database_cache: # reuse db = database_cache[details["database"]] else: # load it diff --git a/beat/backend/python/execution/loop.py b/beat/backend/python/execution/loop.py index 51d9389ba3e032a11218f06fa8232d45429ebaab..4d637260115b8e66013955245bcad5d8a4fc430f 100644 --- a/beat/backend/python/execution/loop.py +++ b/beat/backend/python/execution/loop.py @@ -159,7 +159,6 @@ class LoopExecutor(object): cache_root="/cache", db_socket=None, ): - self._runner = None self.algorithm = None self.output_list = None diff --git a/beat/backend/python/execution/messagehandlers.py b/beat/backend/python/execution/messagehandlers.py index fcebb94e6f254e8a3886a0c2f8228ae5f655fc99..6e84e1e2f9af7fcf66804d8388776fa87d86c9aa 100644 --- a/beat/backend/python/execution/messagehandlers.py +++ b/beat/backend/python/execution/messagehandlers.py @@ -63,7 +63,6 @@ class MessageHandler(threading.Thread): def __init__( self, host_address, data_sources=None, kill_callback=None, context=None ): - super(MessageHandler, self).__init__() # An event unblocking a graceful stop @@ -124,7 +123,6 @@ class MessageHandler(threading.Thread): logger.debug("0MQ server thread started") while not self.stop.is_set(): # keep on - if self.must_kill.is_set(): if self.kill_callback is not None: self.kill_callback() @@ -135,7 +133,6 @@ class MessageHandler(threading.Thread): socks = dict(self.poller.poll(timeout)) if self.socket in socks and socks[self.socket] == zmq.POLLIN: - # incomming more = True parts = [] @@ -208,7 +205,6 @@ class MessageHandler(threading.Thread): logger.debug("0MQ server thread stopped") def _acknowledge(self): - logger.debug("send: ack") self.socket.send_string("ack") logger.debug("setting stop condition for 0MQ server thread") diff --git a/beat/backend/python/helpers.py b/beat/backend/python/helpers.py index 521bc4dcadf8f33d9e847eae4b4339c4177e5d58..5e706b7fa25b7c6b0b2ce32cc80684b309a99863 100644 --- a/beat/backend/python/helpers.py +++ b/beat/backend/python/helpers.py @@ -151,7 +151,6 @@ def create_inputs_from_configuration( databases=None, no_synchronisation_listeners=False, ): - views = {} input_list = InputList() data_loader_list = DataLoaderList() @@ -222,7 +221,6 @@ def create_inputs_from_configuration( ) for name, details in config["inputs"].items(): - input = None if details.get("database", None) is not None: @@ -340,7 +338,6 @@ def create_inputs_from_configuration( ) elif cache_access == AccessMode.LOCAL: - if algorithm.type == Algorithm.LEGACY: input = _create_local_input(details) @@ -389,7 +386,6 @@ def create_outputs_from_configuration( data_loaders=None, loop_socket=None, ): - data_sinks = [] output_list = OutputList() @@ -403,7 +399,6 @@ def create_outputs_from_configuration( output_config = config["outputs"] for name, details in output_config.items(): - synchronization_listener = None if "result" in config: diff --git a/beat/backend/python/inputs.py b/beat/backend/python/inputs.py index 26bba4afaf468d7535662d1168dea6f6e6b37163..2a6627f19c680319bf3e9255333659fa86272736 100644 --- a/beat/backend/python/inputs.py +++ b/beat/backend/python/inputs.py @@ -99,7 +99,6 @@ class Input(object): """ def __init__(self, name, data_format, data_source): - self.group = None self.name = str(name) self.data = None @@ -211,7 +210,6 @@ class InputGroup: """ def __init__(self, channel, synchronization_listener=None, restricted_access=True): - self._inputs = [] self.data_index = -1 # Lower index across all inputs self.data_index_end = -1 # Bigger index across all inputs @@ -222,7 +220,6 @@ class InputGroup: self.restricted_access = restricted_access def __getitem__(self, index): - if isinstance(index, six.string_types): return first([x for x in self._inputs if x.name == index]) elif isinstance(index, int): diff --git a/beat/backend/python/library.py b/beat/backend/python/library.py index db89e6934024c8c750b7949fd4d64e11f14b4fa6..882385e6082eadeb29f81196527ace52820f64ff 100644 --- a/beat/backend/python/library.py +++ b/beat/backend/python/library.py @@ -69,7 +69,6 @@ class Storage(utils.CodeStorage): asset_folder = "libraries" def __init__(self, prefix, name, language=None): - if name.count("/") != 2: raise RuntimeError("invalid library name: `%s'" % name) @@ -127,7 +126,6 @@ class Library(object): """ def __init__(self, prefix, name, library_cache=None): - self._name = None self.storage = None self.prefix = prefix @@ -186,7 +184,6 @@ class Library(object): retval = {} if self.uses is not None: - for name, value in self.uses.items(): retval[name] = dict( path=self.libraries[value].storage.code.path, @@ -219,7 +216,6 @@ class Library(object): @name.setter def name(self, value): - if self.data["language"] == "unknown": raise RuntimeError("library has no programming language set") diff --git a/beat/backend/python/outputs.py b/beat/backend/python/outputs.py index a0054c8c12dab26ff3582ee66ceee1c9638fb149..6e8e2f3763f074784a183a372320678dd090e908 100644 --- a/beat/backend/python/outputs.py +++ b/beat/backend/python/outputs.py @@ -102,7 +102,6 @@ class Output(object): def __init__( self, name, data_sink, synchronization_listener=None, force_start_index=0 ): - self.name = str(name) self.last_written_data_index = force_start_index - 1 self.nb_data_blocks_written = 0 @@ -250,7 +249,6 @@ class OutputList: self._outputs = [] def __getitem__(self, index): - if isinstance(index, six.string_types): try: return [x for x in self._outputs if x.name == index][0] diff --git a/beat/backend/python/protocoltemplate.py b/beat/backend/python/protocoltemplate.py index 7840a4b0597aecffcb9484e31372045f361768d4..6e98b79b09fb21a46e9a78e7e4b6aa281a845620 100644 --- a/beat/backend/python/protocoltemplate.py +++ b/beat/backend/python/protocoltemplate.py @@ -66,7 +66,6 @@ class Storage(utils.Storage): asset_folder = "protocoltemplates" def __init__(self, prefix, name): - if name.count("/") != 1: raise RuntimeError("invalid protocol template name: `%s'" % name) @@ -112,7 +111,6 @@ class ProtocolTemplate(object): """ def __init__(self, prefix, name, dataformat_cache=None): - self._name = None self.prefix = prefix self.dataformats = {} # preloaded dataformats @@ -151,9 +149,7 @@ class ProtocolTemplate(object): return for set_ in self.data["sets"]: - for key, value in set_["outputs"].items(): - if value in self.dataformats: continue diff --git a/beat/backend/python/scripts/databases_provider.py b/beat/backend/python/scripts/databases_provider.py index ea7e90cd19e185d2a901a05e8885295b4d490eba..5d4af2d8e2be0e567904bf63dd3ef45a5ab83d86 100644 --- a/beat/backend/python/scripts/databases_provider.py +++ b/beat/backend/python/scripts/databases_provider.py @@ -91,7 +91,6 @@ def process_traceback(tb, prefix): def main(arguments=None): - # Parse the command-line arguments if arguments is None: arguments = sys.argv[1:] @@ -170,7 +169,6 @@ def main(arguments=None): return 1 try: - # Check the dir if not os.path.exists(args["<dir>"]): raise IOError("Running directory `%s' not found" % args["<dir>"]) @@ -205,7 +203,7 @@ def main(arguments=None): dataformat_cache, database_cache, ) - except (MemoryError): + except MemoryError: raise except Exception as e: import traceback @@ -219,7 +217,7 @@ def main(arguments=None): try: dbexecutor.process() dbexecutor.wait() - except (MemoryError): + except MemoryError: raise except Exception as e: import traceback diff --git a/beat/backend/python/scripts/describe.py b/beat/backend/python/scripts/describe.py index 7bfc45635d61657f9c6d254b2a963694d8b26659..5894b4406ce10163a4f8521bdb12f2d1aa7af3fb 100644 --- a/beat/backend/python/scripts/describe.py +++ b/beat/backend/python/scripts/describe.py @@ -43,7 +43,6 @@ import simplejson def main(): - # resolve package name name = "environment" if len(sys.argv) > 1: diff --git a/beat/backend/python/scripts/execute.py b/beat/backend/python/scripts/execute.py index e12972d0e405fa8aaee96599b5654e126566622b..9bb3bc7c8c81255b80a7bf59636270b46d8fe3ad 100644 --- a/beat/backend/python/scripts/execute.py +++ b/beat/backend/python/scripts/execute.py @@ -135,7 +135,6 @@ def process_traceback(tb, prefix): def main(): - """ # This is an important outcome of this process and must be available # to different processing phases of this script diff --git a/beat/backend/python/scripts/index.py b/beat/backend/python/scripts/index.py index d40c20251f4ebf0a2027c0fbdf9260f2cf8de315..65df9af005f9cd60c664ae0ec2cd336a4aaf306d 100644 --- a/beat/backend/python/scripts/index.py +++ b/beat/backend/python/scripts/index.py @@ -73,7 +73,6 @@ from ..hash import toPath def main(arguments=None): - # Parse the command-line arguments if arguments is None: arguments = sys.argv[1:] @@ -162,7 +161,6 @@ def main(arguments=None): protocols = [args["<protocol>"]] for protocol in protocols: - if args["<set>"] is None: sets = database.set_names(protocol) else: diff --git a/beat/backend/python/scripts/loop_execute.py b/beat/backend/python/scripts/loop_execute.py index 24b142fdcf066bb2d4b8c39751415d881a3e4905..cc0bc59c524c3e35bfdd10a397a41e596b138c5d 100644 --- a/beat/backend/python/scripts/loop_execute.py +++ b/beat/backend/python/scripts/loop_execute.py @@ -91,7 +91,6 @@ def process_traceback(tb, prefix): def main(arguments=None): - # Parse the command-line arguments if arguments is None: arguments = sys.argv[1:] @@ -189,7 +188,7 @@ def main(arguments=None): cache_root=args["<cache>"], db_socket=db_socket, ) - except (MemoryError): + except MemoryError: raise except Exception as e: import traceback @@ -234,7 +233,7 @@ def main(arguments=None): loop_executor.process() loop_executor.wait() loop_executor.close() - except (MemoryError): + except MemoryError: raise except Exception as e: import traceback diff --git a/beat/backend/python/test/test_data_loaders.py b/beat/backend/python/test/test_data_loaders.py index a5d7795fefe238a573ff01156688caba5480f273..d4763710f6c100ac0a30987033db2993c0b378fb 100644 --- a/beat/backend/python/test/test_data_loaders.py +++ b/beat/backend/python/test/test_data_loaders.py @@ -115,7 +115,6 @@ class DataLoaderTest(DataLoaderBaseTest): self.assertTrue(data_loader.view("unknown", 0) is None) def test_one_input(self): - # Setup self.writeData("input1", [(0, 0), (1, 1), (2, 2)], 1000) @@ -229,7 +228,6 @@ class DataLoaderTest(DataLoaderBaseTest): self.assertTrue(view is None) def test_two_synchronized_inputs(self): - # Setup self.writeData("input1", [(0, 0), (1, 1), (2, 2), (3, 3)], 1000) self.writeData("input2", [(0, 1), (2, 3)], 2000) @@ -456,7 +454,6 @@ class DataLoaderTest(DataLoaderBaseTest): self.assertTrue(view is None) def test_two_desynchronized_inputs(self): - # Setup self.writeData("input1", [(0, 2), (3, 3)], 1000) self.writeData("input2", [(0, 1), (2, 3)], 2000) diff --git a/beat/backend/python/test/test_database.py b/beat/backend/python/test/test_database.py index 84aff605ab9b871d729ea21f2a5d09f573cc86b2..1b84a14ff4ec794a0c2c9d6c63c3746a4cc8fd95 100644 --- a/beat/backend/python/test/test_database.py +++ b/beat/backend/python/test/test_database.py @@ -46,7 +46,6 @@ INTEGERS_DBS = ["integers_db/{}".format(i) for i in range(1, 3)] def load(database_name): - database = Database(prefix, database_name) nose.tools.assert_true(database.valid, "\n * %s" % "\n * ".join(database.errors)) return database @@ -56,7 +55,6 @@ def load(database_name): def test_load_valid_database(): - for db_name in INTEGERS_DBS: yield load_valid_database, db_name @@ -72,13 +70,11 @@ def load_valid_database(db_name): def test_load_protocol_with_one_set(): - for db_name in INTEGERS_DBS: yield load_valid_database, db_name def load_protocol_with_one_set(db_name): - database = load(db_name) protocol = database.protocol("double") @@ -98,13 +94,11 @@ def load_protocol_with_one_set(db_name): def test_load_protocol_with_two_sets(): - for db_name in INTEGERS_DBS: yield load_valid_database, db_name def load_protocol_with_two_sets(db_name): - database = load(db_name) protocol = database.protocol("two_sets") @@ -140,7 +134,6 @@ def test_view_definitions(): def compare_definitions(db_name, protocol_name, view_name): - db_1 = load("{}/1".format(db_name)) db_1_view_definition = db_1.view_definition(protocol_name, view_name) db_1_view_definition.pop("template") # Unused property diff --git a/beat/backend/python/test/test_format_array.py b/beat/backend/python/test/test_format_array.py index 8698a01144b38b8fd0c84dd77ab514f6b6d46ad1..75275e757cd7cf1648465a6adbf1063d8248d922 100644 --- a/beat/backend/python/test/test_format_array.py +++ b/beat/backend/python/test/test_format_array.py @@ -44,7 +44,6 @@ from . import prefix def doit(format): - df = DataFormat(prefix, format) nose.tools.assert_true(df.valid, df.errors) ftype = df.type @@ -130,7 +129,6 @@ def test_3d_array_of_integers(): def test_3d_array_of_integers_pack_unpack(): - df = DataFormat(prefix, "user/3d_array_of_integers/1") nose.tools.assert_true(df.valid, df.errors) ftype = df.type @@ -161,7 +159,6 @@ def test_3d_array_of_integers_pack_unpack(): def test_3d_array_of_floats_pack_unpack(): - df = DataFormat(prefix, "user/3d_array_of_floats/1") nose.tools.assert_true(df.valid, df.errors) ftype = df.type @@ -189,7 +186,6 @@ def test_3d_array_of_floats_pack_unpack(): def test_3d_array_of_complexes_pack_unpack(): - df = DataFormat(prefix, "user/3d_array_of_complexes/1") nose.tools.assert_true(df.valid, df.errors) ftype = df.type diff --git a/beat/backend/python/test/test_format_extends.py b/beat/backend/python/test/test_format_extends.py index faccc97c0372ffdb3144abf699f2d8c34248ca04..43c102e23feba51b15c4f9344b62cf6da034deb2 100644 --- a/beat/backend/python/test/test_format_extends.py +++ b/beat/backend/python/test/test_format_extends.py @@ -44,7 +44,6 @@ from . import prefix def doit(format): - df = DataFormat(prefix, format) nose.tools.assert_true(df.valid, "\n * %s" % "\n * ".join(df.errors)) ftype = df.type diff --git a/beat/backend/python/test/test_format_missing_attributes.py b/beat/backend/python/test/test_format_missing_attributes.py index 73490bc450b0152d1bfcefe5f860d36a7a7f3932..f56ef9c1744c9b236a038d6786d37720627483cf 100644 --- a/beat/backend/python/test/test_format_missing_attributes.py +++ b/beat/backend/python/test/test_format_missing_attributes.py @@ -43,7 +43,6 @@ from . import prefix def doit(format, data): - df = DataFormat(prefix, format) nose.tools.assert_true(df.valid, df.errors) obj = df.type() diff --git a/beat/backend/python/test/test_format_object.py b/beat/backend/python/test/test_format_object.py index 6e5322b044aacce92d797a76edf5a57a69abd645..ff7a32ba7bc8cdd131a0fb3b5e0fb20873b22ed0 100644 --- a/beat/backend/python/test/test_format_object.py +++ b/beat/backend/python/test/test_format_object.py @@ -44,7 +44,6 @@ from . import prefix def test_single_object(): - df = DataFormat(prefix, "user/single_object/1") nose.tools.assert_true(df.valid, df.errors) ftype = df.type @@ -78,7 +77,6 @@ def test_single_object(): def test_two_objects(): - df = DataFormat(prefix, "user/two_objects/1") nose.tools.assert_true(df.valid, df.errors) ftype = df.type @@ -119,7 +117,6 @@ def test_two_objects(): def test_hierarchy_of_objects(): - df = DataFormat(prefix, "user/hierarchy_of_objects/1") nose.tools.assert_true(df.valid, df.errors) ftype = df.type @@ -152,7 +149,6 @@ def test_hierarchy_of_objects(): def test_array_of_dict_objects(): - df = DataFormat(prefix, "user/1d_array_of_objects3/1") nose.tools.assert_true(df.valid, df.errors) ftype = df.type @@ -204,7 +200,6 @@ def test_array_of_dict_objects(): def test_array_of_dict_complex_objects(): - df = DataFormat(prefix, "user/1d_array_of_objects4/1") nose.tools.assert_true(df.valid, df.errors) ftype = df.type @@ -252,7 +247,6 @@ def test_array_of_dict_complex_objects(): def test_differs(): - df = DataFormat(prefix, "user/1d_array_of_objects4/1") nose.tools.assert_true(df.valid, df.errors) ftype = df.type diff --git a/beat/backend/python/test/test_format_simple.py b/beat/backend/python/test/test_format_simple.py index 7d0d4f24e3d665e42e0e193c861941b4742cee6b..dec7b7d8414f13f3a7845b83298d6d6a3efceeb6 100644 --- a/beat/backend/python/test/test_format_simple.py +++ b/beat/backend/python/test/test_format_simple.py @@ -44,7 +44,6 @@ from . import prefix def test_integers(): - df = DataFormat(prefix, "user/integers/1") nose.tools.assert_true(df.valid, df.errors) @@ -96,7 +95,6 @@ def test_integers(): @nose.tools.raises(TypeError) def test_integers_unsafe_cast(): - df = DataFormat(prefix, "user/integers/1") nose.tools.assert_true(df.valid, df.errors) @@ -161,7 +159,6 @@ def test_unsigned_integers(): @nose.tools.raises(TypeError) def test_unsigned_integers_unsafe_cast(): - df = DataFormat(prefix, "user/unsigned_integers/1") nose.tools.assert_true(df.valid, df.errors) @@ -176,7 +173,6 @@ def test_unsigned_integers_unsafe_cast(): @nose.tools.raises(AttributeError) def test_unsigned_integers_missing_attributes(): - df = DataFormat(prefix, "user/unsigned_integers/1") nose.tools.assert_true(df.valid, df.errors) diff --git a/beat/backend/python/test/test_format_unsafe_cast.py b/beat/backend/python/test/test_format_unsafe_cast.py index c1335625815329a03333e1fd733dba82066cb475..edfe8f86aae898dba7e0b8a53a776f5efb950b31 100644 --- a/beat/backend/python/test/test_format_unsafe_cast.py +++ b/beat/backend/python/test/test_format_unsafe_cast.py @@ -47,7 +47,6 @@ number42L = long(42) if six.PY2 else int(42) # noqa def doit(format, key, value): - df = DataFormat(prefix, format) nose.tools.assert_true(df.valid, df.errors) obj = df.type() @@ -239,7 +238,6 @@ def test_3d_array_of_objects(): def doit_array(format, key, value, index): - df = DataFormat(prefix, format) nose.tools.assert_true(df.valid, df.errors) obj = df.type() diff --git a/beat/backend/python/test/test_format_valid_cast.py b/beat/backend/python/test/test_format_valid_cast.py index 7be5e5a7a84fa8d7cd79d2b3e40a82be6cf3b401..870454315db01cb7f960ad44f14d152bce3584e6 100644 --- a/beat/backend/python/test/test_format_valid_cast.py +++ b/beat/backend/python/test/test_format_valid_cast.py @@ -44,7 +44,6 @@ from . import prefix def doit(format, key, value): - df = DataFormat(prefix, format) nose.tools.assert_true(df.valid, df.errors) obj = df.type() @@ -361,7 +360,6 @@ def test_3d_array_of_objects(): def doit_array(format, key, value, index): - df = DataFormat(prefix, format) nose.tools.assert_true(df.valid, df.errors) obj = df.type() diff --git a/beat/backend/python/test/test_hash.py b/beat/backend/python/test/test_hash.py index c9dbbd02b68316d18582a16bdfbf23d30f88bc25..95d9c16ad3a6c6b5b735ceebc6d8285f9e66e9cb 100644 --- a/beat/backend/python/test/test_hash.py +++ b/beat/backend/python/test/test_hash.py @@ -95,7 +95,6 @@ def test_unicode_hash(): def test_dataset_hash(): - h = hash.hashDataset("some_database/1", "some_protocol", " some_set") nose.tools.assert_is_not_none(h) nose.tools.assert_true(isinstance(h, str)) @@ -106,7 +105,6 @@ def test_dataset_hash(): def test_dataset_hash_repeatability(): - h1 = hash.hashDataset("some_database/1", "some_protocol", " some_set") h2 = hash.hashDataset("some_database/1", "some_protocol", " some_set") nose.tools.eq_(h1, h2) @@ -116,7 +114,6 @@ def test_dataset_hash_repeatability(): def test_different_dataset_hashes(): - h1 = hash.hashDataset("some_database/1", "some_protocol", " some_set1") h2 = hash.hashDataset("some_database/1", "some_protocol", " some_set2") nose.tools.assert_not_equal(h1, h2, "%r != %r" % (h1, h2)) diff --git a/beat/backend/python/test/test_loop_executor.py b/beat/backend/python/test/test_loop_executor.py index c48a572e422efd413b6cd589d0205e6aae5107d8..8188809302487f6d39a97dea847351bca2ba6c8f 100644 --- a/beat/backend/python/test/test_loop_executor.py +++ b/beat/backend/python/test/test_loop_executor.py @@ -143,7 +143,6 @@ class TestExecution(unittest.TestCase): del data_sink def process(self, algorithm_name, loop_algorithm_name): - self.writeData(CONFIGURATION, "in_main", [(0, 0), (1, 1), (2, 2), (3, 3)], 1000) self.writeData( CONFIGURATION["loop"], "in_loop", [(0, 0), (1, 1), (2, 2), (3, 3)], 1000 diff --git a/beat/backend/python/test/test_outputs.py b/beat/backend/python/test/test_outputs.py index 7e6120820f1a80edc499cddf08d3ef1dda8c5413..b56d12fb78ddfb93fbc812721c3af7cffe70a9a9 100644 --- a/beat/backend/python/test/test_outputs.py +++ b/beat/backend/python/test/test_outputs.py @@ -51,7 +51,6 @@ from .mocks import MockDataSink def test_creation_without_synchronization_listener(): - dataformat = DataFormat(prefix, "user/single_integer/1") nose.tools.assert_true(dataformat.valid, dataformat.errors) data_sink = MockDataSink(dataformat) @@ -68,7 +67,6 @@ def test_creation_without_synchronization_listener(): def test_creation_with_synchronization_listener(): - dataformat = DataFormat(prefix, "user/single_integer/1") nose.tools.assert_true(dataformat.valid, dataformat.errors) data_sink = MockDataSink(dataformat) @@ -88,7 +86,6 @@ def test_creation_with_synchronization_listener(): def test_data_creation(): - dataformat = DataFormat(prefix, "user/single_integer/1") nose.tools.assert_true(dataformat.valid, dataformat.errors) data_sink = MockDataSink(dataformat) @@ -105,7 +102,6 @@ def test_data_creation(): def test_data_writting(): - dataformat = DataFormat(prefix, "user/single_integer/1") nose.tools.assert_true(dataformat.valid, dataformat.errors) data_sink = MockDataSink(dataformat) @@ -135,7 +131,6 @@ def test_data_writting(): @nose.tools.raises(IOError) def test_data_writting_failure(): - dataformat = DataFormat(prefix, "user/single_integer/1") nose.tools.assert_true(dataformat.valid, dataformat.errors) data_sink = MockDataSink(dataformat) @@ -162,7 +157,6 @@ def test_data_writting_failure(): def test_data_delaying(): - dataformat = DataFormat(prefix, "user/single_integer/1") nose.tools.assert_true(dataformat.valid, dataformat.errors) data_sink = MockDataSink(dataformat) @@ -190,7 +184,6 @@ def test_data_delaying(): def test_data_writting_with_explicit_end_index(): - dataformat = DataFormat(prefix, "user/single_integer/1") nose.tools.assert_true(dataformat.valid, dataformat.errors) data_sink = MockDataSink(dataformat) @@ -220,7 +213,6 @@ def test_data_writting_with_explicit_end_index(): @nose.tools.raises(KeyError) def test_data_writting_failure_with_explicit_end_index_too_low(): - dataformat = DataFormat(prefix, "user/single_integer/1") nose.tools.assert_true(dataformat.valid, dataformat.errors) data_sink = MockDataSink(dataformat) @@ -243,7 +235,6 @@ def test_data_writting_failure_with_explicit_end_index_too_low(): @nose.tools.raises(KeyError) def test_data_writting_failure_with_explicit_end_index_too_high(): - dataformat = DataFormat(prefix, "user/single_integer/1") nose.tools.assert_true(dataformat.valid, dataformat.errors) data_sink = MockDataSink(dataformat) @@ -270,7 +261,6 @@ def test_list_creation(): def test_output_list_addition(): - integer_format = DataFormat(prefix, "user/single_integer/1") nose.tools.assert_true(integer_format.valid, integer_format.errors) integer_data_sink = MockDataSink(integer_format) diff --git a/beat/backend/python/test/test_protocoltemplate.py b/beat/backend/python/test/test_protocoltemplate.py index cf5454f7af416f3b6f7b4de1e1c5f89e5dcb6d10..494e85071badb5c85aa579ac46156986f5f25084 100644 --- a/beat/backend/python/test/test_protocoltemplate.py +++ b/beat/backend/python/test/test_protocoltemplate.py @@ -43,7 +43,6 @@ from . import prefix def load(pt_name): - protocol_template = ProtocolTemplate(prefix, pt_name) nose.tools.assert_true( protocol_template.valid, "\n * %s" % "\n * ".join(protocol_template.errors) @@ -60,7 +59,6 @@ def test_load_valid_protocol_template(): def load_valid_protocol_template(name, set_size): - protocol_template = load(name) nose.tools.eq_(len(protocol_template.sets()), set_size) @@ -70,7 +68,6 @@ def load_valid_protocol_template(name, set_size): def test_load_protocol_with_one_set(): - protocol_template = load("double/1") nose.tools.eq_(len(protocol_template.sets()), 1) @@ -88,7 +85,6 @@ def test_load_protocol_with_one_set(): def test_load_protocol_with_two_sets(): - protocol_template = load("two_sets/1") nose.tools.eq_(len(protocol_template.sets()), 2) diff --git a/beat/backend/python/utils.py b/beat/backend/python/utils.py index b60d101c737cb8df6c90649a54a0aa05077f7234..ef98e2771553f84ad04694e27a5f9e88f6110c0a 100644 --- a/beat/backend/python/utils.py +++ b/beat/backend/python/utils.py @@ -152,28 +152,23 @@ class File(object): """User helper to read and write file objects""" def __init__(self, path, binary=False): - self.path = path self.binary = binary def exists(self): - return os.path.exists(self.path) def load(self): - mode = "rb" if self.binary else "rt" with open(self.path, mode) as f: return f.read() def try_load(self): - if os.path.exists(self.path): return self.load() return None def backup(self): - if not os.path.exists(self.path): return # no point in backing-up @@ -184,7 +179,6 @@ class File(object): shutil.copy(self.path, backup) def save(self, contents): - d = os.path.dirname(self.path) if not os.path.exists(d): os.makedirs(d) @@ -206,7 +200,6 @@ class File(object): f.write(contents) def remove(self): - safe_rmfile(self.path) safe_rmfile(self.path + "~") # backup safe_rmdir(self.path) # remove containing directory @@ -216,12 +209,10 @@ class File(object): class AbstractStorage(object): - asset_type = None asset_folder = None def __init__(self, path): - if not all( [type(attr) == str for attr in [self.asset_type, self.asset_folder]] ):