INNER CODE UNIT · Python
get_sample_artifact
416rehman/DeepZero · src/deepzero/api/server.py:108
async def get_sample_artifact(request: Request) -> JSONResponseType:
sample_id = request.path_params["sample_id"]
artifact_name = request.path_params["name"]
sample_dir = store.sample_dir(sample_id)
state = await _run_sync(store.load_sample, sample_id)
if state is None:
return JSONResponse({"error": "sample not found"}, status_code=404)
# find artifact path from state
for stage_state in state.history.values():
for aname, apath in stage_state.artifacts.items():
if aname == artifact_name:
full_path = sample_dir / apath
if full_path.exists():
content = full_path.read_text(encoding="utf-8", errors="replace")
return JSONResponse({"artifact": artifact_name, "content": content})