mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:46:30 +00:00
fix datasetexplorer view
save annotation with detections fix sending to queue
This commit is contained in:
@@ -19,8 +19,13 @@ public class AnnotationImageView(Annotation annotation) : INotifyPropertyChanged
|
||||
Task.Run(async () => Thumbnail = await Annotation.ThumbPath.OpenImage());
|
||||
return _thumbnail;
|
||||
}
|
||||
private set => _thumbnail = value;
|
||||
private set
|
||||
{
|
||||
_thumbnail = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string ImageName => Path.GetFileName(Annotation.ImagePath);
|
||||
|
||||
public void Delete()
|
||||
|
||||
@@ -8,6 +8,7 @@ using Azaion.Common.DTO.Queue;
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
using Azaion.CommonSecurity.Services;
|
||||
using LinqToDB;
|
||||
using LinqToDB.Data;
|
||||
using MediatR;
|
||||
using MessagePack;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -67,7 +68,7 @@ public class AnnotationService
|
||||
//Queue (only from operators)
|
||||
public async Task Consume(AnnotationCreatedMessage message, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (message.CreatedRole == RoleEnum.Validator) //Don't proceed our own messages (or from another Validator)
|
||||
if (message.CreatedRole != RoleEnum.Operator) //Process only operator's messages
|
||||
return;
|
||||
|
||||
await SaveAnnotationInner(
|
||||
@@ -104,6 +105,8 @@ public class AnnotationService
|
||||
? AnnotationStatus.Validated
|
||||
: AnnotationStatus.Created;
|
||||
|
||||
await db.Detections.DeleteAsync(x => x.AnnotationName == fName, token: token);
|
||||
await db.BulkCopyAsync(detections, cancellationToken: token);
|
||||
if (ann != null)
|
||||
await db.Annotations
|
||||
.Where(x => x.Name == fName)
|
||||
|
||||
@@ -65,12 +65,14 @@ public class FailsafeAnnotationsProducer
|
||||
.Where(x => x.Status == AnnotationStatus.Created)
|
||||
.Select(x => new Message(MessagePackSerializer.Serialize(x)))
|
||||
.ToList();
|
||||
if (createdMessages.Any())
|
||||
await _annotationProducer.Send(createdMessages, CompressionType.Gzip);
|
||||
|
||||
var validatedMessages = messagesChunk
|
||||
.Where(x => x.Status == AnnotationStatus.Validated)
|
||||
.Select(x => new Message(MessagePackSerializer.Serialize(x)))
|
||||
.ToList();
|
||||
if (validatedMessages.Any())
|
||||
await _annotationConfirmProducer.Send(validatedMessages, CompressionType.Gzip);
|
||||
|
||||
await _dbFactory.Run(async db =>
|
||||
@@ -80,10 +82,12 @@ public class FailsafeAnnotationsProducer
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, e.Message);
|
||||
await Task.Delay(TimeSpan.FromSeconds(30), cancellationToken);
|
||||
}
|
||||
await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);
|
||||
}
|
||||
await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);
|
||||
}
|
||||
}
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +95,8 @@ public class FailsafeAnnotationsProducer
|
||||
{
|
||||
return await _dbFactory.Run(async db =>
|
||||
{
|
||||
var annotations = await db.AnnotationsQueue.Join(db.Annotations, aq => aq.Name, a => a.Name, (aq, a) => a)
|
||||
var annotations = await db.AnnotationsQueue.Join(
|
||||
db.Annotations.LoadWith(x => x.Detections), aq => aq.Name, a => a.Name, (aq, a) => a)
|
||||
.ToListAsync(token: cancellationToken);
|
||||
|
||||
var messages = new List<AnnotationCreatedMessage>();
|
||||
@@ -105,10 +110,13 @@ public class FailsafeAnnotationsProducer
|
||||
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
|
||||
Source = annotation.Source,
|
||||
|
||||
};
|
||||
messages.Add(annCreateMessage);
|
||||
}
|
||||
|
||||
@@ -118,13 +118,6 @@ public partial class App
|
||||
services.AddSingleton<VLCFrameExtractor>();
|
||||
services.AddSingleton<IDbFactory, DbFactory>();
|
||||
|
||||
services.AddHttpClient<AzaionApiClient>((sp, client) =>
|
||||
{
|
||||
var apiConfig = sp.GetRequiredService<IOptions<ApiConfig>>().Value;
|
||||
client.BaseAddress = new Uri(apiConfig.Url);
|
||||
client.Timeout = TimeSpan.FromSeconds(apiConfig.TimeoutSeconds);
|
||||
});
|
||||
|
||||
services.AddSingleton<FailsafeAnnotationsProducer>();
|
||||
|
||||
services.AddSingleton<AnnotationService>();
|
||||
|
||||
Reference in New Issue
Block a user