MCPcopy Create free account
hub / github.com/VitoHowe/glm-coding / ensure_capacity

Method ensure_capacity

app/services/ocr_service.py:199–251  ·  view source on GitHub ↗
(self, requested_workers: int)

Source from the content-addressed store, hash-verified

197 def _normalize_result(self, result: dict[str, Any]) -> dict[str, Any]:
198 normalized = self._json_safe(dict(result))
199 debug_png = normalized.pop("debug_png", b"")
200 if isinstance(debug_png, bytes) and debug_png:
201 normalized["debug_image_base64"] = "data:image/png;base64," + base64.b64encode(debug_png).decode("ascii")
202 return normalized
203
204 def _json_safe(self, value: Any) -> Any:
205 if isinstance(value, dict):
206 return {str(key): self._json_safe(item) for key, item in value.items()}
207 if isinstance(value, (list, tuple)):
208 return [self._json_safe(item) for item in value]
209 if isinstance(value, bytes):
210 return value
211 if hasattr(value, "item"):
212 return value.item()
213 return value
214
215
216_ocr_service: OcrService | None = None
217
218
219def get_ocr_service() -> OcrService:
220 """Get the shared OCR service."""
221 global _ocr_service
222 if _ocr_service is None:
223 _ocr_service = OcrService()
224 return _ocr_service

Callers 3

warmupMethod · 0.95
reserve_capacityMethod · 0.95
_background_warmupMethod · 0.95

Calls 8

status_payloadMethod · 0.95
_missing_dependenciesMethod · 0.95
_ensure_executorMethod · 0.95
_inflight_snapshotMethod · 0.95
shutdownMethod · 0.95
BadRequestErrorClass · 0.90

Tested by

no test coverage detected