Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise error if sample parse failed. #461

Merged
merged 2 commits into from
Sep 2, 2019

Conversation

fukatani
Copy link
Contributor

@fukatani fukatani commented Jul 3, 2019

Resolve #413

413で例外を投げるようにしました。
エラーメッセージがわかるようなわからないような感じだったので、サンプルのパースに失敗したことをメッセージ煮だすようにしました。
また、従来、中途半端にsample.in/outが残っていましたが、怪しいのでなにも残さないようにしてみました。

@fukatani fukatani changed the title Issue/413 Raise error if sample parse failed. Jul 3, 2019
@kmyk
Copy link
Member

kmyk commented Jul 4, 2019

設計としてはこれが正しいのでマージしたさはつよいのですが、ライブラリとして見たとき「いままで例外を吐かなかった関数が急に例外を吐くようになる」は破壊的変更であり、今回は得に影響範囲が大きいのでマージは保留です。
他が一段落した後にバージョンを v7.0.0 に上げて、その他の破壊的リファクタリングと同時にマージしましょう。

@kmyk kmyk added this to the v7.0.0 milestone Jul 4, 2019
@fukatani
Copy link
Contributor Author

fukatani commented Jul 6, 2019

@kmyk
相談させてください。
https://atcoder.jp/contests/future-contest-2018-final/tasks/future_contest_2018_final_a
の問題のスコアを取得できなくなりテストが落ちます。
たしかに問題を見るとサンプルのパースは失敗していいと思うのですが、スコアだけなら取れるようにすることもできるとは思います。
例えば_AtCoderProblemContent_from_htmlの中で例外を一度受けて、最後までAtCoderProblemContent_parse_xxxを行い、再び例外をレイズする。そしてテストでは、例外をexceptしてscoreがあっているかを見る、みたいな方法です。

ちょっとごちゃごちゃしそうですがこの問題のスコア取得は諦めてもいいのかなと思うのですが、なにか考えはありますか?

@kmyk
Copy link
Member

kmyk commented Jul 6, 2019

テストが落ちている問題は #464 で述べた設計ミスに起因すると考えています。なのでad-hocに解決するのには反対です。ひとまずこのプルリクは忘れて、自然に解決される状態になってから解決するのがよいと思います。

AtCoderProblemContent.sample_cases の型を List[TestCase] から Optional[List[TestCase]] へ修正し、 AtCoderProblem.download_sample_cases でそれが None かどうかに従って例外を投げるのが適切なはずです。

https://github.com/kmyk/online-judge-tools/blob/6d4f23d9f7886f8ba4ef749ff087597c4932412b/onlinejudge/service/atcoder.py#L399-L411

https://github.com/kmyk/online-judge-tools/blob/6d4f23d9f7886f8ba4ef749ff087597c4932412b/onlinejudge/service/atcoder.py#L587-L591

スコアの取得はできるなら諦めたくないです。スコア自体は重要ではないのですが、同時に実行時間制限やメモリ制限が取得できなくなることが問題です。これらの値は例えば https://github.com/fukatani/rujaion のような上部のツールで利用することを期待したものなので、サンプルが取得できなくても十分に意味を持ちます。

@fukatani
Copy link
Contributor Author

fukatani commented Jul 7, 2019

kmykさんの方針で正しいと思います。

@kmyk
Copy link
Member

kmyk commented Jul 21, 2019

失敗してほしいけどしないやつを見つけた。この挙動はけっこうまずい。たぶん原因は同じなのでここにメモしておく https://atcoder.jp/contests/agc036/tasks/agc036_b

$ oj d https://atcoder.jp/contests/agc036/tasks/agc036_b
[x] problem recognized: AtCoderProblem.from_url('https://atcoder.jp/contests/agc036/tasks/agc036_b'): https://atcoder.jp/contests/agc036/tasks/agc036_b
[x] load cookie from: /home/user/.local/share/online-judge-tools/cookie.jar
[x] GET: https://atcoder.jp/contests/agc036/tasks/agc036_b
[x] 200 OK
[!] strange name for output string: 入力例 4
[!] strange name for input string: 出力例 4
[*] skipped due to language: current one is lang-ja, not lang-en: Sample Input 1 
[*] skipped due to language: current one is lang-ja, not lang-en: Sample Output 1 
[*] skipped due to language: current one is lang-ja, not lang-en: Sample Input 2 
[*] skipped due to language: current one is lang-ja, not lang-en: Sample Output 2 
[*] skipped due to language: current one is lang-ja, not lang-en: Sample Input 3 
[*] skipped due to language: current one is lang-ja, not lang-en: Sample Input 4 
[*] skipped due to language: current one is lang-ja, not lang-en: Sample Output 4 
[ERROR] dangling sample string: b'9 2 6\n'
[x] save cookie to: /home/user/.local/share/online-judge-tools/cookie.jar
[x] append history to: /home/user/.cache/online-judge-tools/download-history.jsonl

[*] sample 0
[x] input: sample-1
3 2
1 2 3

[+] saved to: test/sample-1.in
[x] output: sample-1
2 3

[+] saved to: test/sample-1.out

[*] sample 1
[x] input: sample-2
5 10
1 2 3 2 3

[+] saved to: test/sample-2.in
[x] output: sample-2
3

[+] saved to: test/sample-2.out

[*] sample 2
[x] input: sample-3
6 1000000000000
1 1 2 2 3 3

[+] saved to: test/sample-3.in
[x] output: sample-3
11 97
3 1 4 1 5 9 2 6 5 3 5

[+] saved to: test/sample-3.out

@fukatani
Copy link
Contributor Author

Already merged to develop branch.

@fukatani fukatani merged commit f16b4fd into online-judge-tools:master Sep 2, 2019
@fukatani fukatani deleted the issue/413 branch September 2, 2019 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

a example of a problem whose sample cases have no outputs
2 participants