diff --git a/Azaion.Common/Controls/CanvasEditor.cs b/Azaion.Common/Controls/CanvasEditor.cs index f4062f9..0f1c8a1 100644 --- a/Azaion.Common/Controls/CanvasEditor.cs +++ b/Azaion.Common/Controls/CanvasEditor.cs @@ -99,10 +99,6 @@ public class CanvasEditor : Canvas Fill = new SolidColorBrush(Color.FromArgb(128, 128, 128, 128)), }; - KeyDown += (_, args) => - { - Console.WriteLine($"pressed {args.Key}"); - }; MouseDown += CanvasMouseDown; MouseMove += CanvasMouseMove; MouseUp += CanvasMouseUp; diff --git a/Azaion.Common/Database/DbFactory.cs b/Azaion.Common/Database/DbFactory.cs index a46f7ff..72875ae 100644 --- a/Azaion.Common/Database/DbFactory.cs +++ b/Azaion.Common/Database/DbFactory.cs @@ -9,6 +9,7 @@ using LinqToDB.Mapping; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Newtonsoft.Json; +using Serilog; namespace Azaion.Common.Database; @@ -138,7 +139,7 @@ public class DbFactory : IDbFactory { var detDeleted = await db.Detections.DeleteAsync(x => annotationNames.Contains(x.AnnotationName), token: cancellationToken); var annDeleted = await db.Annotations.DeleteAsync(x => annotationNames.Contains(x.Name), token: cancellationToken); - Console.WriteLine($"Deleted {detDeleted} detections, {annDeleted} annotations"); + _logger.LogInformation($"Deleted {detDeleted} detections, {annDeleted} annotations"); }); } } diff --git a/Azaion.Common/Extensions/ResilienceExt.cs b/Azaion.Common/Extensions/ResilienceExt.cs index fb8f382..a0ba009 100644 --- a/Azaion.Common/Extensions/ResilienceExt.cs +++ b/Azaion.Common/Extensions/ResilienceExt.cs @@ -4,8 +4,7 @@ public static class ResilienceExt { public static void WithRetry(this Action operation, int retryCount = 3, int delayMs = 150) => Policy.Handle() - .WaitAndRetry(retryCount, num => TimeSpan.FromMilliseconds(num * delayMs), - (exception, timeSpan) => Console.WriteLine($"Exception: {exception}, TimeSpan: {timeSpan}")) + .WaitAndRetry(retryCount, num => TimeSpan.FromMilliseconds(num * delayMs)) .Execute(operation); public static TResult WithRetry(this Func operation, int retryCount = 3, int delayMs = 150) => diff --git a/Azaion.Common/SecurityConstants.cs b/Azaion.Common/SecurityConstants.cs index b251dcb..a28097e 100644 --- a/Azaion.Common/SecurityConstants.cs +++ b/Azaion.Common/SecurityConstants.cs @@ -1,6 +1,7 @@ using System.IO; using Azaion.Common.DTO; using Newtonsoft.Json; +using Serilog; namespace Azaion.Common; @@ -59,7 +60,7 @@ public class SecurityConstants }; #endregion ExternalClientsConfig - public static InitConfig ReadInitConfig() + public static InitConfig ReadInitConfig(ILogger logger) { try { @@ -72,7 +73,7 @@ public class SecurityConstants } catch (Exception e) { - Console.WriteLine(e); + logger.Error(e, e.Message); return DefaultInitConfig; } } diff --git a/Azaion.Common/Services/AuthProvider.cs b/Azaion.Common/Services/AuthProvider.cs index 841a35e..00376b3 100644 --- a/Azaion.Common/Services/AuthProvider.cs +++ b/Azaion.Common/Services/AuthProvider.cs @@ -4,7 +4,9 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Text; using Azaion.Common.DTO; + using Newtonsoft.Json; +using Serilog; namespace Azaion.Common.Services; @@ -16,7 +18,7 @@ public interface IAzaionApi //Stream GetResource(string filename, string folder); } -public class AzaionApi(HttpClient client, ICache cache, ApiCredentials credentials) : IAzaionApi +public class AzaionApi(ILogger logger, HttpClient client, ICache cache, ApiCredentials credentials) : IAzaionApi { private string _jwtToken = null!; const string APP_JSON = "application/json"; @@ -116,7 +118,7 @@ public class AzaionApi(HttpClient client, ICache cache, ApiCredentials credentia } catch (Exception e) { - Console.WriteLine(e); + logger.Error(e, e.Message); throw; } } diff --git a/Azaion.Common/Services/GalleryService.cs b/Azaion.Common/Services/GalleryService.cs index bf15376..883437d 100644 --- a/Azaion.Common/Services/GalleryService.cs +++ b/Azaion.Common/Services/GalleryService.cs @@ -149,7 +149,7 @@ public class GalleryService( if (!existingAnnotations.ContainsKey(fName)) { if (missedAnnotations.ContainsKey(fName)) - Console.WriteLine($"{fName} is already exists! Duplicate!"); + logger.LogInformation($"{fName} is already exists! Duplicate!"); else missedAnnotations.TryAdd(fName, annotation); } @@ -168,7 +168,7 @@ public class GalleryService( { ProgressFn = async num => { - Console.WriteLine($"Processed {num} item by Thread {Environment.CurrentManagedThreadId}"); + logger.LogInformation($"Processed {num} item by Thread {Environment.CurrentManagedThreadId}"); ProcessedThumbnailsPercentage = imagesCount == 0 ? 0 : Math.Min(100, num * 100 / (double)imagesCount); ThumbnailsUpdate?.Invoke(ProcessedThumbnailsPercentage); await Task.CompletedTask; diff --git a/Azaion.Common/Services/GpsMatcherClient.cs b/Azaion.Common/Services/GpsMatcherClient.cs index c0cea36..d432596 100644 --- a/Azaion.Common/Services/GpsMatcherClient.cs +++ b/Azaion.Common/Services/GpsMatcherClient.cs @@ -54,15 +54,12 @@ public class GpsMatcherClient : IGpsMatcherClient WorkingDirectory = SecurityConstants.EXTERNAL_GPS_DENIED_FOLDER, CreateNoWindow = true }; - - process.OutputDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); }; - process.ErrorDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); }; process.Start(); } catch (Exception e) { - Console.WriteLine(e); - //throw; + _logger.LogError(e, e.ToString()); + throw; } _requestAddress = $"tcp://{gpsConfig.Value.ZeroMqHost}:{gpsConfig.Value.ZeroMqPort}"; diff --git a/Azaion.Common/Services/InferenceClient.cs b/Azaion.Common/Services/InferenceClient.cs index 61556d5..9bf5b2d 100644 --- a/Azaion.Common/Services/InferenceClient.cs +++ b/Azaion.Common/Services/InferenceClient.cs @@ -2,6 +2,7 @@ using System.Text; using Azaion.Common.DTO; using MessagePack; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using NetMQ; using NetMQ.Sockets; @@ -18,6 +19,7 @@ public interface IInferenceClient : IDisposable public class InferenceClient : IInferenceClient { + private readonly ILogger _logger; public event EventHandler? BytesReceived; public event EventHandler? InferenceDataReceived; public event EventHandler? AIAvailabilityReceived; @@ -28,8 +30,9 @@ public class InferenceClient : IInferenceClient private readonly InferenceClientConfig _inferenceClientConfig; private readonly LoaderClientConfig _loaderClientConfig; - public InferenceClient(IOptions inferenceConfig, IOptions loaderConfig) + public InferenceClient(ILogger logger, IOptions inferenceConfig, IOptions loaderConfig) { + _logger = logger; _inferenceClientConfig = inferenceConfig.Value; _loaderClientConfig = loaderConfig.Value; Start(); @@ -46,15 +49,12 @@ public class InferenceClient : IInferenceClient Arguments = $"-p {_inferenceClientConfig.ZeroMqPort} -lp {_loaderClientConfig.ZeroMqPort} -a {_inferenceClientConfig.ApiUrl}", CreateNoWindow = true }; - - process.OutputDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); }; - process.ErrorDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); }; process.Start(); } catch (Exception e) { - Console.WriteLine(e); - //throw; + _logger.LogError(e, e.Message); + throw; } _dealer.Options.Identity = Encoding.UTF8.GetBytes(_clientId.ToString("N")); diff --git a/Azaion.Common/Services/LoaderClient.cs b/Azaion.Common/Services/LoaderClient.cs index 0705618..dee71cb 100644 --- a/Azaion.Common/Services/LoaderClient.cs +++ b/Azaion.Common/Services/LoaderClient.cs @@ -26,20 +26,11 @@ public class LoaderClient(LoaderClientConfig config, ILogger logger, Cancellatio Arguments = $"--port {config.ZeroMqPort} --api {config.ApiUrl}", CreateNoWindow = true }; - - process.OutputDataReceived += (_, e) => - { - if (e.Data != null) Console.WriteLine(e.Data); - }; - process.ErrorDataReceived += (_, e) => - { - if (e.Data != null) Console.WriteLine(e.Data); - }; process.Start(); } catch (Exception e) { - logger.Error(e.Message); + logger.Error(e, e.Message); throw; } } diff --git a/Azaion.Common/Services/SatelliteDownloader.cs b/Azaion.Common/Services/SatelliteDownloader.cs index 6be344d..38dac60 100644 --- a/Azaion.Common/Services/SatelliteDownloader.cs +++ b/Azaion.Common/Services/SatelliteDownloader.cs @@ -146,7 +146,7 @@ public class SatelliteDownloader( } catch (Exception) { - Console.WriteLine($"Error while loading tile: {tileData}"); + logger.LogError($"Error while loading tile: {tileData}"); } if (token.IsCancellationRequested) return; diff --git a/Azaion.Inference/azaion-inference.spec b/Azaion.Inference/azaion-inference.spec index 268f0c2..7ae365f 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_inf', 'file_data', 'remote_command_inf', 'remote_command_handler_inf', '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 c11422e..c08c978 100644 --- a/Azaion.Inference/build_inference.cmd +++ b/Azaion.Inference/build_inference.cmd @@ -34,10 +34,10 @@ venv\Scripts\pyinstaller --name=azaion-inference ^ --collect-all pynvml ^ --collect-all jwt ^ --collect-all loguru ^ ---hidden-import constants ^ +--hidden-import constants_inf ^ --hidden-import file_data ^ ---hidden-import remote_command ^ ---hidden-import remote_command_handler ^ +--hidden-import remote_command_inf ^ +--hidden-import remote_command_handler_inf ^ --hidden-import annotation ^ --hidden-import loader_client ^ --hidden-import ai_config ^ @@ -49,8 +49,8 @@ venv\Scripts\pyinstaller --name=azaion-inference ^ start.py robocopy "dist\azaion-inference\_internal" "..\dist-azaion\_internal" "ai_config.cp312-win_amd64.pyd" "annotation.cp312-win_amd64.pyd" -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" "constants_inf.cp312-win_amd64.pyd" "file_data.cp312-win_amd64.pyd" +robocopy "dist\azaion-inference\_internal" "..\dist-azaion\_internal" "remote_command_inf.cp312-win_amd64.pyd" "remote_command_handler_inf.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" "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" diff --git a/Azaion.Inference/constants.pxd b/Azaion.Inference/constants_inf.pxd similarity index 100% rename from Azaion.Inference/constants.pxd rename to Azaion.Inference/constants_inf.pxd diff --git a/Azaion.Inference/constants.pyx b/Azaion.Inference/constants_inf.pyx similarity index 100% rename from Azaion.Inference/constants.pyx rename to Azaion.Inference/constants_inf.pyx diff --git a/Azaion.Inference/inference.pxd b/Azaion.Inference/inference.pxd index 2a090ab..9e69a25 100644 --- a/Azaion.Inference/inference.pxd +++ b/Azaion.Inference/inference.pxd @@ -1,4 +1,4 @@ -from remote_command cimport RemoteCommand +from remote_command_inf cimport RemoteCommand from annotation cimport Annotation, Detection from ai_config cimport AIRecognitionConfig from loader_client cimport LoaderClient diff --git a/Azaion.Inference/inference.pyx b/Azaion.Inference/inference.pyx index 858d69d..d6ff306 100644 --- a/Azaion.Inference/inference.pyx +++ b/Azaion.Inference/inference.pyx @@ -2,8 +2,8 @@ import mimetypes import time import cv2 import numpy as np -cimport constants -from remote_command cimport RemoteCommand +cimport constants_inf +from remote_command_inf cimport RemoteCommand from annotation cimport Detection, Annotation from ai_config cimport AIRecognitionConfig import pynvml @@ -16,7 +16,7 @@ cdef int check_tensor_gpu_index(): deviceCount = pynvml.nvmlDeviceGetCount() if deviceCount == 0: - constants.logerror('No NVIDIA GPUs found.') + constants_inf.logerror('No NVIDIA GPUs found.') return -1 for i in range(deviceCount): @@ -24,10 +24,10 @@ cdef int check_tensor_gpu_index(): major, minor = pynvml.nvmlDeviceGetCudaComputeCapability(handle) if major > 6 or (major == 6 and minor >= 1): - constants.log('found NVIDIA GPU!') + constants_inf.log('found NVIDIA GPU!') return i - constants.logerror('NVIDIA GPU doesnt support TensorRT!') + constants_inf.logerror('NVIDIA GPU doesnt support TensorRT!') return -1 except pynvml.NVMLError: @@ -36,7 +36,7 @@ cdef int check_tensor_gpu_index(): try: pynvml.nvmlShutdown() except: - constants.logerror('Failed to shutdown pynvml cause probably no NVIDIA GPU') + constants_inf.logerror('Failed to shutdown pynvml cause probably no NVIDIA GPU') pass tensor_gpu_index = check_tensor_gpu_index() @@ -63,23 +63,23 @@ cdef class Inference: try: engine_filename = TensorRTEngine.get_engine_filename(0) - models_dir = constants.MODELS_FOLDER + models_dir = constants_inf.MODELS_FOLDER self.is_building_engine = True updater_callback('downloading') res = self.loader_client.load_big_small_resource(engine_filename, models_dir) if res.err is None: - constants.log('tensor rt engine is here, no need to build') + constants_inf.log('tensor rt engine is here, no need to build') self.is_building_engine = False updater_callback('enabled') return - constants.logerror(res.err) + constants_inf.logerror(res.err) # time.sleep(8) # prevent simultaneously loading dll and models updater_callback('converting') - constants.log('try to load onnx') - res = self.loader_client.load_big_small_resource(constants.AI_ONNX_MODEL_FILE, models_dir) + constants_inf.log('try to load onnx') + res = self.loader_client.load_big_small_resource(constants_inf.AI_ONNX_MODEL_FILE, models_dir) if res.err is not None: updater_callback(f'Error. {res.err}') model_bytes = TensorRTEngine.convert_from_onnx(res.data) @@ -87,7 +87,7 @@ cdef class Inference: res = self.loader_client.upload_big_small_resource(model_bytes, engine_filename, models_dir) if res.err is not None: updater_callback(f'Error. {res.err}') - constants.log(f'uploaded {engine_filename} to CDN and API') + constants_inf.log(f'uploaded {engine_filename} to CDN and API') self.is_building_engine = False updater_callback('enabled') except Exception as e: @@ -97,7 +97,7 @@ cdef class Inference: if self.engine is not None: return - models_dir = constants.MODELS_FOLDER + models_dir = constants_inf.MODELS_FOLDER if tensor_gpu_index > -1: while self.is_building_engine: time.sleep(1) @@ -108,7 +108,7 @@ cdef class Inference: raise Exception(res.err) self.engine = TensorRTEngine(res.data) else: - res = self.loader_client.load_big_small_resource(constants.AI_ONNX_MODEL_FILE, models_dir) + res = self.loader_client.load_big_small_resource(constants_inf.AI_ONNX_MODEL_FILE, models_dir) if res.err is not None: raise Exception(res.err) self.engine = OnnxEngine(res.data) @@ -212,11 +212,11 @@ cdef class Inference: # images first, it's faster if len(images) > 0: for chunk in self.split_list_extend(images, self.engine.get_batch_size()): - constants.log(f'run inference on {" ".join(chunk)}...') + constants_inf.log(f'run inference on {" ".join(chunk)}...') self._process_images(cmd, ai_config, chunk) if len(videos) > 0: for v in videos: - constants.log(f'run inference on {v}...') + constants_inf.log(f'run inference on {v}...') self._process_video(cmd, ai_config, v) diff --git a/Azaion.Inference/loader_client.pxd b/Azaion.Inference/loader_client.pxd index b5b16dc..f9b4383 100644 --- a/Azaion.Inference/loader_client.pxd +++ b/Azaion.Inference/loader_client.pxd @@ -1,4 +1,4 @@ -from remote_command cimport RemoteCommand +from remote_command_inf cimport RemoteCommand cdef class LoadResult: cdef public str err diff --git a/Azaion.Inference/loader_client.pyx b/Azaion.Inference/loader_client.pyx index b6a1a2d..4b6eec7 100644 --- a/Azaion.Inference/loader_client.pyx +++ b/Azaion.Inference/loader_client.pyx @@ -1,5 +1,5 @@ import zmq -from remote_command cimport RemoteCommand, CommandType +from remote_command_inf cimport RemoteCommand, CommandType from file_data cimport FileData, UploadFileData cdef class LoadResult: diff --git a/Azaion.Inference/main_inference.pyx b/Azaion.Inference/main_inference.pyx index 787ca57..6978fd8 100644 --- a/Azaion.Inference/main_inference.pyx +++ b/Azaion.Inference/main_inference.pyx @@ -1,14 +1,14 @@ import queue import traceback from queue import Queue -cimport constants +cimport constants_inf from threading import Thread from annotation cimport Annotation from inference cimport Inference from loader_client cimport LoaderClient -from remote_command cimport RemoteCommand, CommandType -from remote_command_handler cimport RemoteCommandHandler +from remote_command_inf cimport RemoteCommand, CommandType +from remote_command_handler_inf cimport RemoteCommandHandler cdef class CommandProcessor: @@ -20,7 +20,7 @@ cdef class CommandProcessor: def __init__(self, int zmq_port, str loader_zmq_host, int loader_zmq_port, str api_url): self.remote_handler = RemoteCommandHandler(zmq_port, self.on_command) - self.inference_queue = Queue(maxsize=constants.QUEUE_MAXSIZE) + self.inference_queue = Queue(maxsize=constants_inf.QUEUE_MAXSIZE) self.remote_handler.start() self.running = True self.loader_client = LoaderClient(loader_zmq_host, loader_zmq_port) @@ -37,7 +37,7 @@ cdef class CommandProcessor: continue except Exception as e: traceback.print_exc() - constants.log('EXIT!') + constants_inf.log('EXIT!') cdef on_command(self, RemoteCommand command): try: @@ -54,7 +54,7 @@ cdef class CommandProcessor: else: pass except Exception as e: - constants.logerror(f"Error handling client: {e}") + constants_inf.logerror(f"Error handling client: {e}") cdef on_annotation(self, RemoteCommand cmd, Annotation annotation): cdef RemoteCommand response = RemoteCommand(CommandType.INFERENCE_DATA, annotation.serialize()) diff --git a/Azaion.Inference/onnx_engine.pyx b/Azaion.Inference/onnx_engine.pyx index 268a5d6..15ddd1b 100644 --- a/Azaion.Inference/onnx_engine.pyx +++ b/Azaion.Inference/onnx_engine.pyx @@ -1,6 +1,6 @@ from inference_engine cimport InferenceEngine import onnxruntime as onnx -cimport constants +cimport constants_inf cdef class OnnxEngine(InferenceEngine): def __init__(self, model_bytes: bytes, batch_size: int = 1, **kwargs): @@ -11,9 +11,9 @@ cdef class OnnxEngine(InferenceEngine): self.input_name = self.model_inputs[0].name self.input_shape = self.model_inputs[0].shape self.batch_size = self.input_shape[0] if self.input_shape[0] != -1 else batch_size - constants.log(f'AI detection model input: {self.model_inputs} {self.input_shape}') + constants_inf.log(f'AI detection model input: {self.model_inputs} {self.input_shape}') model_meta = self.session.get_modelmeta() - constants.log(f"Metadata: {model_meta.custom_metadata_map}") + constants_inf.log(f"Metadata: {model_meta.custom_metadata_map}") cpdef tuple get_input_shape(self): shape = self.input_shape diff --git a/Azaion.Inference/remote_command_handler.pxd b/Azaion.Inference/remote_command_handler_inf.pxd similarity index 100% rename from Azaion.Inference/remote_command_handler.pxd rename to Azaion.Inference/remote_command_handler_inf.pxd diff --git a/Azaion.Inference/remote_command_handler.pyx b/Azaion.Inference/remote_command_handler_inf.pyx similarity index 90% rename from Azaion.Inference/remote_command_handler.pyx rename to Azaion.Inference/remote_command_handler_inf.pyx index eee5eee..9553a82 100644 --- a/Azaion.Inference/remote_command_handler.pyx +++ b/Azaion.Inference/remote_command_handler_inf.pyx @@ -1,8 +1,8 @@ import time import zmq from threading import Thread, Event -from remote_command cimport RemoteCommand -cimport constants +from remote_command_inf cimport RemoteCommand +cimport constants_inf cdef class RemoteCommandHandler: def __init__(self, int zmq_port, object on_command): @@ -27,7 +27,7 @@ cdef class RemoteCommandHandler: for _ in range(4): # 4 worker threads worker = Thread(target=self._worker_loop, daemon=True) self._workers.append(worker) - constants.log(f'Listening to commands on port {zmq_port}...') + constants_inf.log(f'Listening to commands on port {zmq_port}...') cdef start(self): self._proxy_thread.start() @@ -39,7 +39,7 @@ cdef class RemoteCommandHandler: zmq.proxy_steerable(self._router, self._dealer, control=self._control) except zmq.error.ZMQError as e: if self._shutdown_event.is_set(): - constants.log("Shutdown, exit proxy loop.") + constants_inf.log("Shutdown, exit proxy loop.") else: raise @@ -58,11 +58,11 @@ cdef class RemoteCommandHandler: client_id, message = worker_socket.recv_multipart() cmd = RemoteCommand.from_msgpack( message) cmd.client_id = client_id - constants.log(cmd) + constants_inf.log(str(cmd)) self._on_command(cmd) except Exception as e: if not self._shutdown_event.is_set(): - constants.log(f"Worker error: {e}") + constants_inf.log(f"Worker error: {e}") import traceback traceback.print_exc() finally: diff --git a/Azaion.Inference/remote_command.pxd b/Azaion.Inference/remote_command_inf.pxd similarity index 100% rename from Azaion.Inference/remote_command.pxd rename to Azaion.Inference/remote_command_inf.pxd diff --git a/Azaion.Inference/remote_command.pyx b/Azaion.Inference/remote_command_inf.pyx similarity index 100% rename from Azaion.Inference/remote_command.pyx rename to Azaion.Inference/remote_command_inf.pyx diff --git a/Azaion.Inference/setup.py b/Azaion.Inference/setup.py index ba60517..91157a4 100644 --- a/Azaion.Inference/setup.py +++ b/Azaion.Inference/setup.py @@ -3,10 +3,10 @@ from Cython.Build import cythonize import numpy as np extensions = [ - Extension('constants', ['constants.pyx']), + Extension('constants_inf', ['constants_inf.pyx']), Extension('file_data', ['file_data.pyx']), - Extension('remote_command', ['remote_command.pyx']), - Extension('remote_command_handler', ['remote_command_handler.pyx']), + Extension('remote_command_inf', ['remote_command_inf.pyx']), + Extension('remote_command_handler_inf', ['remote_command_handler_inf.pyx']), Extension('annotation', ['annotation.pyx']), Extension('loader_client', ['loader_client.pyx']), Extension('ai_config', ['ai_config.pyx']), diff --git a/Azaion.Inference/tensorrt_engine.pyx b/Azaion.Inference/tensorrt_engine.pyx index f1c60d2..c792340 100644 --- a/Azaion.Inference/tensorrt_engine.pyx +++ b/Azaion.Inference/tensorrt_engine.pyx @@ -4,7 +4,7 @@ import pycuda.driver as cuda import pycuda.autoinit # required for automatically initialize CUDA, do not remove. import pynvml import numpy as np -cimport constants +cimport constants_inf cdef class TensorRTEngine(InferenceEngine): @@ -100,16 +100,16 @@ cdef class TensorRTEngine(InferenceEngine): return None if builder.platform_has_fast_fp16: - constants.log('Converting to supported fp16') + constants_inf.log('Converting to supported fp16') config.set_flag(trt.BuilderFlag.FP16) else: - constants.log('Converting to supported fp32. (fp16 is not supported)') + constants_inf.log('Converting to supported fp32. (fp16 is not supported)') plan = builder.build_serialized_network(network, config) if plan is None: - constants.logerror('Conversion failed.') + constants_inf.logerror('Conversion failed.') return None - constants.log('conversion done!') + constants_inf.log('conversion done!') return bytes(plan) cpdef tuple get_input_shape(self): diff --git a/Azaion.Loader/build_loader.cmd b/Azaion.Loader/build_loader.cmd index d2cb75c..935b2e4 100644 --- a/Azaion.Loader/build_loader.cmd +++ b/Azaion.Loader/build_loader.cmd @@ -45,7 +45,7 @@ start.py robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "security.cp312-win_amd64.pyd" "cdn_manager.cp312-win_amd64.pyd" -robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "credentials.cp312-win_amd64.pyd" "api_client.cp312-win_amd64.pyd" +robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "constants.cp312-win_amd64.pyd" "credentials.cp312-win_amd64.pyd" "api_client.cp312-win_amd64.pyd" robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "hardware_service.cp312-win_amd64.pyd" "user.cp312-win_amd64.pyd" robocopy "dist\azaion-loader\_internal" "..\dist-azaion\_internal" "main_loader.cp312-win_amd64.pyd" diff --git a/Azaion.Loader/remote_command_handler.pyx b/Azaion.Loader/remote_command_handler.pyx index 97b1a3c..4c3d591 100644 --- a/Azaion.Loader/remote_command_handler.pyx +++ b/Azaion.Loader/remote_command_handler.pyx @@ -59,7 +59,7 @@ cdef class RemoteCommandHandler: client_id, message = worker_socket.recv_multipart() cmd = RemoteCommand.from_msgpack( message) cmd.client_id = client_id - constants.log(f'{cmd}') + constants.log(str(cmd)) self._on_command(cmd) except Exception as e: if not self._shutdown_event.is_set(): diff --git a/Azaion.Suite/App.xaml.cs b/Azaion.Suite/App.xaml.cs index ca9f56e..7ae0381 100644 --- a/Azaion.Suite/App.xaml.cs +++ b/Azaion.Suite/App.xaml.cs @@ -106,7 +106,7 @@ public partial class App try { new ConfigUpdater().CheckConfig(); - var initConfig = SecurityConstants.ReadInitConfig(); + var initConfig = SecurityConstants.ReadInitConfig(Log.Logger); var apiDir = initConfig.DirectoriesConfig.ApiResourcesDirectory; _loaderClient = new LoaderClient(initConfig.LoaderClientConfig, Log.Logger, _mainCTokenSource.Token); @@ -114,7 +114,7 @@ public partial class App _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(Log.Logger, new HttpClient { BaseAddress = new Uri(initConfig.InferenceClientConfig.ApiUrl) }, _cache, credentials); _host = Host.CreateDefaultBuilder() .ConfigureAppConfiguration((_, config) => config