MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / restore_task_files

Function restore_task_files

src/harness/checkpoints/workspace.py:222–391  ·  view source on GitHub ↗

Restore only the specific task's output files from backup. This method restores: 1. The task's output directory (e.g., outputs/ /) 2. Any other non-outputs files in the workspace Args: backup_dir: The backup directory (e.g., workspace_persistent). tar

(
    backup_dir: Path,
    target_dir: Path,
    task_output_subdir: str,
    logger: Optional[Callable[[str], None]] = None,
)

Source from the content-addressed store, hash-verified

220
221
222def restore_task_files(
223 backup_dir: Path,
224 target_dir: Path,
225 task_output_subdir: str,
226 logger: Optional[Callable[[str], None]] = None,
227) -> bool:
228 """
229 Restore only the specific task's output files from backup.
230
231 This method restores:
232 1. The task&#x27;s output directory (e.g., outputs/<task_name>/)
233 2. Any other non-outputs files in the workspace
234
235 Args:
236 backup_dir: The backup directory (e.g., workspace_persistent).
237 target_dir: The target workspace directory (e.g., HOST_WORKSPACE).
238 task_output_subdir: The relative path to the task&#x27;s output dir (e.g., "outputs/my_task").
239 logger: Optional logger callable.
240
241 Returns:
242 True if restore succeeded, False otherwise.
243 """
244
245 def _log(msg: str):
246 if logger:
247 logger(msg)
248 else:
249 print(msg)
250
251 backup_dir = Path(backup_dir)
252 target_dir = Path(target_dir)
253
254 if not backup_dir.exists():
255 _log(f"[Checkpoint] Task restore skipped: backup {backup_dir} does not exist")
256 return False
257
258 success = True
259 task_outputs_found = False
260
261 # 1. Restore the specific task's output directory
262 task_backup = backup_dir / task_output_subdir
263 task_target = target_dir / task_output_subdir
264
265 if task_backup.exists():
266 task_target.parent.mkdir(parents=True, exist_ok=True)
267
268 try:
269 # Use --ignore-errors to continue even if some files can't be transferred
270 # Use --partial to keep partially transferred files
271 cmd = [
272 "rsync",
273 "-a",
274 "--checksum",
275 "--no-owner",
276 "--no-group",
277 "--ignore-errors",
278 "--partial",
279 "--exclude",

Callers

nothing calls this directly

Calls 2

_logFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected