def end(self, session): file.save_pickle( self._results, os.path.join(tf.app.flags.FLAGS.model_dir, "eval_map.pkl")) file.save_json( self._results, os.path.join(tf.app.flags.FLAGS.model_dir, "eval_map.json"))
def _save_results(self): """Export latest results from model training/evaluation in pickle and JSON formats""" pp = pprint.PrettyPrinter(indent=2, compact=True) for name in self._estimator.get_variable_names(): if name == "h" or name.find("optimizer") != -1 or name in [ "beta1_power", "help", "beta2_power" ]: continue val = self._estimator.get_variable_value(name) if len(val.shape) > 0: self.model_details["model_vars"][name] = { "shape": val.shape, } else: self.model_details["model_vars"][name] = { "value": val.item(), } model_stats_map = { "model_details": self.model_details, "final_result": self.get_final_eval_result(), "total_train_duration": self._duration_to_string(self.total_train_duration), "total_eval_duration": self._duration_to_string(self.total_eval_duration), } results_table = self.format_results_as_table_string( self._eval_columns, self.eval_results) file.save_pickle( model_stats_map, os.path.join(tf.app.flags.FLAGS.model_dir, "last_result.pkl")) file.save_json( model_stats_map, os.path.join(tf.app.flags.FLAGS.model_dir, "last_result.json")) file.save_txt( results_table, os.path.join(tf.app.flags.FLAGS.model_dir, "last_results_table.txt")) self.print(results_table) pp.pprint(model_stats_map) self.print("Total training duration: " + self._duration_to_string(self.total_train_duration)) self.print("Total evaluation duration: " + self._duration_to_string(self.total_eval_duration))
def update_quests(quest): """ input: quests output: true/false """ txt_var = "All quests completed? "+ str(quest.quest_list["status"]["quest_checked"]) event.log("DEBUG", "dailies.update_quests", txt_var) if quest.quest_list["status"]["quest_checked"] == False: event.log("DEBUG", "dailies.update_quests", "Checking quests Loop Start") quest.quest_list = quest.check_quests() quest.quest_list["status"]["quests_completed"] = quest.claim_quests() file.save_json(quest.quest_list) return quest.quest_list["status"]["quests_completed"]
async def start_gathering(self): response_list = {} url_list = await self.generate_urls() for i, u in url_list.items(): response_list[i] = [] for coin_id, urls in url_list.items(): for url in urls: self.spinner.spin() response_list[coin_id].append((requests.get(url).json())) if self.save_to_file: file.save_json(response_list) else: await self.database.batch_upload(response_list)
def update_purchases(purchase): """ input: purchases output: true/false """ status = purchase.spend_friendship() print(status) if status != False: file.save_json(status) status = purchase.spend_fossils() print(status) if status != False: file.save_json(status) for value in status.values(): if value == False: return False return True
def update_rewards(rewards): """ input: rewards output: true/false """ status = rewards.get_daily_friendships() print(status) if status != False: file.save_json(status) status = rewards.get_daily_gem_ads() print(status) if status != False: file.save_json(status) status = rewards.get_daily_summon() print(status) if status != False: file.save_json(status) for value in status.values(): if value == False: return False return True
def reset_all(quest, reward, purchase, json_daily_status): quest.quest_list["status"] = quest.reset_all() reward.rewards_list["status"] = reward.reset_all() purchase.purchase_list["status"] = purchase.reset_all() json_daily_status["status"]["all_completed"] = False file.save_json(quest.quest_list) file.save_json(reward.rewards_list) file.save_json(purchase.purchase_list) file.save_json(json_daily_status) # def evaluate_progress(): # """ # input: an array # output: a dictionary/json object # """ # print("test") # class Dailies: # def __init__(self,dailies_list): # self.dailies_list = dailies_list # def check_rewards(self, rewards, quests, ): # if rewards.is_completed == False: # file.save_json(rewards.get_daily_friendships()) # file.save_json(rewards.get_daily_gem_ads()) # file.save_json(rewards.get_daily_summon()) # if quest # def check_quests(self): # print("test") # def check_purchases(self): # print("test") # def is_completed(self): # print("test")
try: game.check_menu_popups(quest, reward, purchase, daily_status) """Battle 1""" game.level_battle_skill(image.skill_crit_chance.value) battle.campaign() game.check_menu_popups(quest, reward, purchase, daily_status) #game.level_battle_skill(image.skill_devastation.value) game.level_battle_skill(image.skill_crit_chance.value) """Battle 2""" # battle.campaign() # game.check_menu_popups(quest, reward, purchase, daily_status) # game.level_battle_skill(image.skill_damage_icon.value) """Extra Quest Battle""" battle.additional_quest_battles(quest) game.check_menu_popups(quest, reward, purchase, daily_status) """Extra Dungeon Battle""" # battle.dungeon(60) # game.check_menu_popups(quest, reward, purchase, daily_status) """Extra Excavation Battle""" # battle.expedition(image.expedition_hell.value) # game.check_menu_popups(quest, reward, purchase, daily_status) """Dailies Subroutine""" if daily_status["status"]["all_completed"] == False: daily_status["status"]["all_completed"] = dailies.update_all( quest, reward, purchase) file.save_json(daily_status) """Rewind""" rewinder.rewind() rewinder.level_skill() except: game.restart_game()
def save(self, key, location): if key: self.api_key = key data = {'api_key': key, 'default_location': location} file.save_json(self.save_file, data)