def stage_0_read(reactor_id): children = None if reactor_id==None: children = database_manager.fetch_children() elif isinstance(reactor_id,list): children = database_manager.fetch_children_subset(id=reactor_id) hanashi.create_new_batch(np.array([[None] for i in range(len(reactor_id))]),servers=reactor_id) hanashi.step()
def get_available_servers(): """ Pings open servers in the network. The url's are obtainted from the `children` table in the SQLite database. """ online = ping_to_children() online = list(filter(lambda x: online[x].ok,online.keys())) return database_manager.fetch_children_subset(online)
def reactors(self,value): if isinstance(value,list): self._reactors = value data = database_manager.fetch_children_subset(id=self._reactors) self.urls = {d["id"]:d["url"] for d in data} self.url_list = list(self.urls.values()) else: print("Unrecognized format. Use a list of reactor id's.") self._reactors = None self.urls = None
def stage_0_set(reactor_id,parameters="uniform",brightness=1): """ Sends a initial set of parameters and only reads thereafter. reactor_id: list of urls to ractors. parameters: list of parameters or string to parameter profile """ children = database_manager.fetch_children_subset(id=reactor_id) #Setting parameters for child in children: if isinstance(parameters,list): hanashi.shadow_send(parameters,child["url"],0) elif parameters=="uniform": spectra.shadow_uniform(brightness,child["url"],0)