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

Add basic reporting for import batch #4773

Merged
merged 3 commits into from
Mar 4, 2024

Conversation

imsdu
Copy link
Contributor

@imsdu imsdu commented Mar 4, 2024

No description provided.

val processorsMap = processors.foldLeft(Map.empty[EntityType, EventProcessor[_]]) { (acc, processor) =>
acc + (processor.resourceType -> processor)
}
eventStream
.evalTap { event =>
.evalScan(ImportReport.start) { case(report, event) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 👍

processorsMap.get(event.`type`) match {
case Some(processor) =>
processor.evaluate(event).onError { err =>
processor.evaluate(event)
.map { status =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it'll be useful to preserve, but could also do .attempt.map, log the errors and include a failure case with the error info, as well as dropped / success. I've done migrations like this and something like this can help to categorise classes of errors to know where to focus on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is meant to be just a first step meant to be enriched later when we import more cases and have a better grasp on how to handle error handling / error handling (with something similar to what you propose for example).

Comment on lines 58 to 65
val header = logger.info(s"Type\tSuccess\tDropped")
val detailedCount = report.progress.foldLeft(header) { case (acc, (entityType, count)) =>
acc >> logger.info(s"$entityType\t${count.success}\t${count.dropped}")
}

val aggregatedCount = report.aggregatedCount
logger.info(s"${aggregatedCount.success} events were imported up to offset ${report.offset} (${aggregatedCount.success} have been dropped).") >>
detailedCount
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also stick in a Show instance for the report and this becomes .flatTap(report => logger.info(report.show)). (Keeps this cleaner and you could dump it all in a file if needed)

@imsdu imsdu merged commit 28052e7 into BlueBrain:master Mar 4, 2024
9 checks passed
@imsdu imsdu deleted the import-add-basic-reporting branch March 4, 2024 14:07
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.

2 participants