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

Improve functionality for preparing tasks to be sent to sandbox #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

OAarne
Copy link
Collaborator

@OAarne OAarne commented Jul 27, 2017

Add CLI command for preparing tasks to be sent to sandbox and implement the functionality in TaskExecutorImpl.

Copy link
Member

@ljleppan ljleppan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, looking good!

Most of my comments are super nitpicky stuff about whitespace and line widths.

The tar thing seems pretty tricky: I don't really have any good suggestions on how to deal with it. I'll be happy with anything that @nygrenh is happy with :)

try {
tarCreator.createTarFromProject(tempdir, tmcLangsPath, tmcRunPath, outputPath);
} catch (ArchiveException ex) {
java.util.logging.Logger.getLogger(TaskExecutorImpl.class.getName()).log(Level.SEVERE, null, ex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a log message that says what project failed. Perhaps "Failed to create tar from project {}" where {} is either a project name, path or something like that?

@@ -134,6 +134,8 @@ ValidationResult checkCodeStyle(Path path, Locale messageLocale)
* @return The compressed file as a byte array.
*/
byte[] compressProject(Path path) throws IOException;


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra whitespace

<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a long time since I've actually compiled any code for this project: @nygrenh, are we running maven 2 or 3?

I'm asking 'cause maven 3 does not support the RELEASE metaversion. As there is already a dependency for junit on lines 46-50, I suggest we simply update the version number of that to the latest. That way we'll be compatible with both mvn2 and mvn3.

logger.error(
"An error occurred while preparing task.", e);
printErrAndExit(
"ERROR: Could not prepare task."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the logger.error() and printErrAndExit() calls in this chunk of changes probably fit on single lines.

@@ -140,4 +153,6 @@ public void clean(Path path) throws NoLanguagePluginFoundException {
private LanguagePlugin getLanguagePlugin(Path path) throws NoLanguagePluginFoundException {
return ProjectType.getProjectType(path).getLanguagePlugin();
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra whitespace

Path outputDirectory = Files.createTempDirectory("output-directory");
Path outputPath = new File("/tmp/output.tar").toPath();//outputDirectory.resolve("output.tar");
Path tmcRunPath = new File("/home/local/onniaarn/Visulahti.R").toPath();//Files.createTempFile("fake-tmc-run", ".sh");
Path tmcLangsPath = new File("/home/local/onniaarn/Projects/tmc-langs/tmc-langs-cli/target/tmc-langs-cli-0.7.7-SNAPSHOT.jar").toPath();//Files.createTempFile("fake-tmc-langs", ".jar");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These paths seem weird.

import fi.helsinki.cs.tmc.langs.java.ant.AntPlugin;
import fi.helsinki.cs.tmc.langs.utils.TestUtils;

import java.io.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid wild-card imports.

executor.prepareSandboxTask(exercisePath, submissionPath, outputPath, tmcRunPath, tmcLangsPath);
Path testDirectory = Files.createTempDirectory("test-directory");

Process untarringProcess = new ProcessBuilder("tar", "-C", testDirectory.toString(), "-xf", outputPath.toString()).start();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tricky one. I don't think this'll work on Windows as-is, but at the same time any other solution is going to be incredibly annoying to implement and have other, almost as significant downsides.

Can we somehow check if tar is available on the system and only run the test then, perhaps outputting a warning or something such if it's not available?

ping @nygrenh

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The offending test is now set to be skipped if the functionality is not available, i.e. when on Windows. Shouldn't be an issue since the code will only ever be deployed to Linux. This solution is @nygrenh approved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -16,13 +16,19 @@
import com.google.common.base.Optional;

import org.apache.commons.compress.archivers.ArchiveException;

import org.codehaus.plexus.util.FileUtils;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra whitespace

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? It's a unique domain, so it's surrounded by empty lines just like the other unique domains in the imports.

Copy link
Member

@ljleppan ljleppan Jul 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Seems that we've been using styles for imports even within this project. Better keep it the way it's now to keep the style consistent within the file.

@OAarne OAarne force-pushed the prepareSandboxTask branch 2 times, most recently from 9628f92 to 607b323 Compare July 28, 2017 13:08
@ljleppan
Copy link
Member

ljleppan commented Jul 28, 2017

Good job, LGTM!

I'll let @nygrenh do the actual merge.

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.

3 participants