|
1 | 1 | import functools |
2 | 2 | import logging |
3 | 3 | import subprocess |
4 | | -from typing import TYPE_CHECKING, Any, Optional |
| 4 | +from typing import Any, Optional |
5 | 5 |
|
6 | 6 | import discord |
7 | | -from consts import Language, SubmissionMode |
8 | | - |
9 | | -if TYPE_CHECKING: |
10 | | - from task import LeaderboardTask |
11 | 7 |
|
12 | 8 |
|
13 | 9 | def setup_logging(name: Optional[str] = None): |
@@ -178,76 +174,6 @@ def invalidate(self): |
178 | 174 | self._q.clear() |
179 | 175 |
|
180 | 176 |
|
181 | | -def build_task_config( |
182 | | - task: "LeaderboardTask" = None, |
183 | | - submission_content: str = None, |
184 | | - arch: str = None, |
185 | | - mode: SubmissionMode = None, |
186 | | -) -> dict: |
187 | | - if task is None: |
188 | | - assert mode == SubmissionMode.SCRIPT |
189 | | - # TODO detect language |
190 | | - lang = "py" |
191 | | - |
192 | | - config = { |
193 | | - "lang": lang, |
194 | | - "arch": arch, |
195 | | - } |
196 | | - |
197 | | - eval_name = {"py": "eval.py", "cu": "eval.cu"}[lang] |
198 | | - |
199 | | - if lang == "py": |
200 | | - config["main"] = "eval.py" |
201 | | - |
202 | | - return { |
203 | | - **config, |
204 | | - "sources": { |
205 | | - eval_name: submission_content, |
206 | | - }, |
207 | | - } |
208 | | - else: |
209 | | - all_files = {} |
210 | | - for n, c in task.files.items(): |
211 | | - if c == "@SUBMISSION@": |
212 | | - all_files[n] = submission_content |
213 | | - else: |
214 | | - all_files[n] = c |
215 | | - |
216 | | - common = { |
217 | | - "lang": task.lang.value, |
218 | | - "arch": arch, |
219 | | - "benchmarks": task.benchmarks, |
220 | | - "tests": task.tests, |
221 | | - "mode": mode.value, |
222 | | - "test_timeout": task.test_timeout, |
223 | | - "benchmark_timeout": task.benchmark_timeout, |
224 | | - "ranked_timeout": task.ranked_timeout, |
225 | | - "ranking_by": task.ranking_by.value, |
226 | | - "seed": task.seed, |
227 | | - } |
228 | | - |
229 | | - if task.lang == Language.Python: |
230 | | - return { |
231 | | - "main": task.config.main, |
232 | | - "sources": all_files, |
233 | | - **common, |
234 | | - } |
235 | | - else: |
236 | | - sources = {} |
237 | | - headers = {} |
238 | | - for f in all_files: |
239 | | - if f in task.config.sources: |
240 | | - sources[f] = all_files[f] |
241 | | - else: |
242 | | - headers[f] = all_files[f] |
243 | | - |
244 | | - return { |
245 | | - "sources": sources, |
246 | | - "headers": headers, |
247 | | - "include_dirs": task.config.include_dirs, |
248 | | - } |
249 | | - |
250 | | - |
251 | 177 | def format_time(value: float | str, err: Optional[float | str] = None, scale=None): # noqa: C901 |
252 | 178 | if value is None: |
253 | 179 | logging.warning("Expected a number, got None", stack_info=True) |
|
0 commit comments