fix(diff): bugs on diff stdin and numerics #16
|  | @ -127,9 +127,14 @@ class Stage(BaseModel): | |||
|     @classmethod | ||||
|     def gather_cases(cls: Type["Stage"], values: Dict[str, Any]) -> Dict[str, Any]: | ||||
|         cases = {k: v for k, v in values.items() if k.startswith("case")} | ||||
|         for key in cases: | ||||
|         limit = values.get("limit", {}) | ||||
|         parsed_cases = {} | ||||
|         for key, case in cases.items(): | ||||
|             case_with_limit = {**limit, **case.get("limit", {})} | ||||
|             case_for_parsing = {**case, "limit": case_with_limit} | ||||
|             parsed_cases[key] = case_for_parsing | ||||
|             values.pop(key) | ||||
|         values["cases"] = {k: v for k, v in cases.items()} | ||||
|         values["cases"] = parsed_cases | ||||
|         return values | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,9 +4,13 @@ from functools import partial | |||
| from pathlib import Path | ||||
| from typing import Any, Callable, Dict, List, Set, Tuple | ||||
| 
 | ||||
| from joj3_config_generator.models import const, result, task | ||||
| from joj3_config_generator.models import result, task | ||||
| from joj3_config_generator.models.common import Memory, Time | ||||
| from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT | ||||
| from joj3_config_generator.models.const import ( | ||||
|     DEFAULT_CLOCK_LIMIT_MULTIPLIER, | ||||
|     DEFAULT_PROC_LIMIT, | ||||
|     JOJ3_CONFIG_ROOT, | ||||
| ) | ||||
| from joj3_config_generator.models.task import Parser as ParserEnum | ||||
| 
 | ||||
| 
 | ||||
|  | @ -194,23 +198,19 @@ def fix_diff( | |||
|             ), | ||||
|             args=shlex.split(case_stage.command) if case_stage.command else None, | ||||
|             cpu_limit=case_stage.limit.cpu, | ||||
|             clock_limit=2 * case_stage.limit.cpu, | ||||
|             clock_limit=DEFAULT_CLOCK_LIMIT_MULTIPLIER * case_stage.limit.cpu, | ||||
|             memory_limit=case_stage.limit.mem, | ||||
|             proc_limit=50, | ||||
|             proc_limit=DEFAULT_PROC_LIMIT, | ||||
|         ) | ||||
| 
					
					bomingzh marked this conversation as resolved
					
						
						
							Outdated
						
					
				 | ||||
|         if cmd.args == executor.with_.default.args: | ||||
|             cmd.args = None | ||||
|         # duplicate with the fallback case in executor.with_ | ||||
|         if cmd.cpu_limit == const.DEFAULT_CPU_LIMIT: | ||||
|         if cmd.cpu_limit == executor.with_.default.cpu_limit: | ||||
|             cmd.cpu_limit = None | ||||
|         if ( | ||||
|             cmd.clock_limit | ||||
|             == const.DEFAULT_CLOCK_LIMIT_MULTIPLIER * const.DEFAULT_CPU_LIMIT | ||||
|         ): | ||||
|         if cmd.clock_limit == executor.with_.default.clock_limit: | ||||
|             cmd.clock_limit = None | ||||
|         if cmd.memory_limit == const.DEFAULT_MEMORY_LIMIT: | ||||
|         if cmd.memory_limit == executor.with_.default.memory_limit: | ||||
|             cmd.memory_limit = None | ||||
|         if cmd.proc_limit == const.DEFAULT_PROC_LIMIT: | ||||
|         if cmd.proc_limit == executor.with_.default.proc_limit: | ||||
|             cmd.proc_limit = None | ||||
|         stage_cases.append(cmd) | ||||
|         parser_case = result.DiffCasesConfig( | ||||
| 
					
					jon-lee marked this conversation as resolved
					
				 
				
					
						张泊明518370910136
						commented  better check if the  better check if the `*.out` file exists in get_testcases 
				
					
						李衍志523370910113
						commented  Not quite understand why would taht better? Not quite understand why would taht better? 
				
					
						张泊明518370910136
						commented  If case*.out will always be used in diff parser, we want to ensure it exists to form a valid case. If case*.out will always be used in diff parser, we want to ensure it exists to form a valid case. 
				
					
						李衍志523370910113
						commented  ok, I see, indeed a good point. ok, I see, indeed a good point. 
				
					
						李衍志523370910113
						commented  done. done. | ||||
|  |  | |||
|  | @ -71,6 +71,8 @@ | |||
|                                 "stdin": { | ||||
|                                     "src": "/home/tt/.config/joj/diff/case0.in" | ||||
|                                 }, | ||||
|                                 "cpuLimit": 1000000000, | ||||
|                                 "clockLimit": 2000000000, | ||||
|                                 "memoryLimit": 2097152 | ||||
|                             }, | ||||
|                             { | ||||
|  |  | |||
|  | @ -33,6 +33,7 @@ case1.diff.output.ignore_spaces = true | |||
| case1.command = "./h7/build/ex2" | ||||
| 
 | ||||
| case9.diff.output.score = 1232131 | ||||
| case9.limit.mem = "10m" | ||||
| 
 | ||||
| case11.diff.output.score = 92321 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	
What if the
with_.default.cpu_limitis not the same asDEFAULT_CPU_LIMIT? Why do we need to set these fields to none?if the
with_.default.cpu_limitis not the same asDEFAULT_CPU_LIMITit means its already been input before, and it is considered as the new default value for all cases (ta might want to control it). If I dont set these field to none, it will useDEFAULT_CPU_LIMITinstead of those ta input, which is not intended. It solve the second problem in #15Which test case will show this problem?
We need another pydantic model for auto detected cases. Fields in these cases can be none, which means they are not set and should use
with_.defaultvalues.