def test_md5_hash(): ob1 = ((1, 2), {"1": "2"}) ob2 = ((1, 2), {1: "2"}) ob3 = ([1, 2], {1: 2}) h1 = md5_hash(ob1) h2 = md5_hash(ob2) h3 = md5_hash(ob3) assert len(set((h1, h2, h3))) == 3 # Test 3 different hash assert h1 == "d5f3de055dd4049def2766a9a6a3e914" assert h2 == "e8c67e026e91872ef85bc56cf67ab97a" assert h3 == "f409ec84efccad047568fa1ca5d0f990"
def _prepare_workers(self): ################# ### Worker ID ### ################# self.nb_of_workers = self.data_persister.new_shared_integer(path=self.get_worker_path(), key="nb_of_workers") new_nb_of_worker = self.nb_of_workers.inc() self.worker_informations = system_and_caller_information() self.worker_informations["time"] = time.strftime("%Y-%m-%d %H:%M:%S") self.worker_informations["started"] = False self.worker_informations["done"] = False self.worker_informations["ctrq_pressed"] = False self.worker_informations["id"] = "worker_%d" % new_nb_of_worker self.worker_informations["class_name"] = self.__class__.__name__ ### Create random_state ### if self.seed is None: seed = int(md5_hash(self.worker_informations), 16) % (2 ** 32 - 1) else: seed = self.seed self.worker_informations["seed"] = seed self.random_state = check_random_state(seed) # will create a generator here # Peut etre qu'il faut mettre le nomber de l'object self.write_worker_informations() log_file = os.path.join( self.data_persister.base_folder, self.get_worker_path(), type(self).__name__.lower() + "_worker_%d.log" % new_nb_of_worker, ) register_log_files(log_file, aikit_only=False)