-
Notifications
You must be signed in to change notification settings - Fork 14
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
rethink constants #344
Comments
The use case is stuff like
in judge solutions, which can now be
I agree that this is not as crucial as constant expansion in validators and problem statements, but it’s nice to be able to tweak problem bounds without needing to go through and fix RTEs in judge solutions. Expanding constants in contestant submissions seems to me a bad idea; for one thing contestants don’t know what constants are available, and for another we should not be doing any messing around with submission source code that could accidentally break a solution that works locally for the student. I’m not sure why text replacement is “just inconvenient”? |
Text replacement badly messes up editor highlighting and autoformatting and such. Wouldn't it be nicer in your example if we did a |
Is there concrete evidence that the proposed balanced-braces “badly” messes up anything in practice? I think it is good to make it obvious which variables are externally defined problem constants and which are statically scoped, and to make it more or less impossible to accidentally shadow the problem constants |
regarding the change in judge submissions: I am not sure if this really makes things much easier since you still need to change all the test data anyway (note that we don't define generators). And distinguishing between user submissions and jury submissions makes stuff more complicated than necessary. Further, we don't don't allow a constant to write solutions like "do random stuff until you are out of time" for which automatic updates would be useful. regarding messing stuff up: my problem is more that this messes up standard build processes. For c++ I can't compile stuff anymore but if it's done with macros or as constant I can simply tell my compiler what macros exist. Same for latex. The curly bracket thing breaks latexmk rebuild whereas with macros this can not happen. |
Yeah I think defines and environment variables might be better approaches here. |
For LaTeX, don't you already need a script that does preprocessing before being able to compile the problem statement? You need to wrap the problem statement in a I agree that it's annoying that C++ code cannot be compiled locally using e.g. So:
But we had long discussions already about these issues at Lund, and considered alternatives like |
you can make latexmk do all that. it just cant preprocess the tex file with text replacement... (especially not with live pdf generation)
we only allow ctd, viva, c++ and python as checkers |
Yes, you are right. So we could specify different mechanisms for these languages (plus yaml and markdown) and remove support for constants in included code and submissions.
And it cannot be configured to |
I see no good way to do that. but if we add a mechanism for c++ etc. then one for latex is also fine i.e. if you have the constant |
"example submissions" are the only kind of submissions in the problem packages.
Yes, definitely. I don't think anybody has suggested or want that.
I agree that constants are significantly less needed for (judge) submissions, simply because the agreement between submissions and statement/data/validators are checked. If there is a change of a limit that breaks a submission, then installation will fail. The reason why we wanted something like constants to begin with is that we verify that submissions agree with data/validators, but we have to trust problem authors to make sure that the statement also agrees. In fact, the most common error with problem packages is exactly this.
I don't understand what this means? There are no "user submissions" in a problem package. Clearly (?) constants are not meant to apply outside of the package, i.e. they are absolutely not meant to be applied to submissions sent to some system that has installed the package.
I can't quite parse this. Is "contsant" supposed to be "contestant"? If so, why would constants help with writing "do stuff until time runs out" style submissions?
A minor point is that this could make it harder to add additional languages in the future. That said, we could always say that constants are not avaialble for some languages (and then we would be not worse off than if we didn't define constants). |
yes but in the end the problem gets uploaded to a a system that handles both the example submissions and participants submissions. Now it has to distinguish them (which will likely also make it impossible to upload the example submission alone).
Regarding use cases for constants in submissions: I think inserting something like the time-limit into a submission would be more useful than inserting constants but we already decided that that won't be possible. Overall i am just in favor of not having constants in submissions and use the for their main purpose, to make checkers and statements consistent.
that is true, but I would prefer to change the constants like this:
|
I disagree with that claim. A system does not have to distinguish submissions in the problem package after installation, from any user submissions. To upload package submissions that are using constants you would of course have to apply the constant replacements first, but that is exactly why the target system does not have to even know that our constants exist.
The consensus certainly seem to be that statements and validators are the more important use case. Is there anybody who sees a good use for constants in submissions (and included code)?
Ok, that would work, but:
|
Well, I think the system you upload the package to has to do the replacement (so for example domjudge)?
Yes, but I rarely run validators on my own (unlike submissions)? And with what I propose at least I don't get errors from my ide while writing those validators. Also, yes what I propose makes it harder for us as tool authors but it makes it more convenient for the people who use our tools? In the end, our goal should be that constants are used as much as possible for the purpose of consistency i.e. ensuring that validators and therefore test cases match what is specified in the problem statement. Therefore, my aim is to make it as convenient as possible. |
Yes, true, but only when installing the problem (or, depending on how you look at it, before installing them). And that point user submissions do not exist, so I would disagree with the statement that "it has to distinguish them".
Good point. |
I'm (again) hearing strong consensus for constants in statement and validators, some good arguments against constants in submissions, and (so far) no-one that explicitly wants constants in submissions (which is a lower bar than having a good argument for it), only that it could in theory maybe be useful (which is an even lower bar). If you really think we should allow constants in submissions (and included code), please speak up. |
@simonlindholm is included code hacks for faster interactive validators still a relevant thing? If so, this might be nice. Also, just because constant replacement exists for user submissions, nothing forces you to use them if you find them inconvenient. |
It is, and included code hacks are relevant for other weird kinds of multipass stuff as well (e.g. you can imagine two submission instances running in parallel and communicating with each other, which wouldn't be covered by the newly added multipass support, or you might want time limits to be across the sum of runs). I personally wouldn't want to use For input/output validators I think injected C++ defines could be decent enough UX, but for a more language-portable solution we could also use cmdline arguments (with some custom syntax for embedding constants in "*_validators_args" yaml strings?) or environment variables. |
I don't have a strong opinion either way for allowing constants in submissions. And I agree with @niemela , this only apply to jury/example submissions, it's completely unrelated to team submissions, because any constant substitution should happen before these jury submissions are uploaded to the CCS (at least for DOMjudge), so I'd consider it part of the "exported" problem package, like calculated time limits and generated test data. On checktestdata: you can define constants on the command line, so that's a way to pass them without replacement of |
The part that I will definitely require my judges to use are constants in the validators, problem statement, and testdata.yaml. I.e. in problem.yaml:
In problem.en.tex:
In validator.ctd:
In testdata.yaml:
In a potential output validator:
Inconsistencies in i.e. capitalization of
|
What about conflicts with, for example, Python's f-strings? |
Not really though, right, because those only use single foo = {{this}}
bar = "{{this_string}}"
print(f'{this} and {this_string}') |
Another solution would be write some formatting function in tex, so that instead if using |
FWIW for input validators I somewhat disagree -- CTD can use the custom syntax, and any non-CTD syntax validator will need to use some kind of testlib/template to correctly validate whitespace/no trailing zeroes/etc. because it's too error-prone to hand-roll. If you combine CTD and non-CTD you're probably putting the limits in the CTD file, but even if not it's really not hard to read data from env vars: in Python it's |
|
This is true for output validators, but not always for input validators: one usage pattern is to have CTD handle the input syntax and for the C++/python validators to check more complicated semantics assuming correct syntax. Anyway, I have a negative bias against environment variables, but maybe it is clean? What would my example above look like in this scheme? LaTeX would also use environment variables, or something else? It would work when the variables have TeX embedded in them? |
My sense is that this is too narrow/special-case. Some of the North American judges have very strong opinions about the style of the problem statement... |
Right now we replace constants at the following places:
testdata.yaml
There are a few things that I want to mention.
"Replacement in example submissions and included code" What is the use case here and why do we differentiate between example submissions and other submissions? (Note that I don't want to argue that we should do replacement for all submissions, rather I think that we should not touch any code at all).
In most cases text replacement is just inconvenient. We already restrict validators to c++ and python in both cases there are nicer ways to automagically introduce constants. For example in c++ we could add
constexpr <std::string_view,long long,double> <constant name> = <constant value>
and something similar in python. In latex, we could also introduce the constants as macros.I know that this makes constants more complicated to implement on the tooling side but IMO it is much more convenient for the user. (For markdown and
testdata.yaml
i have no better idea...)The text was updated successfully, but these errors were encountered: