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

Provide option to directly zip the output files #885

Merged

Conversation

staudtMarius
Copy link
Member

Resolves #793

@staudtMarius staudtMarius added the enhancement New feature or request label Aug 6, 2024
@staudtMarius staudtMarius self-assigned this Aug 6, 2024
Copy link
Member

@danielfeismann danielfeismann left a 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?

Copy link
Member

@danielfeismann danielfeismann left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@danielfeismann
Copy link
Member

!test

@danielfeismann danielfeismann merged commit ab53b8c into dev Sep 23, 2024
4 checks passed
@danielfeismann danielfeismann deleted the ms/#793-provide-option-to-direlty-zip-output-files branch September 23, 2024 07:35
Comment on lines +65 to +94
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)
}
}
}

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide option to directly zip the output files
3 participants