mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:16:30 +00:00
failsafe load dlls
add user config queue offsets throttle improvements
This commit is contained in:
+36
-18
@@ -1,8 +1,12 @@
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Unicode;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Azaion.Annotator;
|
||||
using Azaion.Common;
|
||||
using Azaion.Common.Database;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
@@ -11,8 +15,10 @@ using Azaion.Common.Extensions;
|
||||
using Azaion.Common.Services;
|
||||
using Azaion.CommonSecurity;
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
using Azaion.CommonSecurity.DTO.Commands;
|
||||
using Azaion.CommonSecurity.Services;
|
||||
using Azaion.Dataset;
|
||||
using LazyCache;
|
||||
using LibVLCSharp.Shared;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
@@ -35,12 +41,14 @@ public partial class App
|
||||
|
||||
private IInferenceClient _inferenceClient = null!;
|
||||
private IResourceLoader _resourceLoader = null!;
|
||||
private IAuthProvider _authProvider = null!;
|
||||
|
||||
private Stream _securedConfig = null!;
|
||||
private Stream _systemConfig = null!;
|
||||
private static readonly Guid KeyPressTaskId = Guid.NewGuid();
|
||||
|
||||
private readonly ICache _cache = new MemoryCache();
|
||||
private readonly IHardwareService _hardwareService = new HardwareService();
|
||||
private IAzaionApi _azaionApi = null!;
|
||||
|
||||
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
_logger.LogError(e.Exception, e.Exception.Message);
|
||||
@@ -83,21 +91,32 @@ public partial class App
|
||||
var secureAppConfig = ReadSecureAppConfig();
|
||||
_inferenceClient = new InferenceClient(new OptionsWrapper<InferenceClientConfig>(secureAppConfig.InferenceClientConfig));
|
||||
_resourceLoader = new ResourceLoader(_inferenceClient);
|
||||
_authProvider = new AuthProvider(_inferenceClient);
|
||||
|
||||
var login = new Login();
|
||||
login.Closed += (sender, args) =>
|
||||
{
|
||||
if (!login.MainSuiteOpened)
|
||||
_inferenceClient.Stop();
|
||||
};
|
||||
|
||||
login.CredentialsEntered += (_, credentials) =>
|
||||
login.CredentialsEntered += async (_, credentials) =>
|
||||
{
|
||||
credentials.Folder = secureAppConfig.InferenceClientConfig.ResourcesFolder;
|
||||
_authProvider.Login(credentials);
|
||||
_securedConfig = _resourceLoader.LoadFile("config.secured.json");
|
||||
_systemConfig = _resourceLoader.LoadFile("config.system.json");
|
||||
credentials.Folder = secureAppConfig.DirectoriesConfig.ApiResourcesDirectory;
|
||||
|
||||
_inferenceClient.Send(RemoteCommand.Create(CommandType.Login, credentials));
|
||||
_azaionApi = new AzaionApi(new HttpClient { BaseAddress = new Uri(SecurityConstants.API_URL) }, _cache, credentials, _hardwareService);
|
||||
|
||||
try
|
||||
{
|
||||
_securedConfig = _resourceLoader.LoadFile("config.secured.json");
|
||||
_systemConfig = _resourceLoader.LoadFile("config.system.json");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
_securedConfig = new MemoryStream("{}"u8.ToArray());
|
||||
var systemConfig = new
|
||||
{
|
||||
AnnotationConfig = Constants.DefaultAnnotationConfig,
|
||||
AIRecognitionConfig = Constants.DefaultAIRecognitionConfig,
|
||||
ThumbnailConfig = Constants.DefaultThumbnailConfig,
|
||||
};
|
||||
_systemConfig = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(systemConfig)));
|
||||
}
|
||||
|
||||
AppDomain.CurrentDomain.AssemblyResolve += (_, a) =>
|
||||
{
|
||||
@@ -168,14 +187,13 @@ public partial class App
|
||||
|
||||
services.ConfigureSection<InferenceClientConfig>(context.Configuration);
|
||||
services.ConfigureSection<GpsDeniedClientConfig>(context.Configuration);
|
||||
services.AddSingleton<IInferenceClient>(_inferenceClient);
|
||||
services.AddSingleton<IInferenceClient, InferenceClient>();
|
||||
services.AddSingleton<IGpsMatcherClient, GpsMatcherClient>();
|
||||
services.AddSingleton<IResourceLoader>(_resourceLoader);
|
||||
services.AddSingleton<IAuthProvider>(_authProvider);
|
||||
services.AddSingleton<IInferenceService, InferenceService>();
|
||||
services.AddSingleton<IGpsMatcherService, GpsMatcherService>();
|
||||
services.AddSingleton<ISatelliteDownloader, SatelliteDownloader>();
|
||||
services.AddHttpClient();
|
||||
services.AddSingleton(_azaionApi);
|
||||
#endregion
|
||||
|
||||
services.AddSingleton<IConfigUpdater, ConfigUpdater>();
|
||||
@@ -220,7 +238,7 @@ public partial class App
|
||||
{
|
||||
var args = (KeyEventArgs)e;
|
||||
var keyEvent = new KeyEvent(sender, args, _formState.ActiveWindow);
|
||||
_ = ThrottleExt.ThrottleRunFirst(() => _mediator.Publish(keyEvent), KeyPressTaskId, TimeSpan.FromMilliseconds(50));
|
||||
_ = ThrottleExt.Throttle(() => _mediator.Publish(keyEvent), TimeSpan.FromMilliseconds(50));
|
||||
}
|
||||
|
||||
protected override async void OnExit(ExitEventArgs e)
|
||||
|
||||
@@ -25,7 +25,6 @@ public partial class MainSuite
|
||||
private readonly IGalleryService _galleryService;
|
||||
private readonly IDbFactory _dbFactory;
|
||||
private readonly Dictionary<WindowEnum, Window> _openedWindows = new();
|
||||
private readonly IResourceLoader _resourceLoader;
|
||||
private readonly IInferenceClient _inferenceClient;
|
||||
private readonly IGpsMatcherClient _gpsMatcherClient;
|
||||
private static readonly Guid SaveConfigTaskId = Guid.NewGuid();
|
||||
@@ -36,7 +35,6 @@ public partial class MainSuite
|
||||
IServiceProvider sp,
|
||||
IGalleryService galleryService,
|
||||
IDbFactory dbFactory,
|
||||
IResourceLoader resourceLoader,
|
||||
IInferenceClient inferenceClient,
|
||||
IGpsMatcherClient gpsMatcherClient)
|
||||
{
|
||||
@@ -45,11 +43,10 @@ public partial class MainSuite
|
||||
_sp = sp;
|
||||
_galleryService = galleryService;
|
||||
_dbFactory = dbFactory;
|
||||
_resourceLoader = resourceLoader;
|
||||
_inferenceClient = inferenceClient;
|
||||
_gpsMatcherClient = gpsMatcherClient;
|
||||
|
||||
_appConfig = appConfig.Value;
|
||||
|
||||
InitializeComponent();
|
||||
Loaded += OnLoaded;
|
||||
Closed += OnFormClosed;
|
||||
@@ -135,11 +132,11 @@ public partial class MainSuite
|
||||
|
||||
private async Task SaveUserSettings()
|
||||
{
|
||||
await ThrottleExt.ThrottleRunFirst(() =>
|
||||
await ThrottleExt.Throttle(() =>
|
||||
{
|
||||
_configUpdater.Save(_appConfig);
|
||||
return Task.CompletedTask;
|
||||
}, SaveConfigTaskId, TimeSpan.FromSeconds(2));
|
||||
}, TimeSpan.FromSeconds(2));
|
||||
}
|
||||
|
||||
private void OnFormClosed(object? sender, EventArgs e)
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
"ZeroMqHost": "127.0.0.1",
|
||||
"ZeroMqPort": 5127,
|
||||
"RetryCount": 25,
|
||||
"TimeoutSeconds": 5,
|
||||
"ResourcesFolder": "stage"
|
||||
"TimeoutSeconds": 5
|
||||
},
|
||||
"GpsDeniedClientConfig": {
|
||||
"ZeroMqHost": "127.0.0.1",
|
||||
@@ -14,6 +13,7 @@
|
||||
"TimeoutSeconds": 5
|
||||
},
|
||||
"DirectoriesConfig": {
|
||||
"ApiResourcesDirectory": "stage",
|
||||
"VideosDirectory": "E:\\Azaion6",
|
||||
"LabelsDirectory": "E:\\labels",
|
||||
"ImagesDirectory": "E:\\images",
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
"ZeroMqHost": "127.0.0.1",
|
||||
"ZeroMqPort": 5131,
|
||||
"RetryCount": 25,
|
||||
"TimeoutSeconds": 5,
|
||||
"ResourcesFolder": ""
|
||||
"TimeoutSeconds": 5
|
||||
},
|
||||
"GpsDeniedClientConfig": {
|
||||
"ZeroMqHost": "127.0.0.1",
|
||||
@@ -14,6 +13,7 @@
|
||||
"TimeoutSeconds": 5
|
||||
},
|
||||
"DirectoriesConfig": {
|
||||
"ApiResourcesDirectory": "",
|
||||
"VideosDirectory": "videos",
|
||||
"LabelsDirectory": "labels",
|
||||
"ImagesDirectory": "images",
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
{ "Id": 9, "Name": "Smoke", "ShortName": "Дим", "Color": "#000080" },
|
||||
{ "Id": 10, "Name": "Plane", "ShortName": "Літак", "Color": "#000080" },
|
||||
{ "Id": 11, "Name": "Moto", "ShortName": "Мото", "Color": "#808000" },
|
||||
{ "Id": 12, "Name": "CamouflageNnet", "ShortName": "Сітка", "Color": "#800080" },
|
||||
{ "Id": 12, "Name": "CamouflageNet", "ShortName": "Сітка", "Color": "#800080" },
|
||||
{ "Id": 13, "Name": "CamouflageBranches", "ShortName": "Гілки", "Color": "#2f4f4f" },
|
||||
{ "Id": 14, "Name": "Roof", "ShortName": "Дах", "Color": "#1e90ff" },
|
||||
{ "Id": 15, "Name": "Building", "ShortName": "Будівля", "Color": "#ffb6c1" }
|
||||
|
||||
@@ -14,7 +14,7 @@ set SUITE_FOLDER=%cd%\bin\%CONFIG%\net8.0-windows\
|
||||
rem Inference
|
||||
|
||||
set INFERENCE_PATH=%cd%\..\Azaion.Inference
|
||||
xcopy /E %INFERENCE_PATH%\dist\azaion-inference %SUITE_FOLDER%
|
||||
xcopy /E /Y %INFERENCE_PATH%\dist\azaion-inference %SUITE_FOLDER%
|
||||
copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvinfer_10.dll %SUITE_FOLDER%
|
||||
copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvinfer_plugin_10.dll %SUITE_FOLDER%
|
||||
copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvonnxparser_10.dll %SUITE_FOLDER%
|
||||
|
||||
Reference in New Issue
Block a user