mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:36:30 +00:00
correct app close
fix publishing
This commit is contained in:
@@ -18,6 +18,7 @@ public interface IDbFactory
|
|||||||
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<Annotation> annotations, CancellationToken cancellationToken = default);
|
||||||
|
Task DeleteAnnotations(List<string> annotationNames, CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DbFactory : IDbFactory
|
public class DbFactory : IDbFactory
|
||||||
@@ -100,10 +101,16 @@ public class DbFactory : IDbFactory
|
|||||||
public async Task DeleteAnnotations(List<Annotation> annotations, CancellationToken cancellationToken = default)
|
public async Task DeleteAnnotations(List<Annotation> annotations, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var names = annotations.Select(x => x.Name).ToList();
|
var names = annotations.Select(x => x.Name).ToList();
|
||||||
|
await DeleteAnnotations(names, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAnnotations(List<string> annotationNames, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
await Run(async db =>
|
await Run(async db =>
|
||||||
{
|
{
|
||||||
await db.Detections.DeleteAsync(x => names.Contains(x.AnnotationName), token: cancellationToken);
|
var detDeleted = await db.Detections.DeleteAsync(x => annotationNames.Contains(x.AnnotationName), token: cancellationToken);
|
||||||
await db.Annotations.DeleteAsync(x => names.Contains(x.Name), token: cancellationToken);
|
var annDeleted = await db.Annotations.DeleteAsync(x => annotationNames.Contains(x.Name), token: cancellationToken);
|
||||||
|
Console.WriteLine($"Deleted {detDeleted} detections, {annDeleted} annotations");
|
||||||
});
|
});
|
||||||
SaveToDisk();
|
SaveToDisk();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,17 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
|||||||
MessageHandler = async (stream, consumer, context, message) =>
|
MessageHandler = async (stream, consumer, context, message) =>
|
||||||
{
|
{
|
||||||
var msg = MessagePackSerializer.Deserialize<AnnotationCreatedMessage>(message.Data.Contents);
|
var msg = MessagePackSerializer.Deserialize<AnnotationCreatedMessage>(message.Data.Contents);
|
||||||
|
await _dbFactory.Run(async db => await db.QueueOffsets
|
||||||
|
.Where(x => x.QueueName == Constants.MQ_ANNOTATIONS_QUEUE)
|
||||||
|
.Set(x => x.Offset, context.Offset)
|
||||||
|
.UpdateAsync(token: cancellationToken));
|
||||||
|
|
||||||
|
await ThrottleExt.ThrottleRunAfter(() =>
|
||||||
|
{
|
||||||
|
_dbFactory.SaveToDisk();
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}, SaveTaskId, TimeSpan.FromSeconds(5), cancellationToken);
|
||||||
|
|
||||||
if (msg.CreatedRole != RoleEnum.Operator) //Process only operator's messages
|
if (msg.CreatedRole != RoleEnum.Operator) //Process only operator's messages
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -86,18 +97,6 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
|||||||
msg.CreatedEmail,
|
msg.CreatedEmail,
|
||||||
generateThumbnail: true,
|
generateThumbnail: true,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
await _dbFactory.Run(async db => await db.QueueOffsets
|
|
||||||
.Where(x => x.QueueName == Constants.MQ_ANNOTATIONS_QUEUE)
|
|
||||||
.Set(x => x.Offset, context.Offset)
|
|
||||||
.UpdateAsync(token: cancellationToken));
|
|
||||||
|
|
||||||
await ThrottleExt.ThrottleRunAfter(() =>
|
|
||||||
{
|
|
||||||
_dbFactory.SaveToDisk();
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}, SaveTaskId, TimeSpan.FromSeconds(3), cancellationToken);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ public class GalleryService(
|
|||||||
{
|
{
|
||||||
File.Delete(file.FullName);
|
File.Delete(file.FullName);
|
||||||
logger.LogInformation($"No labels found for image {file.FullName}! Image deleted!");
|
logger.LogInformation($"No labels found for image {file.FullName}! Image deleted!");
|
||||||
|
await dbFactory.DeleteAnnotations([fName], cancellationToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,8 +71,11 @@ public class PythonResourceLoader : IResourceLoader, IAuthProvider
|
|||||||
|
|
||||||
public void StopPython()
|
public void StopPython()
|
||||||
{
|
{
|
||||||
_dealer.SendFrame(MessagePackSerializer.Serialize(new RemoteCommand(CommandType.Exit)));
|
if (!_dealer.IsDisposed)
|
||||||
_dealer.Close();
|
{
|
||||||
|
_dealer.SendFrame(MessagePackSerializer.Serialize(new RemoteCommand(CommandType.Exit)));
|
||||||
|
_dealer.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MemoryStream LoadFileFromPython(string fileName, string? folder = null)
|
public MemoryStream LoadFileFromPython(string fileName, string? folder = null)
|
||||||
|
|||||||
@@ -95,11 +95,16 @@ public class DatasetExplorerEventHandler(
|
|||||||
if (annotation.Classes.Contains(selectedClass) || selectedClass == -1)
|
if (annotation.Classes.Contains(selectedClass) || selectedClass == -1)
|
||||||
{
|
{
|
||||||
var annThumb = new AnnotationThumbnail(annotation);
|
var annThumb = new AnnotationThumbnail(annotation);
|
||||||
if (!datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
|
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
|
||||||
{
|
{
|
||||||
datasetExplorer.SelectedAnnotations.Insert(0, annThumb);
|
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
|
||||||
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
|
var ann = datasetExplorer.SelectedAnnotations.FirstOrDefault(x => x.Annotation.Name == annThumb.Annotation.Name);
|
||||||
|
if (ann != null)
|
||||||
|
datasetExplorer.SelectedAnnotations.Remove(ann);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
datasetExplorer.SelectedAnnotations.Insert(0, annThumb);
|
||||||
|
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
|
||||||
}
|
}
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -45,13 +45,20 @@ pyinstaller --onefile ^
|
|||||||
start.py
|
start.py
|
||||||
move dist\start.exe ..\dist\azaion-inference.exe
|
move dist\start.exe ..\dist\azaion-inference.exe
|
||||||
copy config.yaml ..\dist
|
copy config.yaml ..\dist
|
||||||
|
cd..
|
||||||
|
|
||||||
echo Download onnx model
|
echo Download onnx model
|
||||||
|
cd build
|
||||||
call cdn_manager.exe download models azaion.onnx.big
|
call cdn_manager.exe download models azaion.onnx.big
|
||||||
move azaion.onnx.big ..\dist\
|
move azaion.onnx.big ..\dist\
|
||||||
cd ..
|
cd..
|
||||||
|
|
||||||
echo Copy ico
|
echo Copy ico
|
||||||
copy logo.ico dist\
|
copy logo.ico dist\
|
||||||
|
|
||||||
|
echo building installer...
|
||||||
iscc build\installer.iss
|
iscc build\installer.iss
|
||||||
call cdn_manager.exe upload suite AzaionSuiteInstaller.exe
|
cd build\
|
||||||
|
|
||||||
|
echo uploading installer...
|
||||||
|
call .\cdn_manager.exe upload suite AzaionSuiteInstaller.exe ..\AzaionSuiteInstaller.exe
|
||||||
Reference in New Issue
Block a user