mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 22:26:31 +00:00
refactor external clients
put model batch size as parameter in config
This commit is contained in:
@@ -100,26 +100,40 @@ public class FailsafeAnnotationsProducer
|
||||
.ToListAsync(token: cancellationToken);
|
||||
|
||||
var messages = new List<AnnotationCreatedMessage>();
|
||||
var badImages = new List<string>();
|
||||
foreach (var annotation in annotations)
|
||||
{
|
||||
var image = await File.ReadAllBytesAsync(annotation.ImagePath, cancellationToken);
|
||||
var annCreateMessage = new AnnotationCreatedMessage
|
||||
try
|
||||
{
|
||||
Name = annotation.Name,
|
||||
OriginalMediaName = annotation.OriginalMediaName,
|
||||
Time = annotation.Time,
|
||||
CreatedRole = annotation.CreatedRole,
|
||||
CreatedEmail = annotation.CreatedEmail,
|
||||
CreatedDate = annotation.CreatedDate,
|
||||
Status = annotation.AnnotationStatus,
|
||||
var image = await File.ReadAllBytesAsync(annotation.ImagePath, cancellationToken);
|
||||
var annCreateMessage = new AnnotationCreatedMessage
|
||||
{
|
||||
Name = annotation.Name,
|
||||
OriginalMediaName = annotation.OriginalMediaName,
|
||||
Time = annotation.Time,
|
||||
CreatedRole = annotation.CreatedRole,
|
||||
CreatedEmail = annotation.CreatedEmail,
|
||||
CreatedDate = annotation.CreatedDate,
|
||||
Status = annotation.AnnotationStatus,
|
||||
|
||||
ImageExtension = annotation.ImageExtension,
|
||||
Image = image,
|
||||
Detections = JsonConvert.SerializeObject(annotation.Detections),
|
||||
Source = annotation.Source,
|
||||
ImageExtension = annotation.ImageExtension,
|
||||
Image = image,
|
||||
Detections = JsonConvert.SerializeObject(annotation.Detections),
|
||||
Source = annotation.Source,
|
||||
};
|
||||
messages.Add(annCreateMessage);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, e.Message);
|
||||
badImages.Add(annotation.Name);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
messages.Add(annCreateMessage);
|
||||
if (badImages.Any())
|
||||
{
|
||||
await db.AnnotationsQueue.Where(x => badImages.Contains(x.Name)).DeleteAsync(token: cancellationToken);
|
||||
_dbFactory.SaveToDisk();
|
||||
}
|
||||
return messages;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user