def post(self): template_params = handle_user() if not 'admin' in template_params: self.redirect('/') return tournament_url = self.request.get("url") # Check for input if tournament_url == "": self.redirect("/addTournaments") return dup_check = TournamentModel.query( TournamentModel.url == convert_url(tournament_url)) if dup_check.get() is not None: render_template(self, 'error_dup_league.html', template_params) return api.set_credentials(CHALLONGE_USERNAME, CHALLONGE_API) #Handle tournament not found error tournament = tournaments.show(tournament_url) tournament_object = TournamentModel() tournament_object.name = tournament['name'] tournament_object.url = convert_url(tournament_url) timestamp = parser.parse(tournament['created-at'][:-6]) tournament_object.timestamp = timestamp tournament_object.put() # Extract the matches # Move participant seach to preindex'd list rather than 3 challonge requests match_list = matches.index(tournament['id']) participant_list = participants.index(tournament['id']) self.response.out.write(participant_list) for match in match_list: match_object = MatchModel(parent=tournament_object.key) # Find names via challonge #match_object.player1 = participants.show(tournament['id'], match['player1-id'])['name'] #match_object.player2 = participants.show(tournament['id'], match['player2-id'])['name'] # Find names via list for p in participant_list: if p['id'] == match['player1-id']: match_object.player1 = p['name'] if p['id'] == match['player2-id']: match_object.player2 = p['name'] if match['scores-csv'] != "": parts = match['scores-csv'].split('-') match_object.player1Score = int(parts[0]) match_object.player2Score = int(parts[1]) winner = participants.show(tournament['id'], match['winner-id']) match_object.winner = winner['name'] match_object.label = match['identifier'] timestamp = parser.parse(match['started-at'][:-6]) match_object.timestamp = timestamp match_object.put() self.redirect("/listTournaments")
# from models.model_io import ModelInput, ModelOptions, ModelOutput from utils.flag_parser import parse_arguments import torch.jit as jit # embed basemodel.py import torch import torch.nn as nn import torch.nn.functional as F from utils.net_util import norm_col_init, weights_init from models import MatchModel if __name__ == '__main__': args = parse_arguments() device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # device = 'cpu' model = MatchModel(args).to(device) # model_input = ModelInput() state = torch.zeros(1, 512, 7, 7).to(device) # [1,512,7,7] hidden = ( torch.zeros(1, args.hidden_state_sz).to(device), # [1,512] torch.zeros(1, args.hidden_state_sz).to(device), # [1,512] ) target_class_embedding = torch.zeros(300).to(device) # [300] action_probs = torch.zeros(1, args.action_space).to( device) # [1, #(ACTION_SPACE)] # model_opts = ModelOptions() # tw.draw_model(model,([1,512,7,7], # [1,args.hidden_state_sz], # [1,args.hidden_state_sz],