Implement AI Host functionality with model caching and job management
- Added ai_host.py to handle AI tasks with FastAPI integration. - Introduced HostState and ModelCache classes for managing client connections and model loading. - Implemented job submission and cancellation endpoints in the AI host. - Enhanced tests for AI host functionality, including client tracking and job cancellation. - Updated existing tests to accommodate changes in the operator and command structure. - Refactored runtime commands to use request-based architecture instead of command-line arguments. - Improved model loading logic to handle CUDA memory management and reuse models efficiently.
This commit is contained in:
@@ -47,6 +47,20 @@ class WorkerTest(unittest.TestCase):
|
||||
source.index("import torch"),
|
||||
)
|
||||
|
||||
def test_ai_tasks_support_cooperative_cancellation(self):
|
||||
with self.assertRaises(self.worker.TaskCancelled):
|
||||
self.worker.check_cancelled(lambda: True)
|
||||
|
||||
self.worker.check_cancelled(lambda: False)
|
||||
self.assertIn(
|
||||
"cancel_check=cancel_check",
|
||||
inspect.getsource(self.worker.reconstruct),
|
||||
)
|
||||
self.assertIn(
|
||||
"cancel_check=cancel_check",
|
||||
inspect.getsource(self.worker.remove_background),
|
||||
)
|
||||
|
||||
def test_optional_background_removal_runs_before_da3_model_load(self):
|
||||
source = inspect.getsource(self.worker.reconstruct)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user