Skip to content

Commit e940243

Browse files
corbtclaude
andauthored
feat: Add placeholder _log() implementation for ServerlessBackend (#422)
Implements a local file-based placeholder for ServerlessBackend._log() to unblock usage of ServerlessBackend with code that calls model.log(). Changes: - Writes trajectory groups to local JSONL files using same format as LocalBackend - Uses /tmp/serverless-training-logs by default (configurable via ART_SERVERLESS_LOG_DIR) - Organizes logs by model name, split, and step number - Marked with TODO for future proper serverless API implementation This allows ServerlessBackend to be used immediately while proper remote logging is being developed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
1 parent 41c48f8 commit e940243

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/art/serverless/backend.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,27 @@ async def _log(
9999
trajectory_groups: list[TrajectoryGroup],
100100
split: str = "val",
101101
) -> None:
102-
raise NotImplementedError
102+
# TODO: Implement proper serverless logging via API
103+
# For now, write to local jsonl file as a placeholder
104+
import os
105+
from pathlib import Path
106+
107+
from ..utils.trajectory_logging import serialize_trajectory_groups
108+
109+
# Create log directory (configurable via env var)
110+
log_base = os.getenv("ART_SERVERLESS_LOG_DIR", "/tmp/serverless-training-logs")
111+
log_dir = Path(log_base) / model.name / split
112+
log_dir.mkdir(parents=True, exist_ok=True)
113+
114+
# Get current step
115+
step = await model.get_step()
116+
file_path = log_dir / f"{step:04d}.jsonl"
117+
118+
# Write trajectory groups to jsonl
119+
with open(file_path, "w") as f:
120+
f.write(serialize_trajectory_groups(trajectory_groups))
121+
122+
print(f"[ServerlessBackend] Logged {len(trajectory_groups)} groups to {file_path}")
103123

104124
async def _train_model(
105125
self,

0 commit comments

Comments
 (0)