update: remove storage

This commit is contained in:
tao.chen
2026-08-05 13:41:13 +08:00
parent 309b657d35
commit f4cabe6e20
8 changed files with 683 additions and 332 deletions
+39 -7
View File
@@ -1,15 +1,27 @@
"""Schedule-specific storage client built on the shared ``StorageClient``."""
"""Schedule-side HTTP client for the backend's storage API.
The schedule worker uploads run logs / run results by calling
``POST {backend}/internal/v1/objects`` (the backend's
``create_server_object_payload`` route, which is in the same process
as the public API). The response is the StorageObjects row payload.
The schedule does NOT have its own DB session for storage metadata,
so it must go through the backend to create the StorageObjects row
(``logs_object_id`` / ``result_object_id`` are FKs into that table).
"""
from __future__ import annotations
import base64
from typing import Any
# TODO: common.storage.client.StorageClient was removed in the S3 migration.
# This module is temporary dead code; rewrite to use AsyncStorageBackend.
# from common.storage.client import StorageClient
import httpx
class SchedulerStorageClient:
def __init__(self, http_client: httpx.AsyncClient) -> None:
self._http = http_client
async def create_object(
self,
*,
@@ -21,10 +33,30 @@ class SchedulerStorageClient:
content: bytes,
idempotency_key: str,
) -> dict[str, Any]:
raise NotImplementedError(
"TODO: SchedulerStorageClient is dead code post-migration; "
"rewrite to use AsyncStorageBackend directly"
"""Upload a run_log / run_result via the backend's storage API.
The backend returns ``{"data": <StorageObjectPayload>, "meta": {...}}``;
we return the inner ``data`` dict (which includes
``storage_object_id`` and ``storage_uri``).
"""
response = await self._http.post(
"/internal/v1/objects",
json={
"workspace_id": workspace_id,
"user_id": user_id,
"usage_type": usage_type,
"file_name": file_name,
"content_type": content_type,
"content_base64": base64.b64encode(content).decode("ascii"),
"visibility": "workspace",
"is_immutable": True,
"idempotency_key": idempotency_key,
"relative_path": None,
},
)
response.raise_for_status()
body = response.json()
return body["data"]
__all__ = ["SchedulerStorageClient"]