mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 17:46:36 +00:00
make python app load a bit eariler, making startup a bit faster
This commit is contained in:
@@ -33,7 +33,7 @@ public partial class App
|
||||
private IMediator _mediator = null!;
|
||||
private FormState _formState = null!;
|
||||
|
||||
private PythonResourceLoader _resourceLoader = null!;
|
||||
private readonly PythonResourceLoader _resourceLoader = new();
|
||||
private Stream _securedConfig = null!;
|
||||
|
||||
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
@@ -54,7 +54,7 @@ public partial class App
|
||||
"Azaion.Dataset"
|
||||
];
|
||||
|
||||
private ApiConfig ReadConfig()
|
||||
private static ApiConfig ReadConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -69,8 +69,9 @@ public partial class App
|
||||
return new ApiConfig
|
||||
{
|
||||
Url = SecurityConstants.DEFAULT_API_URL,
|
||||
RetryCount = SecurityConstants.DEFAULT_API_RETRY_COUNT ,
|
||||
TimeoutSeconds = SecurityConstants.DEFAULT_API_TIMEOUT_SECONDS
|
||||
RetryCount = SecurityConstants.DEFAULT_API_RETRY_COUNT,
|
||||
TimeoutSeconds = SecurityConstants.DEFAULT_API_TIMEOUT_SECONDS,
|
||||
ResourcesFolder = ""
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -81,10 +82,9 @@ public partial class App
|
||||
var login = new Login();
|
||||
login.CredentialsEntered += (_, credentials) =>
|
||||
{
|
||||
var apiConfig = ReadConfig();
|
||||
var api = AzaionApiClient.Create(credentials, apiConfig);
|
||||
|
||||
_resourceLoader = new PythonResourceLoader(apiConfig, credentials, api);
|
||||
var config = ReadConfig();
|
||||
credentials.Folder = config.ResourcesFolder;
|
||||
_resourceLoader.Login(credentials);
|
||||
_securedConfig = _resourceLoader.LoadFileFromPython("secured-config.json");
|
||||
|
||||
AppDomain.CurrentDomain.AssemblyResolve += (_, a) =>
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Azaion.Annotator\Azaion.Annotator.csproj" />
|
||||
<ProjectReference Include="..\Azaion.Common\Azaion.Common.csproj" />
|
||||
<ProjectReference Include="..\Azaion.Dataset\Azaion.Dataset.csproj" />
|
||||
<ProjectReference Include="..\Azaion.Common\Azaion.Common.csproj" />
|
||||
<ProjectReference Include="..\Dummy\Azaion.Annotator\Azaion.Annotator.csproj" />
|
||||
<ProjectReference Include="..\Dummy\Azaion.Dataset\Azaion.Dataset.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -54,9 +54,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="Build">
|
||||
<MakeDir Directories="$(TargetDir)secure" />
|
||||
<Move SourceFiles="$(TargetDir)Azaion.Annotator.dll" DestinationFolder="$(TargetDir)secure" />
|
||||
<Move SourceFiles="$(TargetDir)Azaion.Dataset.dll" DestinationFolder="$(TargetDir)secure" />
|
||||
<MakeDir Directories="$(TargetDir)dummy" />
|
||||
<Move SourceFiles="$(TargetDir)Azaion.Annotator.dll" DestinationFolder="$(TargetDir)dummy" />
|
||||
<Move SourceFiles="$(TargetDir)Azaion.Dataset.dll" DestinationFolder="$(TargetDir)dummy" />
|
||||
<Exec Command="upload.cmd $(ConfigurationName)" />
|
||||
</Target>
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.Extensions;
|
||||
using Azaion.Common.Services;
|
||||
using Azaion.CommonSecurity.Services;
|
||||
using Azaion.Dataset;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -24,20 +25,22 @@ public partial class MainSuite
|
||||
private readonly IGalleryService _galleryService;
|
||||
private readonly IDbFactory _dbFactory;
|
||||
private readonly Dictionary<WindowEnum, Window> _openedWindows = new();
|
||||
private readonly IResourceLoader _resourceLoader;
|
||||
|
||||
public MainSuite(IOptions<AppConfig> appConfig,
|
||||
IConfigUpdater configUpdater,
|
||||
IEnumerable<IAzaionModule> modules,
|
||||
IServiceProvider sp,
|
||||
IGalleryService galleryService,
|
||||
IDbFactory dbFactory
|
||||
)
|
||||
IDbFactory dbFactory,
|
||||
IResourceLoader resourceLoader)
|
||||
{
|
||||
_configUpdater = configUpdater;
|
||||
_modules = modules;
|
||||
_sp = sp;
|
||||
_galleryService = galleryService;
|
||||
_dbFactory = dbFactory;
|
||||
_resourceLoader = resourceLoader;
|
||||
_appConfig = appConfig.Value;
|
||||
InitializeComponent();
|
||||
Loaded += OnLoaded;
|
||||
@@ -107,6 +110,7 @@ public partial class MainSuite
|
||||
_openedWindows[module.WindowEnum] = window;
|
||||
window.Closed += (_, _) =>
|
||||
{
|
||||
_resourceLoader.StopPython();
|
||||
_openedWindows.Remove(module.WindowEnum);
|
||||
if (!_openedWindows.Any())
|
||||
Close();
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
{
|
||||
"ApiConfig": {
|
||||
"Url": "https://api.azaion.com/",
|
||||
"RetryCount": 3,
|
||||
"TimeoutSeconds": 40.0,
|
||||
"ResourcesFolder": "stage",
|
||||
"TokenFile": "token.txt"
|
||||
"TimeoutSeconds": 20.0,
|
||||
"ResourcesFolder": "stage"
|
||||
},
|
||||
"DirectoriesConfig": {
|
||||
"VideosDirectory": "E:\\Azaion6",
|
||||
|
||||
@@ -7,11 +7,12 @@ set RESOURCES_FOLDER=stage
|
||||
|
||||
set EMAIL=uploader@azaion.com
|
||||
set PASSWORD=Az@1on_10Upl0@der
|
||||
echo %cd%
|
||||
|
||||
set FILE1_TO_UPLOAD=%cd%\bin\%CONFIG%\net8.0-windows\secure\Azaion.Annotator.dll
|
||||
set FILE1_TO_UPLOAD=%cd%\..\Azaion.Annotator\bin\%CONFIG%\net8.0-windows\Azaion.Annotator.dll
|
||||
set "FILE1_TO_UPLOAD=%FILE1_TO_UPLOAD:\=/%"
|
||||
|
||||
set FILE2_TO_UPLOAD=%cd%\bin\%CONFIG%\net8.0-windows\secure\Azaion.Dataset.dll
|
||||
set FILE2_TO_UPLOAD=%cd%\..\Azaion.Dataset\bin\%CONFIG%\net8.0-windows\Azaion.Dataset.dll
|
||||
set "FILE2_TO_UPLOAD=%FILE2_TO_UPLOAD:\=/%"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user