-
Notifications
You must be signed in to change notification settings - Fork 6
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
Provide option to directly zip the output files #885
Provide option to directly zip the output files #885
Conversation
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.
This looks quite fine, however I should have been a bit more precise. Sorry. It would be better, if only the single output files got zipped within rawOutputData. e.g. pv_res.tar.gz.
Could you please adapt this?
…zip-output-files # Conflicts: # CHANGELOG.md
…zip-output-files # Conflicts: # CHANGELOG.md
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.
LGTM, thanks!
!test |
val config = SimonaConfig(simonaSetup.typeSafeConfig).simona.output | ||
|
||
config.sink.csv.map(_.zipFiles).foreach { zipFiles => | ||
if (zipFiles) { | ||
val rawOutputPath = | ||
Path.of(simonaSetup.resultFileHierarchy.rawOutputDataDir) | ||
|
||
rawOutputPath.toFile.listFiles().foreach { file => | ||
val fileName = file.getName | ||
val archiveName = fileName.replace(".csv", "") | ||
val filePath = rawOutputPath.resolve(fileName) | ||
|
||
val compressFuture = | ||
FileIOUtils | ||
.compressFile(filePath, rawOutputPath.resolve(archiveName)) | ||
.asScala | ||
compressFuture.onComplete { | ||
case Success(_) => | ||
FileIOUtils.deleteRecursively(filePath) | ||
case Failure(exception) => | ||
logger.error( | ||
s"Compression of output file to '$archiveName' has failed. Keep raw data.", | ||
exception, | ||
) | ||
} | ||
Await.ready(compressFuture, compressTimeoutDuration) | ||
} | ||
} | ||
} | ||
|
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.
Sorry, only looked into this now. Maybe this would've fit better inside ResultEventListener
while handling StopTimeout
(i.e. right before the listener stops). This might look pedantic, but I think it's better to keep functionality where it belongs structure-wise. Will provide a suggestion later.
Resolves #793