-
Notifications
You must be signed in to change notification settings - Fork 26
I1179 create zip for submit + CI's #1180
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
base: develop
Are you sure you want to change the base?
Conversation
Move getIFiles() to EventFeedUtilities from RemoteContestAPIAdapter. This class converts a byte stream to a zip file and extracts the contents to a List of IFile objects. Add additional getIFiles(String) method to EventFeedUtilities to accept a BASE64 encoded string consisting of a ZIP file, then decode that and call the getIFiles(bte []) method. Change the CLICS 2023-04 submission service to accept the previous format (a list of BASE64 encoded files) for backward compatibility, and, also accept the correct format (BAS64 encoded ZIP file). The distinction is made by looking at the mime type of the FILE objects passed. Update pc2submit command line utility to put the source files into a zip file, then encode that as base64 and send it off. [This fix for pc2submit was provided by Nicky Gerritsen from the DOMjudge team.]
Setting the contest thaw time using the Contest Service PATCH facility was a bit of a black box and it was hard to determine what happened. Now, we provide better logging. In addition, we call the proper method to set the thaw time. CLICSContestInfo: be sure to include the configured thaw time value in the contest information notification message and the contests endpoint.
| String mimeType = firstFile.getMime(); | ||
|
|
||
| // TODO: deprecate this "if" part and leave the "else" part. JB | ||
| if(mimeType == null || "".equals(mimeType)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A zip with an empty mime is also allowed according to the spec, I think that's not handled now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you take a look at the comments in the PR, we are using the absence of the mime-type as a (temporary) indicator that the older version of pc2submit (submit) that did not zip the files is being used. We are keeping this in for now, since some images out there (ie the icpc2025 image) have the version of pc2submit that does not zip. It also does not include the mime-type, so that's how we can tell (for now). The only command line submit utilities that interact with the API are pc2submit (which has been fixed to add the mime-type and zip the files), and the playback utility, which is a private test utility.
After the next contest image cycle, we will remove the deprecated code and use the absence of the mime-type to indicate it's a zip file, as per the specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!
SamanwaySadhu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update steps to follow with how to set the credentials. Looks good otherwise!
clevengr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed src/edu/csus/ecs/pc2/clics/API202306/ContestService.java. Minor (somewhat trivial) comments on what I think are incorrect comments in the code...
| return Response.status(Status.NOT_MODIFIED).entity("Unable to set contest thaw time to " + thawTime.toString()).build(); | ||
| Date thawDate = thawTime.getTime(); | ||
| String thawStr = Utilities.getIso8601formatterWithMS().format(thawDate); | ||
| // get the local model's ContestInformation sincd we are modifying the thaw time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(trivial) typo: "sincd" -> "since"
| ContestInformation ci = model.getContestInformation(); | ||
| if (ci != null) { | ||
| // set the new start date/time into the ContestInformation | ||
| ci.setThawed(thawDate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preceding comment says we are setting the "new start date/time", but I don't think that's what's actually being set here. (Copy/paste without an update?)
clevengr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed src/edu/csus/ecs/pc2/clics/API202306/SubmissionService.java. Made one comment regarding handling of zero length files.
| if(fileData == null || fileData.length() == 0) { | ||
| // nice to put it in the log in case any questions come up. | ||
| log.info(user + " POSTing empty source submission on behalf of team " + team_id); | ||
|
|
||
| // return Response.status(Response.Status.BAD_REQUEST).entity("no file data specified for " + fileName).build(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR #1173 (handle zero-length files in WTI) includes support for PC2 Admin configuration of "Allow zero-length files?". Once that PR is approved and merged, the above block of code should probably check the ContestInformation configuration item to determine whether to allow a zero-length file. (Unless of course the above block of code actually gets deprecated and eliminated, as suggested above...)
clevengr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed src/edu/csus/ecs/pc2/convert/EventFeedUtilities.java. Made one comment on a trivial typo in a comment; otherwise looks good to me.
| public static List<IFile> getIFiles(String base64Data) { | ||
|
|
||
| // use the decoder to both check the validity of, and to store, the byte data. | ||
| // this will throw an IllegalArgumentException if the data is basd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment? ("basd"?)
clevengr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed all the code changes. Other than trivial issues like typos in comments (which I've noted separately), the code looks reasonable to me. Proceeding to runtime testing.
clevengr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completed a runtime test following the instructions in the PR (although the instructions were missing the information that I needed to have a valid .netrc file on my Windows box in order for pc2submit to work). Since I was able to view the submitted source code in the admin, it appears that the PR works as intended, so I'm approving it.
Description of what the PR does
Accepts CLICS 2023-06 compliant submissions that include the source code in a single BASE64 encoded ZIP file. To maintain backward compatibility, we also accept a submission containing an array of BASE64 encoded files if the mime type of the FILE object is null or empty.
getIFiles(byte [])toEventFeedUtilitiesfromRemoteContestAPIAdapter. This method (nowpublic static) converts a byte stream to a zip file and extracts the contents to aListofIFileobjects.getIFiles(String)method toEventFeedUtilitiesto accept a BASE64 encoded string consisting of a ZIP file, then decode that and call thegetIFiles(byte [])method.pc2submitcommand line utility to put the source files into a zip file, then encode that as base64 and send it off. [This fix forpc2submitwas provided by Nicky Gerritsen from the DOMjudge team.]ContestServiceto set the thaw time. Better logging. Better messages returned to user. Removed and handled outstanding TODO.Issue which the PR addresses
Fixed #1179
Environment in which the PR was developed (OS,IDE, Java version, etc.)
Windows 11
java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)
Precise steps for testing the PR (i.e., how to demonstrate that it works correctly)
Prerequisites:
requestspackage installed (pip install requests)SumitHello(SumH)SUBMITCREDENTIALSenvironment variable to yes so that the submit command will prompt you for the team's user and password:set SUBMITCREDENTIALS=yesbin/pc2submitcommand line Python submit utility, make a submission:python bin/pc2submit -y -u https://localhost:50443 -p B samps/src/hello.cpp