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

Prepare release 0.5.0 #26

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
<artifactId>jackson-databind</artifactId>
<version>2.17.0</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
</dependency>

</dependencies>
<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import life.qbic.data.processing.Provenance;
import life.qbic.data.processing.Provenance.ProvenanceException;
import life.qbic.data.processing.config.RoundRobinDraw;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.Logger;

/**
Expand Down Expand Up @@ -151,13 +152,25 @@ private void evaluateDirectory(File taskDir) {
LOG.error("Could not update provenance file: {}", taskDir.getAbsolutePath(), e);
moveToSystemIntervention(taskDir, e.getMessage());
}
moveToTargetDir(taskDir);
try {
copyToTargetDir(taskDir);
} catch (IOException e) {
LOG.error("Could not copy to target directory: {}", taskDir.getAbsolutePath(), e);
moveToSystemIntervention(taskDir,
"Cannot copy task to target directory: %s".formatted(assignedTargetDirectory));
}
try {
createMarkerFile(assignedTargetDirectory, taskDir.getName());
} catch (IOException e) {
LOG.error("Could not create marker file in: {}", assignedTargetDirectory, e);
moveToSystemIntervention(taskDir, e.getMessage());
}
try {
cleanup(taskDir);
} catch (IOException e) {
LOG.error("Could not clean up task directory: {}", taskDir.getAbsolutePath(), e);
moveToSystemIntervention(taskDir, e.getMessage());
}
return;
}
var errorMessage = ErrorSummary.createSimple(taskDir.getName(),
Expand All @@ -170,6 +183,11 @@ private void evaluateDirectory(File taskDir) {
moveBackToOrigin(taskDir, provenance, errorMessage.toString());
}

private void cleanup(File taskDir) throws IOException {
LOG.info("Deleting task directory: {}", taskDir.getAbsolutePath());
FileUtils.deleteDirectory(taskDir);
}

private void updateProvenanceFile(File provenanceFile, Provenance provenance) throws IOException {
var mapper = new ObjectMapper();
mapper.writerWithDefaultPrettyPrinter().writeValue(provenanceFile, provenance);
Expand Down Expand Up @@ -209,18 +227,11 @@ private void moveBackToOrigin(File taskDir, Provenance provenance, String reason
}
}

private void moveToTargetDir(File taskDir) {
private void copyToTargetDir(File taskDir) throws IOException {
LOG.info(
"Moving %s to target directory %s".formatted(taskDir.getAbsolutePath(),
"Copying %s to target directory %s".formatted(taskDir.getAbsolutePath(),
assignedTargetDirectory));
try {
Files.move(taskDir.toPath(), assignedTargetDirectory.resolve(taskDir.getName()));
} catch (IOException e) {
LOG.error("Cannot move task to target directory: %s".formatted(assignedTargetDirectory), e);
moveToSystemIntervention(taskDir,
"Cannot move task to target directory: %s".formatted(assignedTargetDirectory));
}

FileUtils.copyDirectory(taskDir, assignedTargetDirectory.resolve(taskDir.getName()).toFile());
}

private List<File> tasks() {
Expand Down
Loading