fixed inference bugs

add DONE during inference, correct handling on C# side
This commit is contained in:
Alex Bezdieniezhnykh
2025-02-01 02:09:11 +02:00
parent e7afa96a0b
commit 739759628a
23 changed files with 324 additions and 95 deletions
+31 -5
View File
@@ -11,6 +11,7 @@ using Azaion.Common.Events;
using Azaion.Common.Extensions;
using Azaion.Common.Services;
using Azaion.CommonSecurity;
using Azaion.CommonSecurity.DTO;
using Azaion.CommonSecurity.Services;
using Azaion.Dataset;
using LibVLCSharp.Shared;
@@ -20,6 +21,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Serilog;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
@@ -53,14 +55,38 @@ public partial class App
"Azaion.Dataset"
];
private ApiConfig ReadConfig()
{
try
{
if (!File.Exists(SecurityConstants.CONFIG_PATH))
throw new FileNotFoundException(SecurityConstants.CONFIG_PATH);
var configStr = File.ReadAllText(SecurityConstants.CONFIG_PATH);
return JsonConvert.DeserializeObject<SecureAppConfig>(configStr)!.ApiConfig;
}
catch (Exception e)
{
Console.WriteLine(e);
return new ApiConfig
{
Url = SecurityConstants.DEFAULT_API_URL,
RetryCount = SecurityConstants.DEFAULT_API_RETRY_COUNT ,
TimeoutSeconds = SecurityConstants.DEFAULT_API_TIMEOUT_SECONDS
};
}
}
private void StartLogin()
{
new ConfigUpdater().CheckConfig();
var login = new Login();
login.CredentialsEntered += async (s, args) =>
login.CredentialsEntered += (_, credentials) =>
{
_resourceLoader = new PythonResourceLoader(args);
_securedConfig = await _resourceLoader.LoadFile("secured-config.json");
var apiConfig = ReadConfig();
var api = AzaionApiClient.Create(credentials, apiConfig);
_resourceLoader = new PythonResourceLoader(apiConfig, credentials, api);
_securedConfig = _resourceLoader.LoadFileFromPython("secured-config.json");
AppDomain.CurrentDomain.AssemblyResolve += (_, a) =>
{
@@ -69,7 +95,7 @@ public partial class App
{
try
{
var stream = _resourceLoader.LoadFile($"{assemblyName}.dll").GetAwaiter().GetResult();
var stream = _resourceLoader.LoadFileFromPython($"{assemblyName}.dll");
return Assembly.Load(stream.ToArray());
}
catch (Exception e)
@@ -88,7 +114,7 @@ public partial class App
};
StartMain();
await _host.StartAsync();
_host.Start();
EventManager.RegisterClassHandler(typeof(UIElement), UIElement.KeyDownEvent, new RoutedEventHandler(GlobalClick));
_host.Services.GetRequiredService<MainSuite>().Show();
};