@@ -61,52 +61,6 @@ async def select_gpu_view(
6161 await view .wait ()
6262 return view
6363
64- async def on_submit_hook ( # noqa: C901
65- self ,
66- interaction : discord .Interaction ,
67- leaderboard_name : Optional [str ],
68- script : discord .Attachment ,
69- mode : SubmissionMode ,
70- cmd_gpus : Optional [List [str ]],
71- ) -> int :
72- """
73- Called as the main body of a submission to route to the correct runner.
74- """
75- # Read the template file
76- submission_content = await script .read ()
77-
78- try :
79- submission_content = submission_content .decode ()
80- except UnicodeError :
81- await send_discord_message (
82- interaction , "Could not decode your file. Is it UTF-8?" , ephemeral = True
83- )
84- return - 1
85-
86- if not interaction .response .is_done ():
87- await interaction .response .defer (ephemeral = True )
88-
89- req = SubmissionRequest (
90- code = submission_content ,
91- file_name = script .filename ,
92- user_id = interaction .user .id ,
93- user_name = interaction .user .global_name or interaction .user .name ,
94- gpus = cmd_gpus ,
95- leaderboard = leaderboard_name ,
96- )
97- req = prepare_submission (req , self .bot .leaderboard_db )
98-
99- if req .gpus is None :
100- view = await self .select_gpu_view (interaction , leaderboard_name , req .task_gpus )
101- req .gpus = view .selected_gpus
102-
103- reporter = MultiProgressReporterDiscord (interaction )
104- sub_id , results = await self .bot .backend .submit_full (req , mode , reporter )
105-
106- if mode == SubmissionMode .LEADERBOARD :
107- await self .post_submit_hook (interaction , sub_id )
108- return sub_id
109-
11064 def generate_run_verdict (self , run : RunItem , sub_data : SubmissionItem ):
11165 medals = {1 : "🥇 First" , 2 : "🥈 Second" , 3 : "🥉 Third" }
11266
@@ -176,18 +130,42 @@ async def submit(
176130 mode : SubmissionMode ,
177131 gpu : Optional [str ],
178132 ):
179- if not self .bot .backend .accepts_jobs :
133+ if gpu is not None :
134+ gpu = [gpu .strip () for gpu in gpu .split ("," )]
135+
136+ submission_content = await script .read ()
137+
138+ try :
139+ submission_content = submission_content .decode ()
140+ except UnicodeError :
180141 await send_discord_message (
181- interaction ,
182- "The bot is currently not accepting any new submissions, please try again later." ,
183- ephemeral = True ,
142+ interaction , "Could not decode your file. Is it UTF-8?" , ephemeral = True
184143 )
185- return
144+ return - 1
186145
187- if gpu is not None :
188- gpu = [ gpu . strip () for gpu in gpu . split ( "," )]
146+ if not interaction . response . is_done () :
147+ await interaction . response . defer ( ephemeral = True )
189148
190- return await self .on_submit_hook (interaction , leaderboard_name , script , mode , gpu )
149+ req = SubmissionRequest (
150+ code = submission_content ,
151+ file_name = script .filename ,
152+ user_id = interaction .user .id ,
153+ user_name = interaction .user .global_name or interaction .user .name ,
154+ gpus = gpu ,
155+ leaderboard = leaderboard_name ,
156+ )
157+ req = prepare_submission (req , self .bot .backend )
158+
159+ if req .gpus is None :
160+ view = await self .select_gpu_view (interaction , leaderboard_name , req .task_gpus )
161+ req .gpus = view .selected_gpus
162+
163+ reporter = MultiProgressReporterDiscord (interaction )
164+ sub_id , results = await self .bot .backend .submit_full (req , mode , reporter )
165+
166+ if mode == SubmissionMode .LEADERBOARD :
167+ await self .post_submit_hook (interaction , sub_id )
168+ return sub_id
191169
192170 @app_commands .command (name = "test" , description = "Start a testing/debugging run" )
193171 @app_commands .describe (
0 commit comments