@mcoda/mswarm 0.1.134 → 0.1.135-codali.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/dist/codali-executor.d.ts +76 -0
- package/dist/codali-executor.d.ts.map +1 -1
- package/dist/codali-executor.js +122 -8
- package/dist/codali-executor.js.map +1 -1
- package/dist/invocation-token.d.ts.map +1 -1
- package/dist/invocation-token.js +1 -0
- package/dist/invocation-token.js.map +1 -1
- package/dist/native-reasoning.d.ts +8 -0
- package/dist/native-reasoning.d.ts.map +1 -0
- package/dist/native-reasoning.js +18 -0
- package/dist/native-reasoning.js.map +1 -0
- package/dist/runtime.d.ts +23 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +187 -17
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +58 -8
- package/dist/server.js.map +1 -1
- package/dist/vendor/codali/agents/RoleResolution.d.ts.map +1 -1
- package/dist/vendor/codali/agents/RoleResolution.js +4 -4
- package/dist/vendor/codali/api/CodaliApi.d.ts +16 -0
- package/dist/vendor/codali/api/CodaliApi.d.ts.map +1 -1
- package/dist/vendor/codali/api/CodaliApi.js +39 -10
- package/dist/vendor/codali/cli/AskCommand.d.ts +3 -0
- package/dist/vendor/codali/cli/AskCommand.d.ts.map +1 -1
- package/dist/vendor/codali/cli/AskCommand.js +76 -13
- package/dist/vendor/codali/cli/RunCommand.d.ts +4 -0
- package/dist/vendor/codali/cli/RunCommand.d.ts.map +1 -1
- package/dist/vendor/codali/cli/RunCommand.js +110 -24
- package/dist/vendor/codali/cli/TerminalCommand.d.ts +35 -0
- package/dist/vendor/codali/cli/TerminalCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalCommand.js +618 -0
- package/dist/vendor/codali/cli/TerminalCredentials.d.ts +3 -0
- package/dist/vendor/codali/cli/TerminalCredentials.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalCredentials.js +89 -0
- package/dist/vendor/codali/cli/TerminalInput.d.ts +24 -0
- package/dist/vendor/codali/cli/TerminalInput.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalInput.js +98 -0
- package/dist/vendor/codali/cli/TerminalText.d.ts +10 -0
- package/dist/vendor/codali/cli/TerminalText.d.ts.map +1 -0
- package/dist/vendor/codali/cli/TerminalText.js +53 -0
- package/dist/vendor/codali/cli.d.ts.map +1 -1
- package/dist/vendor/codali/cli.js +33 -4
- package/dist/vendor/codali/cognitive/ConfiguredPipeline.d.ts +34 -0
- package/dist/vendor/codali/cognitive/ConfiguredPipeline.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ConfiguredPipeline.js +50 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts +4 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts.map +1 -1
- package/dist/vendor/codali/cognitive/ValidationRunner.js +18 -41
- package/dist/vendor/codali/config/NodeOrchestration.d.ts +21 -0
- package/dist/vendor/codali/config/NodeOrchestration.d.ts.map +1 -0
- package/dist/vendor/codali/config/NodeOrchestration.js +54 -0
- package/dist/vendor/codali/config/OrchestrationConfig.d.ts +100 -0
- package/dist/vendor/codali/config/OrchestrationConfig.d.ts.map +1 -0
- package/dist/vendor/codali/config/OrchestrationConfig.js +245 -0
- package/dist/vendor/codali/connectors/mcp/McpClient.d.ts +3 -1
- package/dist/vendor/codali/connectors/mcp/McpClient.d.ts.map +1 -1
- package/dist/vendor/codali/connectors/mcp/McpClient.js +3 -2
- package/dist/vendor/codali/connectors/mcp/McpServerRegistry.d.ts +2 -2
- package/dist/vendor/codali/connectors/mcp/McpServerRegistry.d.ts.map +1 -1
- package/dist/vendor/codali/connectors/mcp/McpServerRegistry.js +39 -16
- package/dist/vendor/codali/connectors/mcp/McpToolAdapter.js +2 -2
- package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.d.ts +6 -0
- package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.js +41 -0
- package/dist/vendor/codali/connectors/media/ImageGenerationTool.js +3 -3
- package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.d.ts +5 -0
- package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.js +65 -0
- package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts +68 -0
- package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/MediaJobStore.js +199 -0
- package/dist/vendor/codali/connectors/media/MediaJobWorker.d.ts +2 -0
- package/dist/vendor/codali/connectors/media/MediaJobWorker.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/MediaJobWorker.js +65 -0
- package/dist/vendor/codali/connectors/media/RemoteMediaJob.d.ts +6 -0
- package/dist/vendor/codali/connectors/media/RemoteMediaJob.d.ts.map +1 -0
- package/dist/vendor/codali/connectors/media/RemoteMediaJob.js +80 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts +18 -1
- package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -1
- package/dist/vendor/codali/docdex/DocdexClient.js +135 -19
- package/dist/vendor/codali/docdex/ManagedDocdex.d.ts +29 -0
- package/dist/vendor/codali/docdex/ManagedDocdex.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/ManagedDocdex.js +215 -0
- package/dist/vendor/codali/docdex/ManagedRuntime.d.ts +28 -0
- package/dist/vendor/codali/docdex/ManagedRuntime.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/ManagedRuntime.js +212 -0
- package/dist/vendor/codali/eval/EvaluationProcess.d.ts +13 -0
- package/dist/vendor/codali/eval/EvaluationProcess.d.ts.map +1 -0
- package/dist/vendor/codali/eval/EvaluationProcess.js +76 -0
- package/dist/vendor/codali/eval/LongWorkflowJourney.d.ts +34 -0
- package/dist/vendor/codali/eval/LongWorkflowJourney.d.ts.map +1 -0
- package/dist/vendor/codali/eval/LongWorkflowJourney.js +243 -0
- package/dist/vendor/codali/eval/PlanningCorpus.d.ts +45 -0
- package/dist/vendor/codali/eval/PlanningCorpus.d.ts.map +1 -0
- package/dist/vendor/codali/eval/PlanningCorpus.js +189 -0
- package/dist/vendor/codali/eval/PlanningCorpusRunner.d.ts +13 -0
- package/dist/vendor/codali/eval/PlanningCorpusRunner.d.ts.map +1 -0
- package/dist/vendor/codali/eval/PlanningCorpusRunner.js +89 -0
- package/dist/vendor/codali/eval/TerminalCorpusRunner.d.ts +36 -0
- package/dist/vendor/codali/eval/TerminalCorpusRunner.d.ts.map +1 -0
- package/dist/vendor/codali/eval/TerminalCorpusRunner.js +222 -0
- package/dist/vendor/codali/eval/TerminalTaskCorpus.d.ts +26 -0
- package/dist/vendor/codali/eval/TerminalTaskCorpus.d.ts.map +1 -0
- package/dist/vendor/codali/eval/TerminalTaskCorpus.js +105 -0
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts +11 -0
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts.map +1 -0
- package/dist/vendor/codali/eval/TerminalWorkflowCorpus.js +119 -0
- package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.d.ts +4 -0
- package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.d.ts.map +1 -0
- package/dist/vendor/codali/eval/fixtures/ContractReviewProvider.js +10 -0
- package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.d.ts +6 -0
- package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.d.ts.map +1 -0
- package/dist/vendor/codali/eval/fixtures/MixedMediaRecoveryJourney.js +145 -0
- package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.d.ts +4 -0
- package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.d.ts.map +1 -0
- package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.js +136 -0
- package/dist/vendor/codali/gateway/CodaliGateway.d.ts +2 -0
- package/dist/vendor/codali/gateway/CodaliGateway.d.ts.map +1 -1
- package/dist/vendor/codali/gateway/CodaliGateway.js +11 -1
- package/dist/vendor/codali/gateway/ConfiguredGateway.d.ts +23 -0
- package/dist/vendor/codali/gateway/ConfiguredGateway.d.ts.map +1 -0
- package/dist/vendor/codali/gateway/ConfiguredGateway.js +44 -0
- package/dist/vendor/codali/gateway/GatewayTracer.d.ts +1 -1
- package/dist/vendor/codali/gateway/GatewayTracer.d.ts.map +1 -1
- package/dist/vendor/codali/gateway/GatewayTracer.js +2 -27
- package/dist/vendor/codali/index.d.ts +24 -0
- package/dist/vendor/codali/index.d.ts.map +1 -1
- package/dist/vendor/codali/index.js +13 -0
- package/dist/vendor/codali/permissions/PermissionGate.d.ts +44 -0
- package/dist/vendor/codali/permissions/PermissionGate.d.ts.map +1 -0
- package/dist/vendor/codali/permissions/PermissionGate.js +97 -0
- package/dist/vendor/codali/providers/ConfiguredEmbeddings.d.ts +43 -0
- package/dist/vendor/codali/providers/ConfiguredEmbeddings.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ConfiguredEmbeddings.js +87 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts +70 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ConfiguredModelScope.js +129 -0
- package/dist/vendor/codali/providers/ConfiguredProvider.d.ts +84 -0
- package/dist/vendor/codali/providers/ConfiguredProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ConfiguredProvider.js +271 -0
- package/dist/vendor/codali/providers/ModelServiceError.d.ts +15 -0
- package/dist/vendor/codali/providers/ModelServiceError.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ModelServiceError.js +69 -0
- package/dist/vendor/codali/providers/MswarmWorkerProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/MswarmWorkerProvider.js +4 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +97 -50
- package/dist/vendor/codali/providers/ProviderTypes.d.ts +14 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -1
- package/dist/vendor/codali/providers/RequestUsage.d.ts +11 -0
- package/dist/vendor/codali/providers/RequestUsage.d.ts.map +1 -0
- package/dist/vendor/codali/providers/RequestUsage.js +33 -0
- package/dist/vendor/codali/runtime/CodaliJobRuntime.d.ts +6 -0
- package/dist/vendor/codali/runtime/CodaliJobRuntime.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliJobRuntime.js +36 -1
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +29 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliRuntime.js +70 -1
- package/dist/vendor/codali/runtime/CompletionReport.d.ts +5 -0
- package/dist/vendor/codali/runtime/CompletionReport.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/CompletionReport.js +12 -0
- package/dist/vendor/codali/runtime/ProgressTracker.d.ts +17 -0
- package/dist/vendor/codali/runtime/ProgressTracker.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ProgressTracker.js +27 -0
- package/dist/vendor/codali/runtime/RequestedTestEvidence.d.ts +12 -0
- package/dist/vendor/codali/runtime/RequestedTestEvidence.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RequestedTestEvidence.js +16 -0
- package/dist/vendor/codali/runtime/RequiredRetrieval.d.ts +13 -0
- package/dist/vendor/codali/runtime/RequiredRetrieval.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RequiredRetrieval.js +25 -0
- package/dist/vendor/codali/runtime/ReviewContract.d.ts +35 -0
- package/dist/vendor/codali/runtime/ReviewContract.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ReviewContract.js +132 -0
- package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts +41 -0
- package/dist/vendor/codali/runtime/ReviewCoordinator.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ReviewCoordinator.js +126 -0
- package/dist/vendor/codali/runtime/ReviewSource.d.ts +9 -0
- package/dist/vendor/codali/runtime/ReviewSource.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ReviewSource.js +54 -0
- package/dist/vendor/codali/runtime/Runner.d.ts +7 -0
- package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/Runner.js +220 -171
- package/dist/vendor/codali/runtime/SecretRedaction.d.ts +11 -0
- package/dist/vendor/codali/runtime/SecretRedaction.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/SecretRedaction.js +85 -0
- package/dist/vendor/codali/runtime/SessionController.d.ts +150 -0
- package/dist/vendor/codali/runtime/SessionController.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/SessionController.js +1487 -0
- package/dist/vendor/codali/runtime/StructuralEvidence.d.ts +22 -0
- package/dist/vendor/codali/runtime/StructuralEvidence.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/StructuralEvidence.js +87 -0
- package/dist/vendor/codali/runtime/TaskReview.d.ts +25 -0
- package/dist/vendor/codali/runtime/TaskReview.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/TaskReview.js +84 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.d.ts +71 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/TaskReviewContext.js +50 -0
- package/dist/vendor/codali/runtime/UsageReconciliation.d.ts +28 -0
- package/dist/vendor/codali/runtime/UsageReconciliation.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/UsageReconciliation.js +68 -0
- package/dist/vendor/codali/runtime/ValidationOutput.d.ts +5 -0
- package/dist/vendor/codali/runtime/ValidationOutput.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/ValidationOutput.js +32 -0
- package/dist/vendor/codali/runtime/VerificationCommand.d.ts +5 -0
- package/dist/vendor/codali/runtime/VerificationCommand.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/VerificationCommand.js +76 -0
- package/dist/vendor/codali/runtime/VerificationReceiptSelection.d.ts +15 -0
- package/dist/vendor/codali/runtime/VerificationReceiptSelection.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/VerificationReceiptSelection.js +30 -0
- package/dist/vendor/codali/runtime/WorkStatusPage.d.ts +15 -0
- package/dist/vendor/codali/runtime/WorkStatusPage.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkStatusPage.js +58 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts +13 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkspaceLedger.js +145 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/WorkspaceLock.js +20 -17
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts +13 -0
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkspaceSnapshot.js +88 -0
- package/dist/vendor/codali/session/AtomicState.d.ts +13 -0
- package/dist/vendor/codali/session/AtomicState.d.ts.map +1 -0
- package/dist/vendor/codali/session/AtomicState.js +123 -0
- package/dist/vendor/codali/session/SessionStoragePath.d.ts +15 -0
- package/dist/vendor/codali/session/SessionStoragePath.d.ts.map +1 -0
- package/dist/vendor/codali/session/SessionStoragePath.js +101 -0
- package/dist/vendor/codali/session/SessionStore.d.ts +9 -0
- package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -1
- package/dist/vendor/codali/session/SessionStore.js +181 -47
- package/dist/vendor/codali/session/WorkState.d.ts +32 -0
- package/dist/vendor/codali/session/WorkState.d.ts.map +1 -0
- package/dist/vendor/codali/session/WorkState.js +399 -0
- package/dist/vendor/codali/session/WorkTypes.d.ts +102 -0
- package/dist/vendor/codali/session/WorkTypes.d.ts.map +1 -0
- package/dist/vendor/codali/session/WorkTypes.js +1 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts +2 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -1
- package/dist/vendor/codali/tools/ToolRegistry.js +12 -2
- package/dist/vendor/codali/tools/ToolTypes.d.ts +16 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -1
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +2 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -1
- package/dist/vendor/codali/tools/docdex/DocdexTools.js +17 -2
- package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -1
- package/dist/vendor/codali/tools/filesystem/FileTools.js +30 -10
- package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts +19 -0
- package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/AsyncProcess.js +94 -0
- package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.d.ts +13 -0
- package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.js +130 -0
- package/dist/vendor/codali/tools/shell/HostToolchain.d.ts +19 -0
- package/dist/vendor/codali/tools/shell/HostToolchain.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/HostToolchain.js +266 -0
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts +15 -0
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/IsolatedExecutor.js +138 -0
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -1
- package/dist/vendor/codali/tools/shell/ShellTool.js +9 -29
- package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.d.ts +3 -0
- package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.js +30 -0
- package/package.json +31 -29
- package/scripts/backend-http-drain.mjs +152 -0
- package/scripts/media_gpu_lock.py +238 -0
- package/scripts/native_load_guard.py +257 -0
- package/scripts/stable-audio-3-openai-server.py +45 -14
- package/scripts/stable-diffusion-cpp-openai-server.py +34 -4
- package/scripts/stable-diffusion-cpp-webm-duration.patch +22 -0
- package/scripts/wan22-openai-server.py +97 -18
|
@@ -25,6 +25,8 @@ from pathlib import Path
|
|
|
25
25
|
from socketserver import TCPServer
|
|
26
26
|
from typing import Any, Protocol
|
|
27
27
|
|
|
28
|
+
from media_gpu_lock import MediaGpuError, MediaGpuRecoveryRequired, media_gpu_health, media_gpu_slot
|
|
29
|
+
|
|
28
30
|
|
|
29
31
|
DEFAULT_HOST = "127.0.0.1"
|
|
30
32
|
DEFAULT_PORT = 11446
|
|
@@ -165,7 +167,7 @@ class SubprocessBackend:
|
|
|
165
167
|
seed: int | None,
|
|
166
168
|
) -> tuple[bytes, dict[str, Any]]:
|
|
167
169
|
effective_seed = seed if seed is not None else secrets.randbelow(2**31)
|
|
168
|
-
with tempfile.TemporaryDirectory(prefix="stable-audio-3-") as temp_dir:
|
|
170
|
+
with media_gpu_slot("audio") as lease, tempfile.TemporaryDirectory(prefix="stable-audio-3-") as temp_dir:
|
|
169
171
|
output_path = Path(temp_dir) / "generation.wav"
|
|
170
172
|
command = [
|
|
171
173
|
str(self.python),
|
|
@@ -189,26 +191,48 @@ class SubprocessBackend:
|
|
|
189
191
|
command.extend(("--precision", self.precision))
|
|
190
192
|
if self.models_dir:
|
|
191
193
|
command.extend(("--models-dir", str(self.models_dir)))
|
|
192
|
-
|
|
194
|
+
lease.mark_uncertain("audio_launch_pending")
|
|
195
|
+
try:
|
|
196
|
+
process = subprocess.Popen(
|
|
193
197
|
command,
|
|
194
198
|
cwd=self.runtime_root,
|
|
195
199
|
stdin=subprocess.DEVNULL,
|
|
196
200
|
stdout=subprocess.DEVNULL,
|
|
197
201
|
stderr=subprocess.DEVNULL,
|
|
198
202
|
start_new_session=True,
|
|
199
|
-
|
|
203
|
+
)
|
|
204
|
+
except OSError:
|
|
205
|
+
# Popen reports failed exec only after reaping its failed child.
|
|
206
|
+
lease.confirm_finished()
|
|
207
|
+
raise
|
|
200
208
|
try:
|
|
201
|
-
|
|
202
|
-
except subprocess.TimeoutExpired as error:
|
|
209
|
+
lease.record_native_process(process.pid)
|
|
203
210
|
try:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
return_code = process.wait(timeout=self.timeout_seconds)
|
|
212
|
+
except subprocess.TimeoutExpired as error:
|
|
213
|
+
try:
|
|
214
|
+
os.killpg(process.pid, signal.SIGTERM)
|
|
215
|
+
process.wait(timeout=5)
|
|
216
|
+
except subprocess.TimeoutExpired:
|
|
217
|
+
os.killpg(process.pid, signal.SIGKILL)
|
|
218
|
+
process.wait()
|
|
219
|
+
except ProcessLookupError:
|
|
220
|
+
process.wait()
|
|
221
|
+
raise RuntimeError("Stable Audio CLI timed out") from error
|
|
222
|
+
finally:
|
|
223
|
+
# A reaped wrapper does not prove that its process group stopped.
|
|
224
|
+
# Any unexpected wait/identity failure keeps the durable fence.
|
|
225
|
+
group_alive = True
|
|
226
|
+
try:
|
|
227
|
+
os.killpg(process.pid, 0)
|
|
209
228
|
except ProcessLookupError:
|
|
229
|
+
group_alive = False
|
|
230
|
+
except PermissionError:
|
|
210
231
|
pass
|
|
211
|
-
|
|
232
|
+
if process.poll() is not None and not group_alive:
|
|
233
|
+
lease.confirm_finished()
|
|
234
|
+
if lease.record["status"] == "uncertain":
|
|
235
|
+
raise MediaGpuRecoveryRequired("audio process group has no confirmed terminal outcome")
|
|
212
236
|
if return_code != 0:
|
|
213
237
|
raise RuntimeError(
|
|
214
238
|
f"Stable Audio CLI exited with status {return_code}"
|
|
@@ -244,7 +268,8 @@ class ServerState:
|
|
|
244
268
|
|
|
245
269
|
|
|
246
270
|
class AudioHttpServer(ThreadingHTTPServer):
|
|
247
|
-
|
|
271
|
+
# Let active inference finish before process exit releases the shared GPU.
|
|
272
|
+
daemon_threads = False
|
|
248
273
|
request_queue_size = 8
|
|
249
274
|
|
|
250
275
|
def server_bind(self) -> None:
|
|
@@ -438,8 +463,9 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
438
463
|
|
|
439
464
|
def do_GET(self) -> None:
|
|
440
465
|
if self.path == "/healthz":
|
|
441
|
-
|
|
442
|
-
|
|
466
|
+
gpu = media_gpu_health()
|
|
467
|
+
if state.fatal_error.is_set() or gpu not in ("ready", "busy"):
|
|
468
|
+
self._send_json(503, {"status": "unhealthy", "model": state.model_id, "media_gpu": gpu})
|
|
443
469
|
return
|
|
444
470
|
self._send_json(
|
|
445
471
|
200,
|
|
@@ -447,6 +473,7 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
447
473
|
"status": "ok",
|
|
448
474
|
"model": state.model_id,
|
|
449
475
|
"backend": state.backend_name,
|
|
476
|
+
"media_gpu": gpu,
|
|
450
477
|
"dit": state.dit,
|
|
451
478
|
"decoder": state.decoder,
|
|
452
479
|
},
|
|
@@ -568,6 +595,10 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
568
595
|
)
|
|
569
596
|
except ApiError as error:
|
|
570
597
|
self._send_error(error)
|
|
598
|
+
except MediaGpuError as error:
|
|
599
|
+
self._send_error(
|
|
600
|
+
ApiError(error.status, str(error), error_type="server_error", code=error.code)
|
|
601
|
+
)
|
|
571
602
|
except Exception as error:
|
|
572
603
|
logging.error("generation failed error_type=%s", type(error).__name__)
|
|
573
604
|
self._send_error(
|
|
@@ -6,6 +6,7 @@ from __future__ import annotations
|
|
|
6
6
|
import argparse
|
|
7
7
|
import base64
|
|
8
8
|
import binascii
|
|
9
|
+
import http.client
|
|
9
10
|
import ipaddress
|
|
10
11
|
import json
|
|
11
12
|
import logging
|
|
@@ -28,6 +29,8 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
|
28
29
|
from socketserver import TCPServer
|
|
29
30
|
from typing import Any
|
|
30
31
|
|
|
32
|
+
from media_gpu_lock import MediaGpuError, media_gpu_health, media_gpu_slot
|
|
33
|
+
|
|
31
34
|
|
|
32
35
|
DEFAULT_HOST = "127.0.0.1"
|
|
33
36
|
DEFAULT_PORT = 11449
|
|
@@ -116,7 +119,11 @@ class UpstreamError(Exception):
|
|
|
116
119
|
pass
|
|
117
120
|
|
|
118
121
|
|
|
119
|
-
class
|
|
122
|
+
class UpstreamTransportError(UpstreamError):
|
|
123
|
+
pass
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class UpstreamTimeout(UpstreamTransportError):
|
|
120
127
|
pass
|
|
121
128
|
|
|
122
129
|
|
|
@@ -459,10 +466,10 @@ def _bounded_json_request(
|
|
|
459
466
|
raw = error.read(max_bytes + 1)
|
|
460
467
|
status = error.code
|
|
461
468
|
content_type = error.headers.get_content_type()
|
|
462
|
-
except (OSError, urllib.error.URLError) as error:
|
|
469
|
+
except (OSError, urllib.error.URLError, http.client.HTTPException) as error:
|
|
463
470
|
if _is_timeout_error(error):
|
|
464
471
|
raise UpstreamTimeout("stable-diffusion.cpp request timed out") from error
|
|
465
|
-
raise
|
|
472
|
+
raise UpstreamTransportError("stable-diffusion.cpp is unreachable") from error
|
|
466
473
|
if len(raw) > max_bytes:
|
|
467
474
|
raise UpstreamError("stable-diffusion.cpp response exceeds the configured limit")
|
|
468
475
|
if content_type != "application/json":
|
|
@@ -507,6 +514,19 @@ def _native_request(request: dict[str, Any]) -> dict[str, Any]:
|
|
|
507
514
|
|
|
508
515
|
|
|
509
516
|
def _generate_image(state: ServerState, request: dict[str, Any]) -> dict[str, Any]:
|
|
517
|
+
with media_gpu_slot("image", cancelled=state.shutdown_requested) as lease:
|
|
518
|
+
try:
|
|
519
|
+
return _generate_image_locked(state, request)
|
|
520
|
+
except (UpstreamTransportError, OSError, urllib.error.URLError, http.client.HTTPException) as error:
|
|
521
|
+
# A lost HTTP connection does not prove the synchronous native
|
|
522
|
+
# renderer stopped. Keep a durable fence after this worker exits.
|
|
523
|
+
lease.mark_uncertain("image_transport_lost")
|
|
524
|
+
if isinstance(error, UpstreamError):
|
|
525
|
+
raise
|
|
526
|
+
raise UpstreamTransportError("native image outcome is uncertain") from error
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def _generate_image_locked(state: ServerState, request: dict[str, Any]) -> dict[str, Any]:
|
|
510
530
|
max_json_bytes = math.ceil(state.max_output_bytes / 3) * 4 + 131_072
|
|
511
531
|
status, payload = _bounded_json_request(
|
|
512
532
|
f"{state.upstream_base_url}/v1/images/generations",
|
|
@@ -776,6 +796,10 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
776
796
|
ApiError(404, "not found", error_type="not_found_error")
|
|
777
797
|
)
|
|
778
798
|
return
|
|
799
|
+
gpu = media_gpu_health() if self.path == "/healthz" else None
|
|
800
|
+
if self.path == "/healthz" and gpu not in ("ready", "busy"):
|
|
801
|
+
self._send_json(503, {"status": "unhealthy", "model": state.model_id, "media_gpu": gpu})
|
|
802
|
+
return
|
|
779
803
|
try:
|
|
780
804
|
_check_upstream_model(state)
|
|
781
805
|
except UpstreamError:
|
|
@@ -801,6 +825,7 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
801
825
|
"status": "ok",
|
|
802
826
|
"model": state.model_id,
|
|
803
827
|
"upstream_model": state.upstream_model_id,
|
|
828
|
+
"media_gpu": gpu,
|
|
804
829
|
"upstream": "stable-diffusion.cpp",
|
|
805
830
|
},
|
|
806
831
|
)
|
|
@@ -921,7 +946,8 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
921
946
|
threading.Thread(
|
|
922
947
|
target=run_generation,
|
|
923
948
|
name="sd-cpp-image-generation",
|
|
924
|
-
|
|
949
|
+
# Preserve the GPU lease until non-cancellable inference ends.
|
|
950
|
+
daemon=False,
|
|
925
951
|
).start()
|
|
926
952
|
if not completed.wait(state.inference_timeout_seconds):
|
|
927
953
|
logging.error("generation exceeded client deadline; native request still active")
|
|
@@ -947,6 +973,10 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
947
973
|
)
|
|
948
974
|
elif isinstance(error, ApiError):
|
|
949
975
|
self._send_error(error)
|
|
976
|
+
elif isinstance(error, MediaGpuError):
|
|
977
|
+
self._send_error(
|
|
978
|
+
ApiError(error.status, str(error), error_type="server_error", code=error.code)
|
|
979
|
+
)
|
|
950
980
|
elif isinstance(error, UpstreamTimeout):
|
|
951
981
|
logging.error("generation failed reason=upstream timeout")
|
|
952
982
|
self._send_error(
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
--- a/examples/common/media_io.cpp
|
|
2
|
+
+++ b/examples/common/media_io.cpp
|
|
3
|
+
@@ -1212,6 +1212,9 @@
|
|
4
|
+
|
|
5
|
+
const uint64_t frame_duration_ns = std::max<uint64_t>(
|
|
6
|
+
1, static_cast<uint64_t>(std::llround(1000000000.0 / static_cast<double>(fps))));
|
|
7
|
+
+ if (video_track != nullptr) {
|
|
8
|
+
+ video_track->set_default_duration(frame_duration_ns);
|
|
9
|
+
+ }
|
|
10
|
+
uint64_t timestamp_ns = 0;
|
|
11
|
+
|
|
12
|
+
for (int i = 0; i < num_images; ++i) {
|
|
13
|
+
@@ -1256,6 +1259,9 @@
|
|
14
|
+
timestamp_ns += frame_duration_ns;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
+ // Include the final frame's display interval, not only its timestamp.
|
|
18
|
+
+ segment.set_duration(static_cast<double>(timestamp_ns) /
|
|
19
|
+
+ segment.GetSegmentInfo()->timecode_scale());
|
|
20
|
+
if (!segment.Finalize()) {
|
|
21
|
+
fprintf(stderr, "Error: Failed to finalize WebM output.\n");
|
|
22
|
+
return -1;
|
|
@@ -10,6 +10,7 @@ import ipaddress
|
|
|
10
10
|
import json
|
|
11
11
|
import logging
|
|
12
12
|
import math
|
|
13
|
+
import re
|
|
13
14
|
import secrets
|
|
14
15
|
import signal
|
|
15
16
|
import threading
|
|
@@ -22,6 +23,8 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
|
22
23
|
from socketserver import TCPServer
|
|
23
24
|
from typing import Any
|
|
24
25
|
|
|
26
|
+
from media_gpu_lock import MediaGpuError, MediaGpuLease, media_gpu_health, media_gpu_slot
|
|
27
|
+
|
|
25
28
|
|
|
26
29
|
DEFAULT_HOST = "127.0.0.1"
|
|
27
30
|
DEFAULT_PORT = 11448
|
|
@@ -103,7 +106,7 @@ class ServerState:
|
|
|
103
106
|
|
|
104
107
|
|
|
105
108
|
class VideoHttpServer(ThreadingHTTPServer):
|
|
106
|
-
daemon_threads =
|
|
109
|
+
daemon_threads = False
|
|
107
110
|
request_queue_size = 8
|
|
108
111
|
|
|
109
112
|
def server_bind(self) -> None:
|
|
@@ -411,17 +414,20 @@ def _native_request(request: dict[str, Any]) -> dict[str, Any]:
|
|
|
411
414
|
}
|
|
412
415
|
|
|
413
416
|
|
|
414
|
-
def _cancel_job(state: ServerState, job_id: str) ->
|
|
417
|
+
def _cancel_job(state: ServerState, job_id: str) -> bool:
|
|
415
418
|
try:
|
|
416
|
-
_bounded_json_request(
|
|
419
|
+
status, job = _bounded_json_request(
|
|
417
420
|
f"{state.upstream_base_url}/sdcpp/v1/jobs/{urllib.parse.quote(job_id, safe='')}/cancel",
|
|
418
421
|
method="POST",
|
|
419
422
|
timeout=state.request_timeout_seconds,
|
|
420
423
|
max_bytes=65_536,
|
|
421
424
|
payload={},
|
|
422
425
|
)
|
|
426
|
+
return status == 200 and job.get("id") == job_id and job.get("status") in (
|
|
427
|
+
"completed", "failed", "cancelled"
|
|
428
|
+
)
|
|
423
429
|
except UpstreamError:
|
|
424
|
-
|
|
430
|
+
return False
|
|
425
431
|
|
|
426
432
|
|
|
427
433
|
def _set_active_job(state: ServerState, job_id: str) -> None:
|
|
@@ -435,8 +441,39 @@ def _clear_active_job(state: ServerState, job_id: str) -> None:
|
|
|
435
441
|
state.active_job_id = None
|
|
436
442
|
|
|
437
443
|
|
|
438
|
-
def
|
|
444
|
+
def _wait_for_native_job_end(state: ServerState, job_id: str) -> None:
|
|
445
|
+
"""Keep the GPU lease until a running, non-cancellable native job ends."""
|
|
446
|
+
url = f"{state.upstream_base_url}/sdcpp/v1/jobs/{urllib.parse.quote(job_id, safe='')}"
|
|
447
|
+
max_bytes = math.ceil(state.max_output_bytes / 3) * 4 + 65_536
|
|
448
|
+
logged_wait = False
|
|
449
|
+
while True:
|
|
450
|
+
try:
|
|
451
|
+
status, job = _bounded_json_request(
|
|
452
|
+
url, method="GET", timeout=state.request_timeout_seconds,
|
|
453
|
+
max_bytes=max_bytes,
|
|
454
|
+
)
|
|
455
|
+
if (
|
|
456
|
+
status == 200 and job.get("id") == job_id
|
|
457
|
+
and job.get("status") in ("completed", "failed", "cancelled")
|
|
458
|
+
):
|
|
459
|
+
return
|
|
460
|
+
except UpstreamError:
|
|
461
|
+
# A lost HTTP connection does not prove GPU inference has stopped.
|
|
462
|
+
pass
|
|
463
|
+
if not logged_wait:
|
|
464
|
+
logging.warning("waiting for native video completion before releasing media GPU")
|
|
465
|
+
logged_wait = True
|
|
466
|
+
time.sleep(max(0.1, state.poll_interval_seconds))
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
def _generate_video(state: ServerState, request: dict[str, Any], cancelled: threading.Event | None = None) -> dict[str, Any]:
|
|
470
|
+
with media_gpu_slot("video", cancelled=cancelled, shutdown=state.shutdown_requested) as lease:
|
|
471
|
+
return _generate_video_locked(state, request, lease)
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
def _generate_video_locked(state: ServerState, request: dict[str, Any], lease: MediaGpuLease) -> dict[str, Any]:
|
|
439
475
|
max_json_bytes = math.ceil(state.max_output_bytes / 3) * 4 + 65_536
|
|
476
|
+
lease.mark_uncertain("video_submission_pending")
|
|
440
477
|
status, submission = _bounded_json_request(
|
|
441
478
|
f"{state.upstream_base_url}/sdcpp/v1/vid_gen",
|
|
442
479
|
method="POST",
|
|
@@ -445,6 +482,7 @@ def _generate_video(state: ServerState, request: dict[str, Any]) -> dict[str, An
|
|
|
445
482
|
payload=_native_request(request),
|
|
446
483
|
)
|
|
447
484
|
if status == 429:
|
|
485
|
+
lease.confirm_finished()
|
|
448
486
|
raise ApiError(
|
|
449
487
|
429,
|
|
450
488
|
"the local video generator queue is full",
|
|
@@ -452,18 +490,23 @@ def _generate_video(state: ServerState, request: dict[str, Any]) -> dict[str, An
|
|
|
452
490
|
code="upstream_queue_saturated",
|
|
453
491
|
)
|
|
454
492
|
if status != 202:
|
|
493
|
+
lease.confirm_finished()
|
|
455
494
|
raise UpstreamError(f"stable-diffusion.cpp rejected video submission ({status})")
|
|
456
495
|
job_id = submission.get("id")
|
|
457
496
|
poll_url = submission.get("poll_url")
|
|
458
|
-
|
|
497
|
+
valid_job_id = isinstance(job_id, str) and re.fullmatch(r"[A-Za-z0-9_-]{1,256}", job_id) is not None
|
|
498
|
+
expected_poll_url = f"/sdcpp/v1/jobs/{job_id}" if valid_job_id else None
|
|
499
|
+
if valid_job_id:
|
|
500
|
+
lease.record_native_job(job_id)
|
|
459
501
|
if (
|
|
460
|
-
not
|
|
461
|
-
or not job_id
|
|
502
|
+
not valid_job_id
|
|
462
503
|
or poll_url != expected_poll_url
|
|
463
504
|
or submission.get("kind") != "vid_gen"
|
|
464
505
|
):
|
|
465
|
-
if
|
|
466
|
-
_cancel_job(state, job_id)
|
|
506
|
+
if valid_job_id:
|
|
507
|
+
if not _cancel_job(state, job_id):
|
|
508
|
+
_wait_for_native_job_end(state, job_id)
|
|
509
|
+
lease.confirm_finished()
|
|
467
510
|
raise UpstreamError("stable-diffusion.cpp returned an invalid video job")
|
|
468
511
|
|
|
469
512
|
_set_active_job(state, job_id)
|
|
@@ -478,20 +521,25 @@ def _generate_video(state: ServerState, request: dict[str, Any]) -> dict[str, An
|
|
|
478
521
|
)
|
|
479
522
|
if status != 200:
|
|
480
523
|
raise UpstreamError(f"stable-diffusion.cpp video poll failed ({status})")
|
|
524
|
+
if job.get("id") != job_id:
|
|
525
|
+
raise UpstreamError("stable-diffusion.cpp returned another video job")
|
|
481
526
|
job_status = job.get("status")
|
|
482
527
|
if job_status in ("queued", "generating"):
|
|
483
528
|
state.shutdown_requested.wait(state.poll_interval_seconds)
|
|
484
529
|
continue
|
|
485
530
|
if job_status == "failed":
|
|
531
|
+
lease.confirm_finished()
|
|
486
532
|
error = job.get("error")
|
|
487
533
|
code = error.get("code") if isinstance(error, dict) else None
|
|
488
534
|
raise UpstreamError(
|
|
489
535
|
f"stable-diffusion.cpp video generation failed ({code or 'generation_failed'})"
|
|
490
536
|
)
|
|
491
537
|
if job_status == "cancelled":
|
|
538
|
+
lease.confirm_finished()
|
|
492
539
|
raise UpstreamError("stable-diffusion.cpp video generation was cancelled")
|
|
493
540
|
if job_status != "completed" or job.get("kind") != "vid_gen":
|
|
494
541
|
raise UpstreamError("stable-diffusion.cpp returned an invalid video job status")
|
|
542
|
+
lease.confirm_finished()
|
|
495
543
|
result = job.get("result")
|
|
496
544
|
if not isinstance(result, dict):
|
|
497
545
|
raise UpstreamError("stable-diffusion.cpp completed without a video result")
|
|
@@ -510,7 +558,9 @@ def _generate_video(state: ServerState, request: dict[str, Any]) -> dict[str, An
|
|
|
510
558
|
code="generation_timeout",
|
|
511
559
|
)
|
|
512
560
|
except Exception:
|
|
513
|
-
_cancel_job(state, job_id)
|
|
561
|
+
if not _cancel_job(state, job_id):
|
|
562
|
+
_wait_for_native_job_end(state, job_id)
|
|
563
|
+
lease.confirm_finished()
|
|
514
564
|
raise
|
|
515
565
|
finally:
|
|
516
566
|
_clear_active_job(state, job_id)
|
|
@@ -600,6 +650,10 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
600
650
|
|
|
601
651
|
def do_GET(self) -> None:
|
|
602
652
|
if self.path == "/healthz":
|
|
653
|
+
gpu = media_gpu_health()
|
|
654
|
+
if gpu not in ("ready", "busy"):
|
|
655
|
+
self._send_json(503, {"status": "unhealthy", "model": state.model_id, "media_gpu": gpu})
|
|
656
|
+
return
|
|
603
657
|
try:
|
|
604
658
|
_check_upstream_ready(state)
|
|
605
659
|
except UpstreamError:
|
|
@@ -614,6 +668,7 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
614
668
|
"status": "ok",
|
|
615
669
|
"model": state.model_id,
|
|
616
670
|
"upstream": "stable-diffusion.cpp",
|
|
671
|
+
"media_gpu": gpu,
|
|
617
672
|
},
|
|
618
673
|
)
|
|
619
674
|
return
|
|
@@ -694,9 +749,31 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
694
749
|
)
|
|
695
750
|
return
|
|
696
751
|
started_at = time.monotonic()
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
752
|
+
completed = threading.Event()
|
|
753
|
+
cancelled = threading.Event()
|
|
754
|
+
outcome: dict[str, Any] = {}
|
|
755
|
+
|
|
756
|
+
def run_generation() -> None:
|
|
757
|
+
try:
|
|
758
|
+
native_result = _generate_video(state, parsed, cancelled)
|
|
759
|
+
outcome["output"] = _validate_result(native_result, parsed, state)
|
|
760
|
+
except BaseException as error:
|
|
761
|
+
outcome["error"] = error
|
|
762
|
+
finally:
|
|
763
|
+
# A response deadline does not release native GPU ownership.
|
|
764
|
+
state.inference_slots.release()
|
|
765
|
+
completed.set()
|
|
766
|
+
|
|
767
|
+
threading.Thread(target=run_generation, name="wan-video-generation", daemon=False).start()
|
|
768
|
+
if not completed.wait(state.inference_timeout_seconds):
|
|
769
|
+
# Stop a request still waiting for admission. Already-admitted
|
|
770
|
+
# native jobs keep their slot/lease until their state is terminal.
|
|
771
|
+
cancelled.set()
|
|
772
|
+
self._send_error(ApiError(504, "video generation timed out", error_type="server_error", code="generation_timeout"))
|
|
773
|
+
return
|
|
774
|
+
error = outcome.get("error")
|
|
775
|
+
if error is None:
|
|
776
|
+
output = outcome["output"]
|
|
700
777
|
self._send_json(
|
|
701
778
|
200,
|
|
702
779
|
{
|
|
@@ -711,9 +788,13 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
711
788
|
output["fps"],
|
|
712
789
|
int((time.monotonic() - started_at) * 1000),
|
|
713
790
|
)
|
|
714
|
-
|
|
791
|
+
elif isinstance(error, ApiError):
|
|
715
792
|
self._send_error(error)
|
|
716
|
-
|
|
793
|
+
elif isinstance(error, MediaGpuError):
|
|
794
|
+
self._send_error(
|
|
795
|
+
ApiError(error.status, str(error), error_type="server_error", code=error.code)
|
|
796
|
+
)
|
|
797
|
+
else:
|
|
717
798
|
logging.error("generation failed reason=%s", str(error))
|
|
718
799
|
self._send_error(
|
|
719
800
|
ApiError(
|
|
@@ -723,8 +804,6 @@ def _handler_for(state: ServerState) -> type[BaseHTTPRequestHandler]:
|
|
|
723
804
|
code="upstream_generation_failed",
|
|
724
805
|
)
|
|
725
806
|
)
|
|
726
|
-
finally:
|
|
727
|
-
state.inference_slots.release()
|
|
728
807
|
|
|
729
808
|
return Handler
|
|
730
809
|
|