Skip to content

Commit

Permalink
Determine package output directory from package id
Browse files Browse the repository at this point in the history
  • Loading branch information
paytoncain committed Apr 30, 2024
1 parent 40a45e0 commit 9587530
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ public void process(PackingJob packingJob, Path outputDir, ProgressIndicator...
validatePackingJob(packingJob);

FileUtils.mkdir(outputDir);
Path packageOutputDir = outputDir.resolve(((Dataset) packingJob).getPackageId());
FileUtils.mkdir(packageOutputDir);

Stream<PackageInstruction> instructionStream = PackageInstructionFactory.getPackageInstructions(
packingJob,
FileUtils.writeMetadata((Dataset) packingJob, objectMapper, outputDir.resolve("data")),
outputDir
FileUtils.writeMetadata((Dataset) packingJob, objectMapper, packageOutputDir.resolve("data")),
packageOutputDir
);
long totalRecords = instructionStream.count() + 4L; // accounting for generated files

Expand All @@ -41,13 +43,13 @@ public void process(PackingJob packingJob, Path outputDir, ProgressIndicator...

instructionStream = PackageInstructionFactory.getPackageInstructions(
packingJob,
FileUtils.writeMetadata((Dataset) packingJob, objectMapper, outputDir.resolve("data")),
outputDir
FileUtils.writeMetadata((Dataset) packingJob, objectMapper, packageOutputDir.resolve("data")),
packageOutputDir
);

Packager.run(
instructionStream,
outputDir,
packageOutputDir,
progressIndicators
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void testProcess(
processor.process(packingJob, testOutputPath, progressIndicator);
verify(progressIndicator, times(expectedNumberOfInvocations + 5)).incrementProcessedRecords();

Path baseExpectedOutputPath = testOutputPath.resolve("data");
Path baseExpectedOutputPath = testOutputPath.resolve(((Dataset) packingJob).getPackageId()).resolve("data");

checkTargetPaths(packingJob.getBiologicalPath(), baseExpectedOutputPath.resolve("biological"));
checkTargetPaths(packingJob.getCalibrationDocumentsPath(), baseExpectedOutputPath.resolve("calibration"));
Expand All @@ -183,7 +183,7 @@ void testProcess(
(packingJob instanceof AudioDataset || packingJob instanceof CPodDataset) ? "acoustic_files" : "data_files"
));

String actualMetadata = FileUtils.readFileToString(testOutputPath.resolve("data").resolve(String.format(
String actualMetadata = FileUtils.readFileToString(baseExpectedOutputPath.resolve(String.format(
"%s.json", ((Dataset) packingJob).getPackageId()
)).toFile(), StandardCharsets.UTF_8);

Expand Down

0 comments on commit 9587530

Please sign in to comment.