jd4
jd4 copied to clipboard
New cases file format
- Use yaml as config
- Case insensitive
- Recursive
- Cover all existing use cases
- Automatically convertible from "legacy case"
- Support special judge
Initial thinking:
time: 1s
memory: 16m
score: 10
children:
- input: input/input0.txt
output: output/output0.txt
- input: input/input1.txt
output: output/output1.txt
- judge:
file: judge.cc
lang: cc
time: 5s
memory: 64m
data: ['data/state', 'data/transition']
score: 30
children:
- input: input/input2.txt
data: data/state
memory: 32m
- input: input/input3.txt
data: data/state
score: 50
memory: 2048m
This is an extreme case. Normal config should be much simpler.
YAML is quite unfriendly to beginners.
Could you please explain in more details? @iceb0y
TOML seems simpler and maybe better for this purpose.
Looks like yaml supports inheritance by itself.
The proposed config can be rewritten as:
default: &default
time: 1s
memory: 16m
score: 10
default2: &default2
<<: *default
judge:
file: judge.cc
lang: cc
time: 5s
memory: 64m
data: ['data/state', 'data/transition']
score: 30
cases:
- <<: *default
input: input/input0.txt
output: output/output0.txt
- <<: *default
input: input/input1.txt
output: output/output1.txt
- <<: *default2
input: input/input2.txt
data: data/state
memory: 32m
- <<: *default2
input: input/input3.txt
data: data/state
score: 50
memory: 2048m
Parse result:
[{'input': 'input/input0.txt',
'memory': '16m',
'output': 'output/output0.txt',
'score': 10,
'time': '1s'},
{'input': 'input/input1.txt',
'memory': '16m',
'output': 'output/output1.txt',
'score': 10,
'time': '1s'},
{'data': 'data/state',
'input': 'input/input2.txt',
'judge': {'data': ['data/state', 'data/transition'],
'file': 'judge.cc',
'lang': 'cc',
'memory': '64m',
'time': '5s'},
'memory': '32m',
'score': 30,
'time': '1s'},
{'data': 'data/state',
'input': 'input/input3.txt',
'judge': {'data': ['data/state', 'data/transition'],
'file': 'judge.cc',
'lang': 'cc',
'memory': '64m',
'time': '5s'},
'memory': '2048m',
'score': 50,
'time': '1s'}]
https://github.com/vstakhov/libucl is another option