mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:26:31 +00:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
namespace Azaion.CommonSecurity.DTO;
|
||||
|
||||
public class DirectoriesConfig
|
||||
|
||||
{
|
||||
public string ApiResourcesDirectory { get; set; } = null!;
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ public abstract class ExternalClientConfig
|
||||
public int RetryCount {get;set;}
|
||||
}
|
||||
|
||||
public class InferenceClientConfig : ExternalClientConfig;
|
||||
public class InferenceClientConfig : ExternalClientConfig
|
||||
{
|
||||
public string ApiUrl { get; set; }
|
||||
}
|
||||
|
||||
public class GpsDeniedClientConfig : ExternalClientConfig
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@ public class SecurityConstants
|
||||
public const string DUMMY_DIR = "dummy";
|
||||
|
||||
#region ExternalClientsConfig
|
||||
//public const string API_URL = "http://localhost:5219";
|
||||
public const string API_URL = "https://api.azaion.com";
|
||||
|
||||
public const string EXTERNAL_INFERENCE_PATH = "azaion-inference.exe";
|
||||
public const string EXTERNAL_GPS_DENIED_FOLDER = "gps-denied";
|
||||
|
||||
@@ -34,7 +34,11 @@ public class AzaionApi(HttpClient client, ICache cache, ApiCredentials credentia
|
||||
|
||||
public void UpdateOffsets(UserQueueOffsets offsets)
|
||||
{
|
||||
Put($"/users/queue-offsets/{CurrentUser.Email}", offsets);
|
||||
Put($"/users/queue-offsets/set", new
|
||||
{
|
||||
Email = CurrentUser.Email,
|
||||
Offsets = offsets
|
||||
});
|
||||
}
|
||||
|
||||
private HttpResponseMessage Send(HttpRequestMessage request)
|
||||
|
||||
@@ -38,7 +38,7 @@ public class InferenceClient : IInferenceClient
|
||||
process.StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = SecurityConstants.EXTERNAL_INFERENCE_PATH,
|
||||
//Arguments = $"-e {credentials.Email} -p {credentials.Password} -f {apiConfig.ResourcesFolder}",
|
||||
Arguments = $"--port {_inferenceClientConfig.ZeroMqPort} --api {_inferenceClientConfig.ApiUrl}",
|
||||
//RedirectStandardOutput = true,
|
||||
//RedirectStandardError = true,
|
||||
//CreateNoWindow = true
|
||||
@@ -57,10 +57,10 @@ public class InferenceClient : IInferenceClient
|
||||
_dealer.Options.Identity = Encoding.UTF8.GetBytes(_clientId.ToString("N"));
|
||||
_dealer.Connect($"tcp://{_inferenceClientConfig.ZeroMqHost}:{_inferenceClientConfig.ZeroMqPort}");
|
||||
}
|
||||
|
||||
private async Task ProcessClientCommands()
|
||||
{
|
||||
//TODO: implement always on ready to client's requests. Utilize RemoteCommand
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
zmq_port: 5131
|
||||
api_url: https://api.azaion.com
|
||||
@@ -1,2 +0,0 @@
|
||||
zmq_port: 5127
|
||||
api_url: http://localhost:5219
|
||||
@@ -13,7 +13,6 @@ from remote_command cimport RemoteCommand, CommandType
|
||||
from remote_command_handler cimport RemoteCommandHandler
|
||||
from credentials cimport Credentials
|
||||
from file_data cimport FileData
|
||||
from user cimport User
|
||||
|
||||
cdef class CommandProcessor:
|
||||
cdef ApiClient api_client
|
||||
@@ -22,12 +21,7 @@ cdef class CommandProcessor:
|
||||
cdef bint running
|
||||
cdef Inference inference
|
||||
|
||||
def __init__(self):
|
||||
with open(<str>constants.CONFIG_FILE, "r") as f:
|
||||
config = yaml.safe_load(f)
|
||||
zmq_port = config["zmq_port"]
|
||||
api_url = config["api_url"]
|
||||
|
||||
def __init__(self, int zmq_port, str api_url):
|
||||
self.api_client = ApiClient(api_url)
|
||||
self.remote_handler = RemoteCommandHandler(zmq_port, self.on_command)
|
||||
self.inference_queue = Queue(maxsize=constants.QUEUE_MAXSIZE)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from main import CommandProcessor
|
||||
import argparse
|
||||
|
||||
|
||||
def start():
|
||||
processor = CommandProcessor()
|
||||
def start(zmq_port, api_url):
|
||||
processor = CommandProcessor(zmq_port, api_url)
|
||||
try:
|
||||
processor.start()
|
||||
except KeyboardInterrupt:
|
||||
@@ -10,4 +11,9 @@ def start():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
start()
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-p", "--port", type=str, default="5127", help="zero mq port")
|
||||
parser.add_argument("-a", "--api", type=str, default="https://api.azaion.com", help="api url")
|
||||
args = parser.parse_args()
|
||||
|
||||
start(int(args.port), args.api)
|
||||
|
||||
@@ -96,7 +96,7 @@ public partial class App
|
||||
login.CredentialsEntered += (_, credentials) =>
|
||||
{
|
||||
_inferenceClient.Send(RemoteCommand.Create(CommandType.Login, credentials));
|
||||
_azaionApi = new AzaionApi(new HttpClient { BaseAddress = new Uri(SecurityConstants.API_URL) }, _cache, credentials);
|
||||
_azaionApi = new AzaionApi(new HttpClient { BaseAddress = new Uri(secureAppConfig.InferenceClientConfig.ApiUrl) }, _cache, credentials);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"ZeroMqHost": "127.0.0.1",
|
||||
"ZeroMqPort": 5127,
|
||||
"RetryCount": 25,
|
||||
"TimeoutSeconds": 5
|
||||
"TimeoutSeconds": 5,
|
||||
"ApiUrl": "https://api.azaion.com"
|
||||
},
|
||||
"GpsDeniedClientConfig": {
|
||||
"ZeroMqHost": "127.0.0.1",
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"ZeroMqHost": "127.0.0.1",
|
||||
"ZeroMqPort": 5131,
|
||||
"RetryCount": 25,
|
||||
"TimeoutSeconds": 5
|
||||
"TimeoutSeconds": 5,
|
||||
"ApiUrl": "https://api.azaion.com"
|
||||
},
|
||||
"GpsDeniedClientConfig": {
|
||||
"ZeroMqHost": "127.0.0.1",
|
||||
|
||||
Reference in New Issue
Block a user