RagnarGrootKoerkamp / BAPCtools

Tools for developing ICPC-style programming contest problems.
GNU General Public License v3.0
49 stars 22 forks source link

Generation: allow duplicate _invalid_ input files #334

Closed thorehusfeldt closed 7 months ago

thorehusfeldt commented 8 months ago

The following would be useful and shouldn’t lead to a FATAL error:

invalid_answers:
  - '':
      in: 3 7
      ans: ten
  - '':
      in: 3 7
      ans: 11
mzuenni commented 8 months ago

The reason for this is that the hash of testcase.in is used as a path... and then writing different .ans files would break stuff. However, if the '.ans' is provided we could just include it into the hash?

(this would still break if the .ans is generated in some other way)

thorehusfeldt commented 8 months ago

In particular, the contents of

are all

1

Since I’m now input-validating the data/invalid_answers (which is the new place for invalid_outputs), the test suite, in particular bt validate --input --problem identity breaks the pytest. (Validation returns 1.)

mzuenni commented 8 months ago

Hm, in generell we could rework the caching into multiple directories one for inputs and one for answers, that should fix this issue?

RagnarGrootKoerkamp commented 8 months ago

I believe this was fixed with https://github.com/RagnarGrootKoerkamp/BAPCtools/pull/333/commits/5d1a59eb10148639425e3d262cedac34f8435c75 as part of #333 right?

We'll probably need to extend that for data/invalid_output, where both in and ans can be the same but only the (to be added) out: key may differ.

thorehusfeldt commented 8 months ago

Feel free to implemented the extension suggested above; out: keys are now a thing. The caching is opaque to me, so I don’t want to touch it.

mzuenni commented 8 months ago

@RagnarGrootKoerkamp i added this, can you take a look?

thorehusfeldt commented 8 months ago

I tried to generator-fy the testcases in invalid_{inputs, answers} in test/identity like so:

  invalid_inputs:
    data:
      "2":
        in: "-1"
      "3":
        in: "1001"
      "7": 
        in: "1\n\n"
      "8":
        in: " 0"
      "9":
        in: "\n0"
  invalid_answers:
    data:
      "4":
        in: "2"
        ans: "-2"
      "5":
        in: "199"
        ans: " 199"
      "6":
        in: "3"
        ans: ""

But I get

NameError: name 'ans_hash' is not defined

and am a bit out of my depth. Maybe you could add the above, and try to make it work with identical input files, so we could instead have

invalid_answers:
  data:
    -'':
      in: "1"
      ans: " 1"
  -'':
      in: "1"
      ans: "1 "

and so on. Once that works, we should (finally) reach the Holy Grail of this entire quest and add

 invalid_outputs:
   data:
    -'':
        in: "1"
        ans: "1"
        out: "2"

I’d be grateful if somebody did this to identity.

thorehusfeldt commented 7 months ago

I think this is solved by feat/invalidation.