online-judge-tools / template-generator

Analyze problems of competitive programming and automatically generate boilerplate
MIT License
87 stars 12 forks source link

サンプルの取得に失敗した場合に、サンプルだけでなくテンプレート類も作られません。 #79

Closed kmyk closed 3 years ago

kmyk commented 3 years ago

Summary / 概要

Steps to reproduce / 再現方法

  1. サンプルの取得に失敗するような問題に対して oj-prepare を実行

environments:

Expected behavior / 期待される挙動

テンプレート類が (解析失敗時のデフォルトの形で) 作られる。

Actual behavior / 実際の挙動

テンプレート類がまったく作られない

maspypy commented 3 years ago

例えば、以下で確認しています。 oj-prepare https://codeforces.com/contest/1535

kmyk commented 3 years ago

最新バージョンで再現取れました。バグですね

$ oj-prepare https://codeforces.com/contest/1535

...

Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_prepare/main.py", line 144, in prepare_contest
    prepare_problem(problem, contest=contest, config=config, session=session)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_prepare/main.py", line 100, in prepare_problem
    analyzed = analyzer.run(resources)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/combined.py", line 79, in run
    input_format = onlinejudge_template.analyzer.minimum_tree.construct_minimum_input_format_tree(instances=input_samples, multiple_test_cases=multiple_test_cases)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 506, in construct_minimum_input_format_tree
    node = _construct_minimum_input_format_internal_tree(instances=tokenized_instances, initial_node=initial_node)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 407, in _construct_minimum_input_format_internal_tree
    state = cur.run_match(_MatchState(tokens=instance, offset=0, env=env))
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 280, in run_match
    assert 0 <= self.index < len(state.env)
AssertionError

...

Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_prepare/main.py", line 144, in prepare_contest
    prepare_problem(problem, contest=contest, config=config, session=session)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_prepare/main.py", line 100, in prepare_problem
    analyzed = analyzer.run(resources)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/combined.py", line 79, in run
    input_format = onlinejudge_template.analyzer.minimum_tree.construct_minimum_input_format_tree(instances=input_samples, multiple_test_cases=multiple_test_cases)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 506, in construct_minimum_input_format_tree
    node = _construct_minimum_input_format_internal_tree(instances=tokenized_instances, initial_node=initial_node)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 407, in _construct_minimum_input_format_internal_tree
    state = cur.run_match(_MatchState(tokens=instance, offset=0, env=env))
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 280, in run_match
    assert 0 <= self.index < len(state.env)
AssertionError

...

Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_prepare/main.py", line 144, in prepare_contest
    prepare_problem(problem, contest=contest, config=config, session=session)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_prepare/main.py", line 100, in prepare_problem
    analyzed = analyzer.run(resources)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/combined.py", line 79, in run
    input_format = onlinejudge_template.analyzer.minimum_tree.construct_minimum_input_format_tree(instances=input_samples, multiple_test_cases=multiple_test_cases)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 506, in construct_minimum_input_format_tree
    node = _construct_minimum_input_format_internal_tree(instances=tokenized_instances, initial_node=initial_node)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 407, in _construct_minimum_input_format_internal_tree
    state = cur.run_match(_MatchState(tokens=instance, offset=0, env=env))
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 280, in run_match
    assert 0 <= self.index < len(state.env)
AssertionError

...

Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/oj-prepare", line 8, in <module>
    sys.exit(main())
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_prepare/main.py", line 191, in main
    prepare_contest(contest, config=config, session=session)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_prepare/main.py", line 151, in prepare_contest
    raise exceptions[0]
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_prepare/main.py", line 144, in prepare_contest
    prepare_problem(problem, contest=contest, config=config, session=session)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_prepare/main.py", line 100, in prepare_problem
    analyzed = analyzer.run(resources)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/combined.py", line 79, in run
    input_format = onlinejudge_template.analyzer.minimum_tree.construct_minimum_input_format_tree(instances=input_samples, multiple_test_cases=multiple_test_cases)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 506, in construct_minimum_input_format_tree
    node = _construct_minimum_input_format_internal_tree(instances=tokenized_instances, initial_node=initial_node)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 407, in _construct_minimum_input_format_internal_tree
    state = cur.run_match(_MatchState(tokens=instance, offset=0, env=env))
  File "/home/ubuntu/.local/lib/python3.8/site-packages/onlinejudge_template/analyzer/minimum_tree.py", line 280, in run_match
    assert 0 <= self.index < len(state.env)
AssertionError

$ tree
.
├── 613
│   └── d
│       ├── a.out
│       ├── generate.py
│       ├── main.bundled.cpp
│       ├── main.cpp
│       ├── main.py
│       └── test
│           ├── sample-1.in
│           ├── sample-1.out
│           ├── sample-2.in
│           ├── sample-2.out
│           ├── system-3.in
│           ├── system-3.out
│           ├── system-4.in
│           └── system-4.out
├── A
│   ├── generate.py
│   ├── main.cpp
│   ├── main.py
│   └── test
│       ├── sample-1.in
│       └── sample-1.out
├── B
│   ├── generate.py
│   ├── main.cpp
│   ├── main.py
│   └── test
│       ├── sample-1.in
│       └── sample-1.out
├── C
├── D
├── E
└── F
    ├── generate.py
    ├── main.cpp
    ├── main.py
    └── test
        ├── sample-1.in
        ├── sample-1.out
        ├── sample-2.in
        └── sample-2.out

12 directories, 30 files

$ uname -a
Linux DESKTOP-VQVORAN 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

$ pip3 list | grep online-judge-
online-judge-api-client         10.9.0
online-judge-template-generator 4.8.0
online-judge-tools              11.3.0
online-judge-verify-helper      5.5.3