cms
cms copied to clipboard
Command line utils for submitting solutions
The web interface looks very nice until you have several minutes until the contest finishes, where you want to submit as fast as possible (even seconds matter). It would be nice to have some simple script out-of-the-box which allows to submit solutions from command line. As an optional feature this script can wait for result of the evaluation and show it in command line (or using some simple GUI tools that available in the operating system).
That's a very good idea. Here are my thoughts on it.
Authentication. The credentials can either be given as command line arguments / read from stdin or stored in a configuration file. The script then makes a request to the login handler of CWS, gets the cookie, ignores the rest of the response, and uses that cookie in subsequent requests. It's a bit "dirty" but it should work.
Selecting task and collecting files. The task name has to be given in some way but the individual file names may not: the script could automatically get the submission format and try to match it with the files in a certain directory (given by the user) to obtain the programming language and the files to submit.
Submitting files. As part of #152 I'm writing a SubmitHandler that accepts files encoded in JSON instead of HTML-form-syntax. It also returns data in JSON, instead of redirecting to another HTML page. That may help.
If the script will do authentication each time it runs, this will add some extra time for submission, and at the end of contest this time matters. I would propose to reduce everything to as small number of requests as possible. Here are my thoughts.
To reduce number of request we can store the cookie somewhere in the filesystem and reuse it next time script runs (until it's expired and we had to authenticate again). Another solution is a secret key which won't expire and will uniquely identify the user. And the third one is to add a new ConsoleSubmissionHandler which will merge LoginHandler and SubmissionHandler, so login and password will be provided along with submission.
Providing credentials and selecting the task can be also done in several ways:
- provide them in command line parameters (yes, it's not good to put password here, but the computer will not be used by anyone else during the contest)
- provide them from stdin in interactive mode
- provide them in configuration file
- store them in the script itself
If we store all submission related metadata in the script itself, everything is reduced to one script and become more simple to deploy (for example, user can just download it from the web interface).
If everything is stored in the script or in the configuration file, it can be automatically generated and made available from the web interface (or pre-deployed on the contestant machine, if there is such option).
Given that the target is to make submission as fast as possible in the latest instants of the contenst, here you have my suggestions for the implementation.
- Do not ask for anything in the comand line or environment; you do not want to get the right format when you have 10 seconds for fixing and submitting. Also, do nothing interactive, for the same reason. What you want is to configure your program at the beginning of the contest and use it seamlessly for the rest of it.
- Take the configuration from a static file somewhere is the user's home. According to best practices it should be something like
~/.config/cmssubmitter, but using dot-files would probably be confusing for non-Linux-expert contestants. Given moreover the very temporary scope of such data, probably something~/cmssubmitter.txtis ok. I expect to find username and password there. Maybe the cached cookie as well, if you want to retain it and don't want to mess around with another file. - I would take the task name from the command line. If it is not specified, I would fall back to the basename of the CWD.
- I would assume that files are taken relative to the CWD, consulting the submission format to know which of them are to submit. Notice, however, that there may be need for some way to avoid submitting some of them (for example, if it is an output-only task you don't want to submit again big files that you have already submitted and didn't change since then; this cause useless stress on network and CMS server). This may implemented with command line options.
- I would make it scriptable: return 0 if submission was ok, print on stderr and return != 0 is it wasn't. Verbose flag may be useful as well.
At IOI 2024, we used a similar thing: https://github.com/ioi-2024/ioisubmit
It's currently too specific for the IOI, but perhaps it could be generalized.