mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 01:56:31 +00:00
huge queue refactoring:
3 queues -> 1 queue send delete validate updates
This commit is contained in:
@@ -243,9 +243,9 @@ public partial class Annotator
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var res = DgAnnotations.SelectedItems.Cast<AnnotationResult>().ToList();
|
var res = DgAnnotations.SelectedItems.Cast<AnnotationResult>().ToList();
|
||||||
var annotations = res.Select(x => x.Annotation).ToList();
|
var annotationNames = res.Select(x => x.Annotation.Name).ToList();
|
||||||
|
|
||||||
await _mediator.Publish(new AnnotationsDeletedEvent(annotations));
|
await _mediator.Publish(new AnnotationsDeletedEvent(annotationNames));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -555,6 +555,7 @@ public partial class Annotator
|
|||||||
|
|
||||||
LvFiles.Items.Refresh();
|
LvFiles.Items.Refresh();
|
||||||
IsInferenceNow = false;
|
IsInferenceNow = false;
|
||||||
|
StatusHelp.Text = "Розпізнавання зваершено";
|
||||||
AIDetectBtn.IsEnabled = true;
|
AIDetectBtn.IsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -278,15 +278,18 @@ public class AnnotatorEventHandler(
|
|||||||
|
|
||||||
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var annResDict = formState.AnnotationResults.ToDictionary(x => x.Annotation.Name, x => x);
|
var namesSet = notification.AnnotationNames.ToHashSet();
|
||||||
foreach (var ann in notification.Annotations)
|
|
||||||
{
|
|
||||||
if (!annResDict.TryGetValue(ann.Name, out var value))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
formState.AnnotationResults.Remove(value);
|
var remainAnnotations = formState.AnnotationResults
|
||||||
mainWindow.TimedAnnotations.Remove(ann);
|
.Where(x => !namesSet.Contains(x.Annotation?.Name ?? "")).ToList();
|
||||||
}
|
formState.AnnotationResults.Clear();
|
||||||
|
foreach (var ann in remainAnnotations)
|
||||||
|
formState.AnnotationResults.Add(ann);
|
||||||
|
|
||||||
|
var timedAnnsToRemove = mainWindow.TimedAnnotations
|
||||||
|
.Where(x => namesSet.Contains(x.Value.Name))
|
||||||
|
.Select(x => x.Value).ToList();
|
||||||
|
mainWindow.TimedAnnotations.Remove(timedAnnsToRemove);
|
||||||
|
|
||||||
if (formState.AnnotationResults.Count == 0)
|
if (formState.AnnotationResults.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -307,7 +310,7 @@ public class AnnotatorEventHandler(
|
|||||||
mainWindow.AddAnnotation(e.Annotation);
|
mainWindow.AddAnnotation(e.Annotation);
|
||||||
|
|
||||||
var log = string.Join(Environment.NewLine, e.Annotation.Detections.Select(det =>
|
var log = string.Join(Environment.NewLine, e.Annotation.Detections.Select(det =>
|
||||||
$"Розпізнавання: {annotationConfig.Value.DetectionClassesDict[det.ClassNumber].ShortName}: " +
|
$"Розпізнавання {e.Annotation.OriginalMediaName}: {annotationConfig.Value.DetectionClassesDict[det.ClassNumber].ShortName}: " +
|
||||||
$"xy=({det.CenterX:F2},{det.CenterY:F2}), " +
|
$"xy=({det.CenterX:F2},{det.CenterY:F2}), " +
|
||||||
$"розмір=({det.Width:F2}, {det.Height:F2}), " +
|
$"розмір=({det.Width:F2}, {det.Height:F2}), " +
|
||||||
$"conf: {det.Confidence*100:F0}%"));
|
$"conf: {det.Confidence*100:F0}%"));
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
|
||||||
using Azaion.Common.Database;
|
|
||||||
using Azaion.Common.DTO;
|
using Azaion.Common.DTO;
|
||||||
using Azaion.Common.DTO.Config;
|
using Azaion.Common.DTO.Config;
|
||||||
using Azaion.Common.Extensions;
|
using Azaion.Common.Extensions;
|
||||||
@@ -10,7 +8,7 @@ namespace Azaion.Common;
|
|||||||
public class Constants
|
public class Constants
|
||||||
{
|
{
|
||||||
public const string JPG_EXT = ".jpg";
|
public const string JPG_EXT = ".jpg";
|
||||||
|
public const string TXT_EXT = ".txt";
|
||||||
#region DirectoriesConfig
|
#region DirectoriesConfig
|
||||||
|
|
||||||
public const string DEFAULT_VIDEO_DIR = "video";
|
public const string DEFAULT_VIDEO_DIR = "video";
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class AnnotationThumbnail(Annotation annotation) : INotifyPropertyChanged
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string ImageName => Path.GetFileName(Annotation.ImagePath);
|
public string ImageName => Path.GetFileName(Annotation.ImagePath);
|
||||||
|
public string CreatedEmail => Annotation.CreatedEmail;
|
||||||
public bool IsSeed => Annotation.AnnotationStatus == AnnotationStatus.Created;
|
public bool IsSeed => Annotation.AnnotationStatus == AnnotationStatus.Created;
|
||||||
|
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Azaion.Common.DTO.Queue;
|
|||||||
using MessagePack;
|
using MessagePack;
|
||||||
|
|
||||||
[MessagePackObject]
|
[MessagePackObject]
|
||||||
public class AnnotationCreatedMessage
|
public class AnnotationMessage
|
||||||
{
|
{
|
||||||
[Key(0)] public DateTime CreatedDate { get; set; }
|
[Key(0)] public DateTime CreatedDate { get; set; }
|
||||||
[Key(1)] public string Name { get; set; } = null!;
|
[Key(1)] public string Name { get; set; } = null!;
|
||||||
@@ -14,14 +14,14 @@ public class AnnotationCreatedMessage
|
|||||||
[Key(4)] public string ImageExtension { get; set; } = null!;
|
[Key(4)] public string ImageExtension { get; set; } = null!;
|
||||||
[Key(5)] public string Detections { get; set; } = null!;
|
[Key(5)] public string Detections { get; set; } = null!;
|
||||||
[Key(6)] public byte[] Image { get; set; } = null!;
|
[Key(6)] public byte[] Image { get; set; } = null!;
|
||||||
[Key(7)] public RoleEnum CreatedRole { get; set; }
|
[Key(7)] public RoleEnum Role { get; set; }
|
||||||
[Key(8)] public string CreatedEmail { get; set; } = null!;
|
[Key(8)] public string Email { get; set; } = null!;
|
||||||
[Key(9)] public SourceEnum Source { get; set; }
|
[Key(9)] public SourceEnum Source { get; set; }
|
||||||
[Key(10)] public AnnotationStatus Status { get; set; }
|
[Key(10)] public AnnotationStatus Status { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[MessagePackObject]
|
[MessagePackObject]
|
||||||
public class AnnotationValidatedMessage
|
public class AnnotationBulkMessage
|
||||||
{
|
{
|
||||||
[Key(0)] public string Name { get; set; } = null!;
|
[Key(0)] public string[] AnnotationNames { get; set; } = null!;
|
||||||
}
|
}
|
||||||
@@ -59,5 +59,7 @@ public enum AnnotationStatus
|
|||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Created = 10,
|
Created = 10,
|
||||||
Validated = 20
|
Validated = 20,
|
||||||
|
ValidatedEdited = 25,
|
||||||
|
Deleted = 30
|
||||||
}
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace Azaion.Common.Database;
|
|
||||||
|
|
||||||
public class AnnotationName
|
|
||||||
{
|
|
||||||
public string Name { get; set; } = null!;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Azaion.Common.Database;
|
||||||
|
|
||||||
|
public class AnnotationQueueRecord
|
||||||
|
{
|
||||||
|
public DateTime DateTime { get; set; }
|
||||||
|
public AnnotationStatus Operation { get; set; }
|
||||||
|
public List<string> AnnotationNames { get; set; } = null!;
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ namespace Azaion.Common.Database;
|
|||||||
public class AnnotationsDb(DataOptions dataOptions) : DataConnection(dataOptions)
|
public class AnnotationsDb(DataOptions dataOptions) : DataConnection(dataOptions)
|
||||||
{
|
{
|
||||||
public ITable<Annotation> Annotations => this.GetTable<Annotation>();
|
public ITable<Annotation> Annotations => this.GetTable<Annotation>();
|
||||||
public ITable<AnnotationName> AnnotationsQueue => this.GetTable<AnnotationName>();
|
public ITable<AnnotationQueueRecord> AnnotationsQueueRecords => this.GetTable<AnnotationQueueRecord>();
|
||||||
public ITable<Detection> Detections => this.GetTable<Detection>();
|
public ITable<Detection> Detections => this.GetTable<Detection>();
|
||||||
public ITable<QueueOffset> QueueOffsets => this.GetTable<QueueOffset>();
|
public ITable<QueueOffset> QueueOffsets => this.GetTable<QueueOffset>();
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ using LinqToDB.DataProvider.SQLite;
|
|||||||
using LinqToDB.Mapping;
|
using LinqToDB.Mapping;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Azaion.Common.Database;
|
namespace Azaion.Common.Database;
|
||||||
|
|
||||||
@@ -17,7 +18,6 @@ public interface IDbFactory
|
|||||||
Task<T> Run<T>(Func<AnnotationsDb, Task<T>> func);
|
Task<T> Run<T>(Func<AnnotationsDb, Task<T>> func);
|
||||||
Task Run(Func<AnnotationsDb, Task> func);
|
Task Run(Func<AnnotationsDb, Task> func);
|
||||||
void SaveToDisk();
|
void SaveToDisk();
|
||||||
Task DeleteAnnotations(List<Annotation> annotations, CancellationToken cancellationToken = default);
|
|
||||||
Task DeleteAnnotations(List<string> annotationNames, CancellationToken cancellationToken = default);
|
Task DeleteAnnotations(List<string> annotationNames, CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class DbFactory : IDbFactory
|
|||||||
SQLiteConnection.CreateFile(_annConfig.AnnotationsDbFile);
|
SQLiteConnection.CreateFile(_annConfig.AnnotationsDbFile);
|
||||||
using var db = new AnnotationsDb(_fileDataOptions);
|
using var db = new AnnotationsDb(_fileDataOptions);
|
||||||
db.CreateTable<Annotation>();
|
db.CreateTable<Annotation>();
|
||||||
db.CreateTable<AnnotationName>();
|
db.CreateTable<AnnotationQueueRecord>();
|
||||||
db.CreateTable<Detection>();
|
db.CreateTable<Detection>();
|
||||||
db.CreateTable<QueueOffset>();
|
db.CreateTable<QueueOffset>();
|
||||||
db.QueueOffsets.BulkCopy(new List<QueueOffset>
|
db.QueueOffsets.BulkCopy(new List<QueueOffset>
|
||||||
@@ -98,12 +98,6 @@ public class DbFactory : IDbFactory
|
|||||||
_memoryConnection.BackupDatabase(_fileConnection, "main", "main", -1, null, -1);
|
_memoryConnection.BackupDatabase(_fileConnection, "main", "main", -1, null, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteAnnotations(List<Annotation> annotations, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
var names = annotations.Select(x => x.Name).ToList();
|
|
||||||
await DeleteAnnotations(names, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task DeleteAnnotations(List<string> annotationNames, CancellationToken cancellationToken = default)
|
public async Task DeleteAnnotations(List<string> annotationNames, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
await Run(async db =>
|
await Run(async db =>
|
||||||
@@ -142,8 +136,11 @@ public static class AnnotationsDbSchemaHolder
|
|||||||
builder.Entity<Detection>()
|
builder.Entity<Detection>()
|
||||||
.HasTableName(Constants.DETECTIONS_TABLENAME);
|
.HasTableName(Constants.DETECTIONS_TABLENAME);
|
||||||
|
|
||||||
builder.Entity<AnnotationName>()
|
builder.Entity<AnnotationQueueRecord>()
|
||||||
.HasTableName(Constants.ANNOTATIONS_QUEUE_TABLENAME);
|
.HasTableName(Constants.ANNOTATIONS_QUEUE_TABLENAME)
|
||||||
|
.Property(x => x.AnnotationNames)
|
||||||
|
.HasDataType(DataType.NVarChar)
|
||||||
|
.HasConversion(list => JsonConvert.SerializeObject(list), str => JsonConvert.DeserializeObject<List<string>>(str) ?? new List<string>());
|
||||||
|
|
||||||
builder.Build();
|
builder.Build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ using MediatR;
|
|||||||
|
|
||||||
namespace Azaion.Common.Events;
|
namespace Azaion.Common.Events;
|
||||||
|
|
||||||
public class AnnotationsDeletedEvent(List<Annotation> annotations) : INotification
|
public class AnnotationsDeletedEvent(List<string> annotationNames, bool fromQueue = false) : INotification
|
||||||
{
|
{
|
||||||
public List<Annotation> Annotations { get; set; } = annotations;
|
public List<string> AnnotationNames { get; set; } = annotationNames;
|
||||||
|
public bool FromQueue { get; set; } = fromQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AnnotationAddedEvent(Annotation annotation) : INotification
|
public class AnnotationAddedEvent(Annotation annotation) : INotification
|
||||||
|
|||||||
@@ -30,13 +30,16 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
private readonly QueueConfig _queueConfig;
|
private readonly QueueConfig _queueConfig;
|
||||||
private Consumer _consumer = null!;
|
private Consumer _consumer = null!;
|
||||||
private readonly UIConfig _uiConfig;
|
private readonly UIConfig _uiConfig;
|
||||||
|
private readonly DirectoriesConfig _dirConfig;
|
||||||
private static readonly Guid SaveTaskId = Guid.NewGuid();
|
private static readonly Guid SaveTaskId = Guid.NewGuid();
|
||||||
|
private static readonly Guid SaveQueueOffsetTaskId = Guid.NewGuid();
|
||||||
|
|
||||||
public AnnotationService(
|
public AnnotationService(
|
||||||
IDbFactory dbFactory,
|
IDbFactory dbFactory,
|
||||||
FailsafeAnnotationsProducer producer,
|
FailsafeAnnotationsProducer producer,
|
||||||
IOptions<QueueConfig> queueConfig,
|
IOptions<QueueConfig> queueConfig,
|
||||||
IOptions<UIConfig> uiConfig,
|
IOptions<UIConfig> uiConfig,
|
||||||
|
IOptions<DirectoriesConfig> directoriesConfig,
|
||||||
IGalleryService galleryService,
|
IGalleryService galleryService,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IAzaionApi api)
|
IAzaionApi api)
|
||||||
@@ -48,11 +51,12 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
_api = api;
|
_api = api;
|
||||||
_queueConfig = queueConfig.Value;
|
_queueConfig = queueConfig.Value;
|
||||||
_uiConfig = uiConfig.Value;
|
_uiConfig = uiConfig.Value;
|
||||||
|
_dirConfig = directoriesConfig.Value;
|
||||||
|
|
||||||
Task.Run(async () => await Init()).Wait();
|
Task.Run(async () => await InitQueueConsumer()).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Init(CancellationToken cancellationToken = default)
|
private async Task InitQueueConsumer(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (!_api.CurrentUser.Role.IsValidator())
|
if (!_api.CurrentUser.Role.IsValidator())
|
||||||
return;
|
return;
|
||||||
@@ -72,18 +76,13 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
OffsetSpec = new OffsetTypeOffset(offsets.AnnotationsOffset + 1),
|
OffsetSpec = new OffsetTypeOffset(offsets.AnnotationsOffset + 1),
|
||||||
MessageHandler = async (_, _, context, message) =>
|
MessageHandler = async (_, _, context, message) =>
|
||||||
{
|
{
|
||||||
var msg = MessagePackSerializer.Deserialize<AnnotationCreatedMessage>(message.Data.Contents);
|
var email = (string)message.ApplicationProperties[nameof(User.Email)]!;
|
||||||
|
if (email == _api.CurrentUser.Email) //Don't process messages by yourself
|
||||||
offsets.AnnotationsOffset = context.Offset;
|
|
||||||
ThrottleExt.Throttle(() =>
|
|
||||||
{
|
|
||||||
_api.UpdateOffsets(offsets);
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}, SaveTaskId, TimeSpan.FromSeconds(10), scheduleCallAfterCooldown: true);
|
|
||||||
|
|
||||||
if (msg.CreatedEmail == _api.CurrentUser.Email) //Don't process messages by yourself
|
|
||||||
return;
|
return;
|
||||||
|
var annotationStatus = (AnnotationStatus)message.ApplicationProperties[nameof(AnnotationStatus)];
|
||||||
|
if (annotationStatus.In(AnnotationStatus.Created, AnnotationStatus.ValidatedEdited))
|
||||||
|
{
|
||||||
|
var msg = MessagePackSerializer.Deserialize<AnnotationMessage>(message.Data.Contents);
|
||||||
await SaveAnnotationInner(
|
await SaveAnnotationInner(
|
||||||
msg.CreatedDate,
|
msg.CreatedDate,
|
||||||
msg.OriginalMediaName,
|
msg.OriginalMediaName,
|
||||||
@@ -91,11 +90,27 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
JsonConvert.DeserializeObject<List<Detection>>(msg.Detections) ?? [],
|
JsonConvert.DeserializeObject<List<Detection>>(msg.Detections) ?? [],
|
||||||
msg.Source,
|
msg.Source,
|
||||||
new MemoryStream(msg.Image),
|
new MemoryStream(msg.Image),
|
||||||
msg.CreatedRole,
|
msg.Role,
|
||||||
msg.CreatedEmail,
|
msg.Email,
|
||||||
fromQueue: true,
|
fromQueue: true,
|
||||||
token: cancellationToken);
|
token: cancellationToken);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var msg = MessagePackSerializer.Deserialize<AnnotationBulkMessage>(message.Data.Contents);
|
||||||
|
if (annotationStatus == AnnotationStatus.Validated)
|
||||||
|
await ValidateAnnotations(msg.AnnotationNames.ToList(), true, cancellationToken);
|
||||||
|
if (annotationStatus == AnnotationStatus.Deleted)
|
||||||
|
await _mediator.Publish(new AnnotationsDeletedEvent(msg.AnnotationNames.ToList(), fromQueue:true), cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
offsets.AnnotationsOffset = context.Offset;
|
||||||
|
ThrottleExt.Throttle(() =>
|
||||||
|
{
|
||||||
|
_api.UpdateOffsets(offsets);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}, SaveQueueOffsetTaskId, TimeSpan.FromSeconds(10), scheduleCallAfterCooldown: true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +135,7 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
bool fromQueue = false,
|
bool fromQueue = false,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
AnnotationStatus status;
|
var status = AnnotationStatus.Created;
|
||||||
var fName = originalMediaName.ToTimeName(time);
|
var fName = originalMediaName.ToTimeName(time);
|
||||||
var annotation = await _dbFactory.Run(async db =>
|
var annotation = await _dbFactory.Run(async db =>
|
||||||
{
|
{
|
||||||
@@ -128,25 +143,41 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
.LoadWith(x => x.Detections)
|
.LoadWith(x => x.Detections)
|
||||||
.FirstOrDefaultAsync(x => x.Name == fName, token: token);
|
.FirstOrDefaultAsync(x => x.Name == fName, token: token);
|
||||||
|
|
||||||
status = userRole.IsValidator() && source == SourceEnum.Manual
|
if (userRole.IsValidator() && source == SourceEnum.Manual)
|
||||||
? AnnotationStatus.Validated
|
status = AnnotationStatus.Validated;
|
||||||
: AnnotationStatus.Created;
|
|
||||||
|
|
||||||
if (fromQueue && ann is { AnnotationStatus: AnnotationStatus.Validated })
|
if (fromQueue && ann is { AnnotationStatus: AnnotationStatus.Validated })
|
||||||
return ann;
|
return ann;
|
||||||
|
|
||||||
await db.Detections.DeleteAsync(x => x.AnnotationName == fName, token: token);
|
await db.Detections.DeleteAsync(x => x.AnnotationName == fName, token: token);
|
||||||
|
|
||||||
if (ann != null)
|
if (ann != null) //Annotation is already exists
|
||||||
{
|
{
|
||||||
await db.Annotations
|
var annotationUpdatable = db.Annotations
|
||||||
.Where(x => x.Name == fName)
|
.Where(x => x.Name == fName)
|
||||||
.Set(x => x.Source, source)
|
.Set(x => x.Source, source)
|
||||||
.Set(x => x.AnnotationStatus, status)
|
.Set(x => x.CreatedRole, userRole);
|
||||||
|
|
||||||
|
if (status == AnnotationStatus.Validated)
|
||||||
|
{
|
||||||
|
if (status == AnnotationStatus.Validated)
|
||||||
|
status = AnnotationStatus.ValidatedEdited; //For further processing mark Annotations *edited* by Validator, not just simply Validated by button.
|
||||||
|
|
||||||
|
annotationUpdatable = annotationUpdatable
|
||||||
|
.Set(x => x.ValidateDate, createdDate)
|
||||||
|
.Set(x => x.ValidateEmail, createdEmail);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
annotationUpdatable = annotationUpdatable
|
||||||
.Set(x => x.CreatedDate, createdDate)
|
.Set(x => x.CreatedDate, createdDate)
|
||||||
.Set(x => x.CreatedEmail, createdEmail)
|
.Set(x => x.CreatedEmail, createdEmail);
|
||||||
.Set(x => x.CreatedRole, userRole)
|
}
|
||||||
|
|
||||||
|
await annotationUpdatable
|
||||||
|
.Set(x => x.AnnotationStatus, status)
|
||||||
.UpdateAsync(token: token);
|
.UpdateAsync(token: token);
|
||||||
|
|
||||||
ann.Detections = detections;
|
ann.Detections = detections;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -184,10 +215,11 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
if (_uiConfig.GenerateAnnotatedImage)
|
if (_uiConfig.GenerateAnnotatedImage)
|
||||||
await _galleryService.CreateAnnotatedImage(annotation, token);
|
await _galleryService.CreateAnnotatedImage(annotation, token);
|
||||||
|
|
||||||
if (!fromQueue && !_uiConfig.SilentDetection) //Send to queue only if we're not getting from queue already
|
|
||||||
await _producer.SendToInnerQueue(annotation, token);
|
|
||||||
|
|
||||||
await _mediator.Publish(new AnnotationCreatedEvent(annotation), token);
|
await _mediator.Publish(new AnnotationCreatedEvent(annotation), token);
|
||||||
|
|
||||||
|
if (!fromQueue && !_uiConfig.SilentDetection) //Send to queue only if we're not getting from queue already
|
||||||
|
await _producer.SendToInnerQueue([annotation.Name], status, token);
|
||||||
|
|
||||||
ThrottleExt.Throttle(async () =>
|
ThrottleExt.Throttle(async () =>
|
||||||
{
|
{
|
||||||
_dbFactory.SaveToDisk();
|
_dbFactory.SaveToDisk();
|
||||||
@@ -196,12 +228,12 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
return annotation;
|
return annotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ValidateAnnotations(List<Annotation> annotations, CancellationToken token = default)
|
public async Task ValidateAnnotations(List<string> annotationNames, bool fromQueue = false, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!_api.CurrentUser.Role.IsValidator())
|
if (!_api.CurrentUser.Role.IsValidator())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var annNames = annotations.Select(x => x.Name).ToHashSet();
|
var annNames = annotationNames.ToHashSet();
|
||||||
await _dbFactory.Run(async db =>
|
await _dbFactory.Run(async db =>
|
||||||
{
|
{
|
||||||
await db.Annotations
|
await db.Annotations
|
||||||
@@ -211,6 +243,9 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
.Set(x => x.ValidateEmail, _api.CurrentUser.Email)
|
.Set(x => x.ValidateEmail, _api.CurrentUser.Email)
|
||||||
.UpdateAsync(token: token);
|
.UpdateAsync(token: token);
|
||||||
});
|
});
|
||||||
|
if (!fromQueue)
|
||||||
|
await _producer.SendToInnerQueue(annotationNames, AnnotationStatus.Validated, token);
|
||||||
|
|
||||||
ThrottleExt.Throttle(async () =>
|
ThrottleExt.Throttle(async () =>
|
||||||
{
|
{
|
||||||
_dbFactory.SaveToDisk();
|
_dbFactory.SaveToDisk();
|
||||||
@@ -218,15 +253,25 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
}, SaveTaskId, TimeSpan.FromSeconds(5), true);
|
}, SaveTaskId, TimeSpan.FromSeconds(5), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken ct)
|
||||||
{
|
{
|
||||||
await _dbFactory.DeleteAnnotations(notification.Annotations, cancellationToken);
|
await _dbFactory.DeleteAnnotations(notification.AnnotationNames, ct);
|
||||||
foreach (var annotation in notification.Annotations)
|
foreach (var name in notification.AnnotationNames)
|
||||||
{
|
{
|
||||||
File.Delete(annotation.ImagePath);
|
File.Delete(Path.Combine(_dirConfig.ImagesDirectory, $"{name}{Constants.JPG_EXT}"));
|
||||||
File.Delete(annotation.LabelPath);
|
File.Delete(Path.Combine(_dirConfig.LabelsDirectory, $"{name}{Constants.TXT_EXT}"));
|
||||||
File.Delete(annotation.ThumbPath);
|
File.Delete(Path.Combine(_dirConfig.ThumbnailsDirectory, $"{name}{Constants.THUMBNAIL_PREFIX}{Constants.JPG_EXT}"));
|
||||||
|
File.Delete(Path.Combine(_dirConfig.ResultsDirectory, $"{name}{Constants.RESULT_PREFIX}{Constants.JPG_EXT}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!notification.FromQueue)
|
||||||
|
await _producer.SendToInnerQueue(notification.AnnotationNames, AnnotationStatus.Deleted, ct);
|
||||||
|
|
||||||
|
ThrottleExt.Throttle(async () =>
|
||||||
|
{
|
||||||
|
_dbFactory.SaveToDisk();
|
||||||
|
await Task.CompletedTask;
|
||||||
|
}, SaveTaskId, TimeSpan.FromSeconds(5), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,6 +279,5 @@ public interface IAnnotationService
|
|||||||
{
|
{
|
||||||
Task<Annotation> SaveAnnotation(AnnotationImage a, CancellationToken ct = default);
|
Task<Annotation> SaveAnnotation(AnnotationImage a, CancellationToken ct = default);
|
||||||
Task<Annotation> SaveAnnotation(string originalMediaName, TimeSpan time, List<Detection> detections, Stream? stream = null, CancellationToken token = default);
|
Task<Annotation> SaveAnnotation(string originalMediaName, TimeSpan time, List<Detection> detections, Stream? stream = null, CancellationToken token = default);
|
||||||
Task ValidateAnnotations(List<Annotation> annotations, CancellationToken token = default);
|
Task ValidateAnnotations(List<string> annotationNames, bool fromQueue = false, CancellationToken token = default);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,12 +3,16 @@ using System.Net;
|
|||||||
using Azaion.Common.Database;
|
using Azaion.Common.Database;
|
||||||
using Azaion.Common.DTO.Config;
|
using Azaion.Common.DTO.Config;
|
||||||
using Azaion.Common.DTO.Queue;
|
using Azaion.Common.DTO.Queue;
|
||||||
|
using Azaion.Common.Extensions;
|
||||||
|
using Azaion.CommonSecurity.DTO;
|
||||||
|
using Azaion.CommonSecurity.Services;
|
||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
using MessagePack;
|
using MessagePack;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using RabbitMQ.Stream.Client;
|
using RabbitMQ.Stream.Client;
|
||||||
|
using RabbitMQ.Stream.Client.AMQP;
|
||||||
using RabbitMQ.Stream.Client.Reliable;
|
using RabbitMQ.Stream.Client.Reliable;
|
||||||
|
|
||||||
namespace Azaion.Common.Services;
|
namespace Azaion.Common.Services;
|
||||||
@@ -17,16 +21,15 @@ public class FailsafeAnnotationsProducer
|
|||||||
{
|
{
|
||||||
private readonly ILogger<FailsafeAnnotationsProducer> _logger;
|
private readonly ILogger<FailsafeAnnotationsProducer> _logger;
|
||||||
private readonly IDbFactory _dbFactory;
|
private readonly IDbFactory _dbFactory;
|
||||||
|
private readonly IAzaionApi _azaionApi;
|
||||||
private readonly QueueConfig _queueConfig;
|
private readonly QueueConfig _queueConfig;
|
||||||
|
|
||||||
private Producer _annotationProducer = null!;
|
private Producer _annotationProducer = null!;
|
||||||
private Producer _annotationConfirmProducer = null!;
|
|
||||||
|
|
||||||
|
public FailsafeAnnotationsProducer(ILogger<FailsafeAnnotationsProducer> logger, IDbFactory dbFactory, IOptions<QueueConfig> queueConfig, IAzaionApi azaionApi)
|
||||||
public FailsafeAnnotationsProducer(ILogger<FailsafeAnnotationsProducer> logger, IDbFactory dbFactory, IOptions<QueueConfig> queueConfig)
|
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_dbFactory = dbFactory;
|
_dbFactory = dbFactory;
|
||||||
|
_azaionApi = azaionApi;
|
||||||
_queueConfig = queueConfig.Value;
|
_queueConfig = queueConfig.Value;
|
||||||
Task.Run(async () => await ProcessQueue());
|
Task.Run(async () => await ProcessQueue());
|
||||||
}
|
}
|
||||||
@@ -41,78 +44,60 @@ public class FailsafeAnnotationsProducer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Init(CancellationToken cancellationToken = default)
|
private async Task ProcessQueue(CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
_annotationProducer = await Producer.Create(new ProducerConfig(await GetProducerQueueConfig(), Constants.MQ_ANNOTATIONS_QUEUE));
|
_annotationProducer = await Producer.Create(new ProducerConfig(await GetProducerQueueConfig(), Constants.MQ_ANNOTATIONS_QUEUE));
|
||||||
_annotationConfirmProducer = await Producer.Create(new ProducerConfig(await GetProducerQueueConfig(), Constants.MQ_ANNOTATIONS_CONFIRM_QUEUE));
|
while (!ct.IsCancellationRequested)
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ProcessQueue(CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
await Init(cancellationToken);
|
|
||||||
while (!cancellationToken.IsCancellationRequested)
|
|
||||||
{
|
|
||||||
var messages = await GetFromInnerQueue(cancellationToken);
|
|
||||||
foreach (var messagesChunk in messages.Chunk(10)) //Sending by 10
|
|
||||||
{
|
{
|
||||||
var sent = false;
|
var sent = false;
|
||||||
while (!sent || cancellationToken.IsCancellationRequested) //Waiting for send
|
while (!sent || !ct.IsCancellationRequested) //Waiting for send
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var createdMessages = messagesChunk
|
var result = await _dbFactory.Run(async db =>
|
||||||
.Where(x => x.Status == AnnotationStatus.Created)
|
{
|
||||||
.Select(x => new Message(MessagePackSerializer.Serialize(x)))
|
var records = await db.AnnotationsQueueRecords.OrderBy(x => x.DateTime).ToListAsync(token: ct);
|
||||||
|
var editedCreatedNames = records
|
||||||
|
.Where(x => x.Operation.In(AnnotationStatus.Created, AnnotationStatus.ValidatedEdited))
|
||||||
|
.Select(x => x.AnnotationNames.FirstOrDefault())
|
||||||
.ToList();
|
.ToList();
|
||||||
if (createdMessages.Any())
|
|
||||||
await _annotationProducer.Send(createdMessages, CompressionType.Gzip);
|
|
||||||
|
|
||||||
var validatedMessages = messagesChunk
|
var annotationsDict = await db.Annotations.LoadWith(x => x.Detections)
|
||||||
.Where(x => x.Status == AnnotationStatus.Validated)
|
.Where(x => editedCreatedNames.Contains(x.Name))
|
||||||
.Select(x => new Message(MessagePackSerializer.Serialize(x)))
|
.ToDictionaryAsync(a => a.Name, token: ct);
|
||||||
.ToList();
|
|
||||||
if (validatedMessages.Any())
|
|
||||||
await _annotationConfirmProducer.Send(validatedMessages, CompressionType.Gzip);
|
|
||||||
|
|
||||||
await _dbFactory.Run(async db =>
|
var messages = new List<Message>();
|
||||||
await db.AnnotationsQueue.DeleteAsync(aq => messagesChunk.Any(x => aq.Name == x.Name), token: cancellationToken));
|
foreach (var record in records)
|
||||||
sent = true;
|
|
||||||
_dbFactory.SaveToDisk();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
{
|
||||||
_logger.LogError(e, e.Message);
|
var appProperties = new ApplicationProperties
|
||||||
await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);
|
{
|
||||||
}
|
{ nameof(AnnotationStatus), record.Operation },
|
||||||
await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);
|
{ nameof(User.Email), _azaionApi.CurrentUser.Email }
|
||||||
}
|
};
|
||||||
}
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<List<AnnotationCreatedMessage>> GetFromInnerQueue(CancellationToken cancellationToken = default)
|
if (record.Operation.In(AnnotationStatus.Validated, AnnotationStatus.Deleted))
|
||||||
{
|
{
|
||||||
return await _dbFactory.Run(async db =>
|
var message = new Message(MessagePackSerializer.Serialize(new AnnotationBulkMessage
|
||||||
{
|
{
|
||||||
var annotations = await db.AnnotationsQueue.Join(
|
AnnotationNames = record.AnnotationNames.ToArray()
|
||||||
db.Annotations.LoadWith(x => x.Detections), aq => aq.Name, a => a.Name, (aq, a) => a)
|
})) { ApplicationProperties = appProperties };
|
||||||
.ToListAsync(token: cancellationToken);
|
|
||||||
|
|
||||||
var messages = new List<AnnotationCreatedMessage>();
|
messages.Add(message);
|
||||||
var badImages = new List<string>();
|
}
|
||||||
foreach (var annotation in annotations)
|
else
|
||||||
{
|
{
|
||||||
try
|
var annotation = annotationsDict.GetValueOrDefault(record.AnnotationNames.FirstOrDefault());
|
||||||
{
|
if (annotation == null)
|
||||||
var image = await File.ReadAllBytesAsync(annotation.ImagePath, cancellationToken);
|
continue;
|
||||||
var annCreateMessage = new AnnotationCreatedMessage
|
|
||||||
|
var image = await File.ReadAllBytesAsync(annotation.ImagePath, ct);
|
||||||
|
var annMessage = new AnnotationMessage
|
||||||
{
|
{
|
||||||
Name = annotation.Name,
|
Name = annotation.Name,
|
||||||
OriginalMediaName = annotation.OriginalMediaName,
|
OriginalMediaName = annotation.OriginalMediaName,
|
||||||
Time = annotation.Time,
|
Time = annotation.Time,
|
||||||
CreatedRole = annotation.CreatedRole,
|
Role = annotation.CreatedRole,
|
||||||
CreatedEmail = annotation.CreatedEmail,
|
Email = annotation.CreatedEmail,
|
||||||
CreatedDate = annotation.CreatedDate,
|
CreatedDate = annotation.CreatedDate,
|
||||||
Status = annotation.AnnotationStatus,
|
Status = annotation.AnnotationStatus,
|
||||||
|
|
||||||
@@ -121,27 +106,42 @@ public class FailsafeAnnotationsProducer
|
|||||||
Detections = JsonConvert.SerializeObject(annotation.Detections),
|
Detections = JsonConvert.SerializeObject(annotation.Detections),
|
||||||
Source = annotation.Source,
|
Source = annotation.Source,
|
||||||
};
|
};
|
||||||
messages.Add(annCreateMessage);
|
var message = new Message(MessagePackSerializer.Serialize(annMessage)) { ApplicationProperties = appProperties };
|
||||||
|
|
||||||
|
messages.Add(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (messages, records);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.messages.Any())
|
||||||
|
{
|
||||||
|
await _annotationProducer.Send(result.messages, CompressionType.Gzip);
|
||||||
|
await _dbFactory.Run(async db => await db.DeleteAsync(result.records, token: ct));
|
||||||
|
sent = true;
|
||||||
|
_dbFactory.SaveToDisk();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_logger.LogError(e, e.Message);
|
_logger.LogError(e, e.Message);
|
||||||
badImages.Add(annotation.Name);
|
await Task.Delay(TimeSpan.FromSeconds(10), ct);
|
||||||
}
|
}
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(10), ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(5), ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (badImages.Any())
|
public async Task SendToInnerQueue(List<string> annotationNames, AnnotationStatus status, CancellationToken cancellationToken = default)
|
||||||
{
|
|
||||||
await db.AnnotationsQueue.Where(x => badImages.Contains(x.Name)).DeleteAsync(token: cancellationToken);
|
|
||||||
_dbFactory.SaveToDisk();
|
|
||||||
}
|
|
||||||
return messages;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task SendToInnerQueue(Annotation annotation, CancellationToken cancellationToken = default)
|
|
||||||
{
|
{
|
||||||
await _dbFactory.Run(async db =>
|
await _dbFactory.Run(async db =>
|
||||||
await db.InsertAsync(new AnnotationName { Name = annotation.Name }, token: cancellationToken));
|
await db.InsertAsync(new AnnotationQueueRecord
|
||||||
|
{
|
||||||
|
DateTime = DateTime.UtcNow,
|
||||||
|
Operation = status,
|
||||||
|
AnnotationNames = annotationNames
|
||||||
|
}, token: cancellationToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ public class GpsMatcherClient : IGpsMatcherClient
|
|||||||
|
|
||||||
process.OutputDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
|
process.OutputDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
|
||||||
process.ErrorDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
|
process.ErrorDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
|
||||||
process.Start();
|
//process.Start();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,8 @@
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*"></RowDefinition>
|
<RowDefinition Height="*"></RowDefinition>
|
||||||
<RowDefinition Height="32"></RowDefinition>
|
<RowDefinition Height="18"></RowDefinition>
|
||||||
|
<RowDefinition Height="14"></RowDefinition>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Image
|
<Image
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
@@ -42,6 +43,11 @@
|
|||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Foreground="LightGray"
|
Foreground="LightGray"
|
||||||
Text="{Binding ImageName}" />
|
Text="{Binding ImageName}" />
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="2"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Foreground="Gray"
|
||||||
|
Text="{Binding CreatedEmail}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|||||||
@@ -273,10 +273,9 @@ public partial class DatasetExplorer
|
|||||||
if (result != MessageBoxResult.Yes)
|
if (result != MessageBoxResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var annotations = ThumbnailsView.SelectedItems.Cast<AnnotationThumbnail>().Select(x => x.Annotation)
|
var annotationNames = ThumbnailsView.SelectedItems.Cast<AnnotationThumbnail>().Select(x => x.Annotation.Name).ToList();
|
||||||
.ToList();
|
|
||||||
|
|
||||||
await _mediator.Publish(new AnnotationsDeletedEvent(annotations));
|
await _mediator.Publish(new AnnotationsDeletedEvent(annotationNames));
|
||||||
ThumbnailsView.SelectedIndex = Math.Min(SelectedAnnotations.Count, tempSelected);
|
ThumbnailsView.SelectedIndex = Math.Min(SelectedAnnotations.Count, tempSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class DatasetExplorerEventHandler(
|
|||||||
var annotations = datasetExplorer.ThumbnailsView.SelectedItems.Cast<AnnotationThumbnail>()
|
var annotations = datasetExplorer.ThumbnailsView.SelectedItems.Cast<AnnotationThumbnail>()
|
||||||
.Select(x => x.Annotation)
|
.Select(x => x.Annotation)
|
||||||
.ToList();
|
.ToList();
|
||||||
await annotationService.ValidateAnnotations(annotations, cancellationToken);
|
await annotationService.ValidateAnnotations(annotations.Select(x => x.Name).ToList(), token: cancellationToken);
|
||||||
foreach (var ann in datasetExplorer.SelectedAnnotations.Where(x => annotations.Contains(x.Annotation)))
|
foreach (var ann in datasetExplorer.SelectedAnnotations.Where(x => annotations.Contains(x.Annotation)))
|
||||||
{
|
{
|
||||||
ann.Annotation.AnnotationStatus = AnnotationStatus.Validated;
|
ann.Annotation.AnnotationStatus = AnnotationStatus.Validated;
|
||||||
@@ -143,9 +143,8 @@ public class DatasetExplorerEventHandler(
|
|||||||
|
|
||||||
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var names = notification.Annotations.Select(x => x.Name).ToList();
|
|
||||||
var annThumbs = datasetExplorer.SelectedAnnotationDict
|
var annThumbs = datasetExplorer.SelectedAnnotationDict
|
||||||
.Where(x => names.Contains(x.Key))
|
.Where(x => notification.AnnotationNames.Contains(x.Key))
|
||||||
.Select(x => x.Value)
|
.Select(x => x.Value)
|
||||||
.ToList();
|
.ToList();
|
||||||
foreach (var annThumb in annThumbs)
|
foreach (var annThumb in annThumbs)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ cdef enum CommandType:
|
|||||||
INFERENCE = 30
|
INFERENCE = 30
|
||||||
INFERENCE_DATA = 35
|
INFERENCE_DATA = 35
|
||||||
STOP_INFERENCE = 40
|
STOP_INFERENCE = 40
|
||||||
AI_AVAILABILITY_CHECK = 80,
|
AI_AVAILABILITY_CHECK = 80
|
||||||
AI_AVAILABILITY_RESULT = 85,
|
AI_AVAILABILITY_RESULT = 85
|
||||||
ERROR = 90
|
ERROR = 90
|
||||||
EXIT = 100
|
EXIT = 100
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public partial class App
|
|||||||
|
|
||||||
private readonly ICache _cache = new MemoryCache();
|
private readonly ICache _cache = new MemoryCache();
|
||||||
private IAzaionApi _azaionApi = null!;
|
private IAzaionApi _azaionApi = null!;
|
||||||
private CancellationTokenSource _mainCancelTokenSource = new();
|
private CancellationTokenSource _mainCTokenSource = new();
|
||||||
|
|
||||||
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -89,7 +89,7 @@ public partial class App
|
|||||||
new ConfigUpdater().CheckConfig();
|
new ConfigUpdater().CheckConfig();
|
||||||
var secureAppConfig = ReadSecureAppConfig();
|
var secureAppConfig = ReadSecureAppConfig();
|
||||||
var apiDir = secureAppConfig.DirectoriesConfig.ApiResourcesDirectory;
|
var apiDir = secureAppConfig.DirectoriesConfig.ApiResourcesDirectory;
|
||||||
_inferenceClient = new InferenceClient(new OptionsWrapper<InferenceClientConfig>(secureAppConfig.InferenceClientConfig), _mainCancelTokenSource.Token);
|
_inferenceClient = new InferenceClient(new OptionsWrapper<InferenceClientConfig>(secureAppConfig.InferenceClientConfig), _mainCTokenSource.Token);
|
||||||
var login = new Login();
|
var login = new Login();
|
||||||
|
|
||||||
var loader = (IResourceLoader)_inferenceClient;
|
var loader = (IResourceLoader)_inferenceClient;
|
||||||
@@ -244,7 +244,7 @@ public partial class App
|
|||||||
{
|
{
|
||||||
var args = (KeyEventArgs)e;
|
var args = (KeyEventArgs)e;
|
||||||
var keyEvent = new KeyEvent(sender, args, _formState.ActiveWindow);
|
var keyEvent = new KeyEvent(sender, args, _formState.ActiveWindow);
|
||||||
ThrottleExt.Throttle(() => _mediator.Publish(keyEvent), KeyPressTaskId, TimeSpan.FromMilliseconds(50));
|
ThrottleExt.Throttle(() => _mediator.Publish(keyEvent, _mainCTokenSource.Token), KeyPressTaskId, TimeSpan.FromMilliseconds(50));
|
||||||
//e.Handled = true;
|
//e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,8 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Azaion.Common\Azaion.Common.csproj" />
|
<ProjectReference Include="..\Azaion.Common\Azaion.Common.csproj" />
|
||||||
<ProjectReference Include="..\dummy\Azaion.Annotator\Azaion.Annotator.csproj" />
|
<ProjectReference Include="..\Azaion.Annotator\Azaion.Annotator.csproj" />
|
||||||
<ProjectReference Include="..\dummy\Azaion.Dataset\Azaion.Dataset.csproj" />
|
<ProjectReference Include="..\Azaion.Dataset\Azaion.Dataset.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -62,8 +62,8 @@
|
|||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="Build">
|
<Target Name="PostBuild" AfterTargets="Build">
|
||||||
<MakeDir Directories="$(TargetDir)dummy" />
|
<MakeDir Directories="$(TargetDir)dummy" />
|
||||||
<Move SourceFiles="$(TargetDir)Azaion.Annotator.dll" DestinationFolder="$(TargetDir)dummy" />
|
<Copy SourceFiles="$(TargetDir)Azaion.Annotator.dll" DestinationFolder="$(TargetDir)dummy" />
|
||||||
<Move SourceFiles="$(TargetDir)Azaion.Dataset.dll" DestinationFolder="$(TargetDir)dummy" />
|
<Copy SourceFiles="$(TargetDir)Azaion.Dataset.dll" DestinationFolder="$(TargetDir)dummy" />
|
||||||
<Exec Command="postbuild.cmd $(ConfigurationName) stage" />
|
<Exec Command="postbuild.cmd $(ConfigurationName) stage" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user