From f9815a0a3f0c60b3ccd64235fafb29e367929fcf Mon Sep 17 00:00:00 2001 From: Alex Bezdieniezhnykh Date: Tue, 10 Jun 2025 23:38:37 +0300 Subject: [PATCH] add list files for autoupdate feature put new Versioning fix bugs --- Azaion.Annotator/Azaion.Annotator.csproj | 2 +- Azaion.Common/Services/InferenceClient.cs | 2 +- .../Services/LoaderClient.cs | 4 +- Azaion.Dataset/Azaion.Dataset.csproj | 2 +- Azaion.Inference/azaion-inference.spec | 2 +- Azaion.Inference/build_inference.cmd | 8 +- Azaion.Inference/file_data.pxd | 8 + Azaion.Inference/file_data.pyx | 14 +- Azaion.Inference/loader_client.pyx | 2 +- Azaion.Inference/remote_command.pxd | 2 + Azaion.Inference/remote_command.pyx | 6 +- Azaion.Loader/api_client.pxd | 2 + Azaion.Loader/api_client.pyx | 35 ++-- Azaion.Loader/build_loader.cmd | 2 +- Azaion.Loader/cdn_manager.pyx | 6 +- Azaion.Loader/file_data.pxd | 8 + Azaion.Loader/file_data.pyx | 14 +- Azaion.Loader/main_loader.pyx | 7 +- Azaion.Loader/remote_command.pxd | 2 + Azaion.Loader/remote_command.pyx | 2 + Azaion.Suite/App.xaml.cs | 170 +++++++++--------- Azaion.Suite/Azaion.Suite.csproj | 2 +- Azaion.Suite/config.production.json | 13 +- build/init.cmd | 2 + build/installer.iterative.iss | 9 +- build/publish.cmd | 5 +- 26 files changed, 204 insertions(+), 127 deletions(-) diff --git a/Azaion.Annotator/Azaion.Annotator.csproj b/Azaion.Annotator/Azaion.Annotator.csproj index 0e3ecaf..03dd400 100644 --- a/Azaion.Annotator/Azaion.Annotator.csproj +++ b/Azaion.Annotator/Azaion.Annotator.csproj @@ -9,7 +9,7 @@ $([System.DateTime]::UtcNow.ToString("yyyy.MM.dd")) - $([System.Convert]::ToInt32($([System.DateTime]::UtcNow.TimeOfDay.TotalSeconds))) + $([System.Convert]::ToInt32($([System.DateTime]::UtcNow.TimeOfDay.TotalMinutes))) $(VersionDate).$(VersionSeconds) $(AssemblyVersion) diff --git a/Azaion.Common/Services/InferenceClient.cs b/Azaion.Common/Services/InferenceClient.cs index a7be69b..97c66be 100644 --- a/Azaion.Common/Services/InferenceClient.cs +++ b/Azaion.Common/Services/InferenceClient.cs @@ -58,7 +58,7 @@ public class InferenceClient : IInferenceClient process.OutputDataReceived += (_, 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) { diff --git a/Azaion.CommonSecurity/Services/LoaderClient.cs b/Azaion.CommonSecurity/Services/LoaderClient.cs index 4f0e414..e1cfbc4 100644 --- a/Azaion.CommonSecurity/Services/LoaderClient.cs +++ b/Azaion.CommonSecurity/Services/LoaderClient.cs @@ -65,7 +65,7 @@ public class LoaderClient(LoaderClientConfig config, ILogger logger, Cancellatio return new MemoryStream(result.Data!); } - private RemoteCommand SendCommand(RemoteCommand command, int retryCount = 15, int retryDelayMs = 400) + private RemoteCommand SendCommand(RemoteCommand command, int retryCount = 50, int retryDelayMs = 800) { try { @@ -82,7 +82,7 @@ public class LoaderClient(LoaderClientConfig config, ILogger logger, Cancellatio return res; } - throw new Exception($"Sent {command} {retryCount} times. No response from client."); + throw new Exception($"Sent {command} {retryCount} times, with wait time {retryDelayMs}ms for each call. No response from client."); } catch (Exception e) { diff --git a/Azaion.Dataset/Azaion.Dataset.csproj b/Azaion.Dataset/Azaion.Dataset.csproj index 08f525f..e6564cc 100644 --- a/Azaion.Dataset/Azaion.Dataset.csproj +++ b/Azaion.Dataset/Azaion.Dataset.csproj @@ -9,7 +9,7 @@ $([System.DateTime]::UtcNow.ToString("yyyy.MM.dd")) - $([System.Convert]::ToInt32($([System.DateTime]::UtcNow.TimeOfDay.TotalSeconds))) + $([System.Convert]::ToInt32($([System.DateTime]::UtcNow.TimeOfDay.TotalMinutes))) $(VersionDate).$(VersionSeconds) $(AssemblyVersion) diff --git a/Azaion.Inference/azaion-inference.spec b/Azaion.Inference/azaion-inference.spec index c10262e..dc49315 100644 --- a/Azaion.Inference/azaion-inference.spec +++ b/Azaion.Inference/azaion-inference.spec @@ -4,7 +4,7 @@ from PyInstaller.utils.hooks import collect_all datas = [('venv\\Lib\\site-packages\\cv2', 'cv2')] binaries = [] -hiddenimports = ['constants', 'file_data', 'remote_command', 'remote_command_handler', 'annotation', 'loader_client', 'ai_config', 'tensorrt_engine', 'onnx_engine', 'inference_engine', 'inference', 'main-inf'] +hiddenimports = ['constants', 'file_data', 'loader_client', 'remote_command', 'remote_command_handler', 'annotation', 'loader_client', 'ai_config', 'tensorrt_engine', 'onnx_engine', 'inference_engine', 'inference', 'main-inf'] hiddenimports += collect_submodules('cv2') tmp_ret = collect_all('psutil') datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] diff --git a/Azaion.Inference/build_inference.cmd b/Azaion.Inference/build_inference.cmd index 6aff820..6848cbb 100644 --- a/Azaion.Inference/build_inference.cmd +++ b/Azaion.Inference/build_inference.cmd @@ -51,12 +51,10 @@ robocopy "dist\azaion-inference\_internal" "..\dist-azaion\_internal" "ai_config robocopy "dist\azaion-inference\_internal" "..\dist-azaion\_internal" "constants.cp312-win_amd64.pyd" "file_data.cp312-win_amd64.pyd" robocopy "dist\azaion-inference\_internal" "..\dist-azaion\_internal" "remote_command.cp312-win_amd64.pyd" "remote_command_handler.cp312-win_amd64.pyd" robocopy "dist\azaion-inference\_internal" "..\dist-azaion\_internal" "inference.cp312-win_amd64.pyd" "inference_engine.cp312-win_amd64.pyd" -robocopy "dist\azaion-inference\_internal" "..\dist-azaion\_internal" "tensorrt_engine.cp312-win_amd64.pyd" "onnx_engine.cp312-win_amd64.pyd" "main_inference.cp312-win_amd64.pyd" +robocopy "dist\azaion-inference\_internal" "..\dist-azaion\_internal" "loader_client.cp312-win_amd64.pyd" "tensorrt_engine.cp312-win_amd64.pyd" +robocopy "dist\azaion-inference\_internal" "..\dist-azaion\_internal" "onnx_engine.cp312-win_amd64.pyd" "main_inference.cp312-win_amd64.pyd" robocopy "dist\azaion-inference\_internal" "..\dist-dlls\_internal" /E -robocopy "dist\azaion-inference" "..\dist-azaion" "azaion-inference.exe" /E - -REM copy for local run -robocopy "c:\share\" "dist\azaion-inference\_internal /E +robocopy "dist\azaion-inference" "..\dist-azaion" "azaion-inference.exe" cd /d %CURRENT_DIR% diff --git a/Azaion.Inference/file_data.pxd b/Azaion.Inference/file_data.pxd index 11604e5..811155d 100644 --- a/Azaion.Inference/file_data.pxd +++ b/Azaion.Inference/file_data.pxd @@ -14,3 +14,11 @@ cdef class UploadFileData(FileData): cdef from_msgpack(bytes data) cdef bytes serialize(self) + +cdef class FileList: + cdef public list[str] files + + @staticmethod + cdef from_msgpack(bytes data) + + cdef bytes serialize(self) \ No newline at end of file diff --git a/Azaion.Inference/file_data.pyx b/Azaion.Inference/file_data.pyx index 73bf2b2..fec6379 100644 --- a/Azaion.Inference/file_data.pyx +++ b/Azaion.Inference/file_data.pyx @@ -37,4 +37,16 @@ cdef class UploadFileData(FileData): "Resource": self.resource, "Folder": self.folder, "Filename": self.filename - }) \ No newline at end of file + }) + +cdef class FileList: + def __init__(self, list[str] files): + self.files = files + + @staticmethod + cdef from_msgpack(bytes data): + unpacked = unpackb(data, strict_map_key=False) + return FileList(unpacked.get("files")) + + cdef bytes serialize(self): + return packb({ "files": self.files }) diff --git a/Azaion.Inference/loader_client.pyx b/Azaion.Inference/loader_client.pyx index e3d72a3..b6a1a2d 100644 --- a/Azaion.Inference/loader_client.pyx +++ b/Azaion.Inference/loader_client.pyx @@ -28,7 +28,7 @@ cdef class LoaderClient: return LoadResult(f"Unexpected response command type: {response.command_type}") cdef upload_big_small_resource(self, bytes content, str filename, str directory): - cdef UploadFileData upload_file_data = UploadFileData(content, filename, directory) + cdef UploadFileData upload_file_data = UploadFileData(content, folder=directory, filename=filename) cdef RemoteCommand upload_resp = self._send_receive_command(RemoteCommand(CommandType.UPLOAD_BIG_SMALL, data=upload_file_data.serialize())) if upload_resp.command_type == CommandType.OK: return LoadResult(None, None) diff --git a/Azaion.Inference/remote_command.pxd b/Azaion.Inference/remote_command.pxd index 0d02840..2571843 100644 --- a/Azaion.Inference/remote_command.pxd +++ b/Azaion.Inference/remote_command.pxd @@ -1,6 +1,8 @@ cdef enum CommandType: OK = 3 LOGIN = 10 + LIST_REQUEST = 15 + LIST_FILES = 18 LOAD = 20 LOAD_BIG_SMALL = 22 UPLOAD_BIG_SMALL = 24 diff --git a/Azaion.Inference/remote_command.pyx b/Azaion.Inference/remote_command.pyx index cea1f41..03ff40d 100644 --- a/Azaion.Inference/remote_command.pyx +++ b/Azaion.Inference/remote_command.pyx @@ -1,15 +1,17 @@ import msgpack cdef class RemoteCommand: - def __init__(self, CommandType command_type, bytes data, str message=None): + def __init__(self, CommandType command_type, bytes data=None, str message=None): self.command_type = command_type self.data = data self.message = message def __str__(self): command_type_names = { - 3: "OK", + 3: "OK", 10: "LOGIN", + 15: "LIST_REQUEST", + 18: "LIST_FILES", 20: "LOAD", 22: "LOAD_BIG_SMALL", 24: "UPLOAD_BIG_SMALL", diff --git a/Azaion.Loader/api_client.pxd b/Azaion.Loader/api_client.pxd index 468ac46..b93f7df 100644 --- a/Azaion.Loader/api_client.pxd +++ b/Azaion.Loader/api_client.pxd @@ -14,6 +14,8 @@ cdef class ApiClient: cdef set_token(self, str token) cdef get_user(self) + cdef post(self, url, json) + cdef list_files(self, str folder, str search_file) cdef load_bytes(self, str filename, str folder) cdef upload_file(self, str filename, bytes resource, str folder) cdef load_big_file_cdn(self, str folder, str big_part) diff --git a/Azaion.Loader/api_client.pyx b/Azaion.Loader/api_client.pyx index 6c537c6..abf1119 100644 --- a/Azaion.Loader/api_client.pyx +++ b/Azaion.Loader/api_client.pyx @@ -97,25 +97,38 @@ cdef class ApiClient: except Exception as e: constants.log(f"Upload fail: {e}") + cdef list_files(self, str folder, str search_file): + response = self.post(f'{self.api_url}/resources/list/{folder}', { + "search": search_file + }) + constants.log( f'Get files list by {folder}') + return response.json() + cdef load_bytes(self, str filename, str folder): cdef str hardware = HardwareService.get_hardware_info() hw_hash = Security.get_hw_hash(hardware) key = Security.get_api_encryption_key(self.credentials, hw_hash) + payload = json.dumps( + { + "password": self.credentials.password, + "hardware": hardware, + "fileName": filename + }, indent=4) + response = self.post(f'{self.api_url}/resources/get/{folder}', payload) + resp_bytes = response.raw.read() + data = Security.decrypt_to(resp_bytes, key) + constants.log(f'Downloaded file: {filename}, {len(data)} bytes') + return data + + cdef post(self, url, payload): if self.token is None: self.login() - url = f"{self.api_url}/resources/get/{folder}" headers = { "Authorization": f"Bearer {self.token}", "Content-Type": "application/json" } - payload = json.dumps( - { - "password": self.credentials.password, - "hardware": hardware, - "fileName": filename - }, indent=4) response = requests.post(url, data=payload, headers=headers, stream=True) if response.status_code == HTTPStatus.UNAUTHORIZED or response.status_code == HTTPStatus.FORBIDDEN: self.login() @@ -132,18 +145,14 @@ cdef class ApiClient: err_code = res['ErrorCode'] err_msg = res['Message'] raise Exception(f"Error {err_code}: {err_msg}") - - resp_bytes = response.raw.read() - data = Security.decrypt_to(resp_bytes, key) - constants.log(f'Downloaded file: {filename}, {len(data)} bytes') - return data + return response cdef load_big_file_cdn(self, str folder, str big_part): print(f'downloading file {folder}\\{big_part} from cdn...') if self.cdn_manager.download(folder, big_part): with open(path.join( folder, big_part), 'rb') as binary_file: encrypted_bytes_big = binary_file.read() - # return encrypted_bytes_big + return encrypted_bytes_big else: raise Exception(f'Cannot download file {folder}\\{big_part} from CDN!') diff --git a/Azaion.Loader/build_loader.cmd b/Azaion.Loader/build_loader.cmd index abf8573..979aa86 100644 --- a/Azaion.Loader/build_loader.cmd +++ b/Azaion.Loader/build_loader.cmd @@ -49,6 +49,6 @@ robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "hardware_ser robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "main_loader.cp312-win_amd64.pyd" robocopy "dist\azaion-loader\_internal" "..\dist-dlls\_internal" /E -robocopy "dist\azaion-loader" "..\dist-azaion" "azaion-loader.exe" /E +robocopy "dist\azaion-loader" "..\dist-azaion" "azaion-loader.exe" cd /d %CURRENT_DIR% \ No newline at end of file diff --git a/Azaion.Loader/cdn_manager.pyx b/Azaion.Loader/cdn_manager.pyx index fb02dec..0074790 100644 --- a/Azaion.Loader/cdn_manager.pyx +++ b/Azaion.Loader/cdn_manager.pyx @@ -1,6 +1,6 @@ import io import os - +cimport constants import boto3 @@ -27,7 +27,7 @@ cdef class CDNManager: cdef upload(self, str bucket, str filename, bytes file_bytes): try: self.upload_client.upload_fileobj(io.BytesIO(file_bytes), bucket, filename) - print(f'uploaded {filename} ({len(file_bytes)} bytes) to the {bucket}') + constants.log(f'uploaded {filename} ({len(file_bytes)} bytes) to the {bucket}') return True except Exception as e: print(e) @@ -37,7 +37,7 @@ cdef class CDNManager: try: os.makedirs(folder, exist_ok=True) self.download_client.download_file(folder, filename, f'{folder}\\{filename}') - print(f'downloaded {filename} from the {folder}') + constants.log(f'downloaded {filename} from the {folder}') return True except Exception as e: print(e) diff --git a/Azaion.Loader/file_data.pxd b/Azaion.Loader/file_data.pxd index ee7f359..811155d 100644 --- a/Azaion.Loader/file_data.pxd +++ b/Azaion.Loader/file_data.pxd @@ -13,4 +13,12 @@ cdef class UploadFileData(FileData): @staticmethod cdef from_msgpack(bytes data) + cdef bytes serialize(self) + +cdef class FileList: + cdef public list[str] files + + @staticmethod + cdef from_msgpack(bytes data) + cdef bytes serialize(self) \ No newline at end of file diff --git a/Azaion.Loader/file_data.pyx b/Azaion.Loader/file_data.pyx index 73bf2b2..fec6379 100644 --- a/Azaion.Loader/file_data.pyx +++ b/Azaion.Loader/file_data.pyx @@ -37,4 +37,16 @@ cdef class UploadFileData(FileData): "Resource": self.resource, "Folder": self.folder, "Filename": self.filename - }) \ No newline at end of file + }) + +cdef class FileList: + def __init__(self, list[str] files): + self.files = files + + @staticmethod + cdef from_msgpack(bytes data): + unpacked = unpackb(data, strict_map_key=False) + return FileList(unpacked.get("files")) + + cdef bytes serialize(self): + return packb({ "files": self.files }) diff --git a/Azaion.Loader/main_loader.pyx b/Azaion.Loader/main_loader.pyx index 3368066..9d1ef92 100644 --- a/Azaion.Loader/main_loader.pyx +++ b/Azaion.Loader/main_loader.pyx @@ -4,7 +4,7 @@ import traceback from credentials cimport Credentials from remote_command cimport RemoteCommand, CommandType from remote_command_handler cimport RemoteCommandHandler -from file_data cimport FileData, UploadFileData +from file_data cimport FileData, UploadFileData, FileList from api_client cimport ApiClient cdef class CommandProcessor: @@ -47,6 +47,11 @@ cdef class CommandProcessor: file_data = FileData.from_msgpack(command.data) file_bytes = self.api_client.load_bytes(file_data.filename, file_data.folder) self.remote_handler.send(command.client_id, RemoteCommand(CommandType.DATA_BYTES, file_bytes).serialize()) + elif command.command_type == CommandType.LIST_REQUEST: + search_data = FileData.from_msgpack(command.data) + list_files = self.api_client.load_bytes(search_data.folder, search_data.filename) + file_list_bytes = FileList(list_files).serialize() + self.remote_handler.send(command.client_id, RemoteCommand(CommandType.LIST_FILES, file_list_bytes).serialize()) elif command.command_type == CommandType.LOAD_BIG_SMALL: data = FileData.from_msgpack(command.data) file_bytes = self.api_client.load_big_small_resource(data.filename, data.folder) diff --git a/Azaion.Loader/remote_command.pxd b/Azaion.Loader/remote_command.pxd index 0d02840..2571843 100644 --- a/Azaion.Loader/remote_command.pxd +++ b/Azaion.Loader/remote_command.pxd @@ -1,6 +1,8 @@ cdef enum CommandType: OK = 3 LOGIN = 10 + LIST_REQUEST = 15 + LIST_FILES = 18 LOAD = 20 LOAD_BIG_SMALL = 22 UPLOAD_BIG_SMALL = 24 diff --git a/Azaion.Loader/remote_command.pyx b/Azaion.Loader/remote_command.pyx index 18a41ec..03ff40d 100644 --- a/Azaion.Loader/remote_command.pyx +++ b/Azaion.Loader/remote_command.pyx @@ -10,6 +10,8 @@ cdef class RemoteCommand: command_type_names = { 3: "OK", 10: "LOGIN", + 15: "LIST_REQUEST", + 18: "LIST_FILES", 20: "LOAD", 22: "LOAD_BIG_SMALL", 24: "UPLOAD_BIG_SMALL", diff --git a/Azaion.Suite/App.xaml.cs b/Azaion.Suite/App.xaml.cs index f2625de..59b1226 100644 --- a/Azaion.Suite/App.xaml.cs +++ b/Azaion.Suite/App.xaml.cs @@ -106,100 +106,106 @@ public partial class App private void Start(ApiCredentials credentials) { - new ConfigUpdater().CheckConfig(); - var initConfig = SecurityConstants.ReadInitConfig(); - var apiDir = initConfig.DirectoriesConfig.ApiResourcesDirectory; - _loaderClient = new LoaderClient(initConfig.LoaderClientConfig, Log.Logger, _mainCTokenSource.Token); + try + { + new ConfigUpdater().CheckConfig(); + var initConfig = SecurityConstants.ReadInitConfig(); + var apiDir = initConfig.DirectoriesConfig.ApiResourcesDirectory; + _loaderClient = new LoaderClient(initConfig.LoaderClientConfig, Log.Logger, _mainCTokenSource.Token); -#if DEBUG - _loaderClient.StartClient(); -#endif - _loaderClient.Connect(); //Client app should be already started by LoaderUI - _loaderClient.Login(credentials); + _loaderClient.StartClient(); + _loaderClient.Connect(); //Client app should be already started by LoaderUI + _loaderClient.Login(credentials); - var azaionApi = new AzaionApi(new HttpClient { BaseAddress = new Uri(initConfig.InferenceClientConfig.ApiUrl) }, _cache, credentials); + var azaionApi = new AzaionApi(new HttpClient { BaseAddress = new Uri(initConfig.InferenceClientConfig.ApiUrl) }, _cache, credentials); - _host = Host.CreateDefaultBuilder() - .ConfigureAppConfiguration((_, config) => config - .AddCommandLine(Environment.GetCommandLineArgs()) - .AddJsonFile(SecurityConstants.CONFIG_PATH, optional: true, reloadOnChange: true) - .AddJsonStream(GetSystemConfig(_loaderClient, apiDir)) - .AddJsonStream(GetSecuredConfig(_loaderClient, apiDir))) - .UseSerilog() - .ConfigureServices((context, services) => - { - services.AddSingleton(); - - services.Configure(context.Configuration); - services.ConfigureSection(context.Configuration); - services.ConfigureSection(context.Configuration); - services.ConfigureSection(context.Configuration); - services.ConfigureSection(context.Configuration); - services.ConfigureSection(context.Configuration); - services.ConfigureSection(context.Configuration); - services.ConfigureSection(context.Configuration); - - #region External Services - - services.ConfigureSection(context.Configuration); - services.AddSingleton(_loaderClient); - - services.ConfigureSection(context.Configuration); - services.AddSingleton(); - services.AddSingleton(); - - services.ConfigureSection(context.Configuration); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - - services.AddHttpClient(); - services.AddSingleton(azaionApi); - #endregion - - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddMediatR(c => c.RegisterServicesFromAssemblies( - typeof(Annotator.Annotator).Assembly, - typeof(DatasetExplorer).Assembly, - typeof(AnnotationService).Assembly)); - services.AddSingleton(_ => new LibVLC()); - services.AddSingleton(); - services.AddSingleton(sp => + _host = Host.CreateDefaultBuilder() + .ConfigureAppConfiguration((_, config) => config + .AddCommandLine(Environment.GetCommandLineArgs()) + .AddJsonFile(SecurityConstants.CONFIG_PATH, optional: true, reloadOnChange: true) + .AddJsonStream(GetSystemConfig(_loaderClient, apiDir)) + .AddJsonStream(GetSecuredConfig(_loaderClient, apiDir))) + .UseSerilog() + .ConfigureServices((context, services) => { - var libVLC = sp.GetRequiredService(); - return new MediaPlayer(libVLC); - }); - services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); - services.AddSingleton(); + services.Configure(context.Configuration); + services.ConfigureSection(context.Configuration); + services.ConfigureSection(context.Configuration); + services.ConfigureSection(context.Configuration); + services.ConfigureSection(context.Configuration); + services.ConfigureSection(context.Configuration); + services.ConfigureSection(context.Configuration); + services.ConfigureSection(context.Configuration); - services.AddSingleton(); + #region External Services - services.AddSingleton(); - services.AddSingleton(); + services.ConfigureSection(context.Configuration); + services.AddSingleton(_loaderClient); - services.AddSingleton(); - services.AddSingleton(); - }) - .Build(); + services.ConfigureSection(context.Configuration); + services.AddSingleton(); + services.AddSingleton(); - Annotation.InitializeDirs(_host.Services.GetRequiredService>().Value); - _host.Services.GetRequiredService(); - // datasetExplorer.Show(); - // datasetExplorer.Hide(); + services.ConfigureSection(context.Configuration); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); - _mediator = _host.Services.GetRequiredService(); + services.AddHttpClient(); + services.AddSingleton(azaionApi); + #endregion - _formState = _host.Services.GetRequiredService(); - DispatcherUnhandledException += OnDispatcherUnhandledException; + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddMediatR(c => c.RegisterServicesFromAssemblies( + typeof(Annotator.Annotator).Assembly, + typeof(DatasetExplorer).Assembly, + typeof(AnnotationService).Assembly)); + services.AddSingleton(_ => new LibVLC()); + services.AddSingleton(); + services.AddSingleton(sp => + { + var libVLC = sp.GetRequiredService(); + return new MediaPlayer(libVLC); + }); + services.AddSingleton(); + services.AddSingleton(); - _host.Start(); - EventManager.RegisterClassHandler(typeof(UIElement), UIElement.PreviewKeyDownEvent, new RoutedEventHandler(GlobalKeyHandler)); - _host.Services.GetRequiredService().Show(); + services.AddSingleton(); + + services.AddSingleton(); + + services.AddSingleton(); + services.AddSingleton(); + + services.AddSingleton(); + services.AddSingleton(); + }) + .Build(); + + Annotation.InitializeDirs(_host.Services.GetRequiredService>().Value); + _host.Services.GetRequiredService(); + // datasetExplorer.Show(); + // datasetExplorer.Hide(); + + _mediator = _host.Services.GetRequiredService(); + + _formState = _host.Services.GetRequiredService(); + DispatcherUnhandledException += OnDispatcherUnhandledException; + + _host.Start(); + EventManager.RegisterClassHandler(typeof(UIElement), UIElement.PreviewKeyDownEvent, new RoutedEventHandler(GlobalKeyHandler)); + _host.Services.GetRequiredService().Show(); + } + catch (Exception e) + { + Log.Logger.Error(e, e.Message); + throw; + } } private void GlobalKeyHandler(object sender, RoutedEventArgs e) diff --git a/Azaion.Suite/Azaion.Suite.csproj b/Azaion.Suite/Azaion.Suite.csproj index b5b86ba..6b3baf7 100644 --- a/Azaion.Suite/Azaion.Suite.csproj +++ b/Azaion.Suite/Azaion.Suite.csproj @@ -13,7 +13,7 @@ $([System.DateTime]::UtcNow.ToString("yyyy.MM.dd")) - $([System.Convert]::ToInt32($([System.DateTime]::UtcNow.TimeOfDay.TotalSeconds))) + $([System.Convert]::ToInt32($([System.DateTime]::UtcNow.TimeOfDay.TotalMinutes))) $(VersionDate).$(VersionSeconds) $(AssemblyVersion) diff --git a/Azaion.Suite/config.production.json b/Azaion.Suite/config.production.json index 5aacf77..71dfe6f 100644 --- a/Azaion.Suite/config.production.json +++ b/Azaion.Suite/config.production.json @@ -1,17 +1,18 @@ { + "LoaderClientConfig": { + "ZeroMqHost": "127.0.0.1", + "ZeroMqPort": 5025, + "ApiUrl": "https://api.azaion.com" + }, "InferenceClientConfig": { "ZeroMqHost": "127.0.0.1", - "ZeroMqPort": 5131, - "RetryCount": 25, - "TimeoutSeconds": 5, + "ZeroMqPort": 5127, "ApiUrl": "https://api.azaion.com" }, "GpsDeniedClientConfig": { "ZeroMqHost": "127.0.0.1", "ZeroMqPort": 5555, - "ZeroMqReceiverPort": 5556, - "RetryCount": 25, - "TimeoutSeconds": 5 + "ZeroMqReceiverPort": 5556 }, "DirectoriesConfig": { "ApiResourcesDirectory": "", diff --git a/build/init.cmd b/build/init.cmd index 56e0250..a62ba52 100644 --- a/build/init.cmd +++ b/build/init.cmd @@ -10,6 +10,8 @@ if exist dist-dlls rmdir dist-dlls /s /q mkdir dist-dlls if exist dist-azaion rmdir dist-azaion /s /q mkdir dist-azaion +if exist dist rmdir dist /s /q +mkdir dist echo Copying shared libs diff --git a/build/installer.iterative.iss b/build/installer.iterative.iss index 1340fc4..3f44d07 100644 --- a/build/installer.iterative.iss +++ b/build/installer.iterative.iss @@ -1,12 +1,15 @@ +#define MyAppVersion GetFileVersion("..\dist-azaion\Azaion.Suite.exe") + [Setup] AppId={{CCFEC8E2-0FCC-4B03-8EEA-00AF20D265E5}} AppName=Azaion Suite -AppVersion=1.5.0 -AppPublisher=Azaion Ukraine +AppVersion={#MyAppVersion} +VersionInfoVersion={#MyAppVersion} +AppPublisher=Azaion LLC DefaultDirName={localappdata}\Azaion\Azaion Suite DefaultGroupName=Azaion Suite OutputDir=..\ -OutputBaseFilename=AzaionSuite.Iterative.1.5.0 +OutputBaseFilename=AzaionSuite.Iterative.{#MyAppVersion} SetupIconFile=..\dist-azaion\logo.ico UninstallDisplayName=Azaion Suite UninstallDisplayIcon={app}\Azaion.Suite.exe diff --git a/build/publish.cmd b/build/publish.cmd index 3678741..5c64195 100644 --- a/build/publish.cmd +++ b/build/publish.cmd @@ -1,10 +1,13 @@ -@echo off +rem + @echo off pushd %~dp0.. call build\init call build\build_dotnet +call Azaion.Loader\build_loader + call Azaion.Inference\build_inference call ..\gps-denied\image-matcher\build_gps