separate load functionality from inference client to loader client. Call loader client from inference to get the model.

remove dummy dlls, remove resource loader from c#.

TODO: Load dlls separately by Loader UI and loader client

WIP
This commit is contained in:
Alex Bezdieniezhnykh
2025-06-06 20:04:03 +03:00
parent 500db31142
commit 7750025631
54 changed files with 353 additions and 571 deletions
+25 -18
View File
@@ -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
from file_data cimport FileData, UploadFileData
from api_client cimport ApiClient
cdef class CommandProcessor:
@@ -12,6 +12,7 @@ cdef class CommandProcessor:
cdef ApiClient api_client
cdef bint running
cdef object shutdown_event
cdef RemoteCommand ok_response
def __init__(self, int zmq_port, str api_url):
self.api_client = ApiClient(api_url)
@@ -19,6 +20,7 @@ cdef class CommandProcessor:
self.remote_handler = RemoteCommandHandler(zmq_port, self.on_command)
self.remote_handler.start()
self.running = True
self.ok_response = RemoteCommand(CommandType.OK)
def start(self):
while self.running:
@@ -29,31 +31,36 @@ cdef class CommandProcessor:
traceback.print_exc()
print('EXIT!')
cdef on_command(self, RemoteCommand command):
try:
if command.command_type == CommandType.LOGIN:
self.api_client.set_credentials(Credentials.from_msgpack(command.data))
elif command.command_type == CommandType.LOAD:
self.load_file(command)
elif command.command_type == CommandType.EXIT:
if command.command_type == CommandType.EXIT:
self.remote_handler.send(command.client_id, self.ok_response.serialize())
t = Thread(target=self.stop) # non-block worker:
t.start()
return
if command.command_type == CommandType.LOGIN:
self.api_client.set_credentials(Credentials.from_msgpack(command.data))
self.remote_handler.send(command.client_id, self.ok_response.serialize())
elif command.command_type == CommandType.LOAD:
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.LOAD_BIG_SMALL:
data = FileData.from_msgpack(command.data)
file_bytes = self.api_client.load_big_small_resource(data.filename, data.folder)
self.remote_handler.send(command.client_id, RemoteCommand(CommandType.DATA_BYTES, file_bytes).serialize())
elif command.command_type == CommandType.UPLOAD_BIG_SMALL:
data = UploadFileData.from_msgpack(command.data)
file_bytes = self.api_client.upload_big_small_resource(data.resource, data.filename, data.folder)
self.remote_handler.send(command.client_id, RemoteCommand(CommandType.OK).serialize())
else:
pass
except Exception as e:
print(f"Error handling client: {e}")
cdef load_file(self, RemoteCommand command):
cdef RemoteCommand response
cdef FileData file_data
cdef bytes file_bytes
try:
file_data = FileData.from_msgpack(command.data)
file_bytes = self.api_client.load_bytes(file_data.filename, file_data.folder)
response = RemoteCommand(CommandType.DATA_BYTES, file_bytes)
except Exception as e:
response = RemoteCommand(CommandType.DATA_BYTES, None, str(e))
self.remote_handler.send(command.client_id, response.serialize())
err_command = RemoteCommand(CommandType.ERROR, None, str(e))
self.remote_handler.send(command.client_id, err_command.serialize())
def stop(self):
self.shutdown_event.set()