Spaces:
Running
Running
Download plugins/_time_travel/api/history_diff.py from Leon4gr45/openoperator: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/Leon4gr45/openoperator/resolve/main/plugins/_time_travel/api/history_diff.py
- Command line
-
hf download hf://spaces/Leon4gr45/openoperator/plugins/_time_travel/api/history_diff.py
-
curl -L -o history_diff.py https://huggingface.co/spaces/Leon4gr45/openoperator/resolve/main/plugins/_time_travel/api/history_diff.py
1.13 kB
| from __future__ import annotations | |
| from helpers.api import ApiHandler, Request, Response | |
| from plugins._time_travel.helpers.time_travel import ( | |
| TimeTravelError, | |
| TimeTravelService, | |
| WorkspaceRejectedError, | |
| resolve_workspace, | |
| ) | |
| class HistoryDiff(ApiHandler): | |
| async def process(self, input: dict, request: Request) -> dict | Response: | |
| context_id = str(input.get("context_id") or "").strip() | |
| workspace_id = str(input.get("workspace_id") or "").strip() | |
| try: | |
| workspace = resolve_workspace( | |
| context_id, | |
| workspace_id=workspace_id, | |
| context_loader=self.use_context, | |
| ) | |
| return TimeTravelService(workspace).history_diff( | |
| commit_hash=str(input.get("commit_hash") or ""), | |
| path=str(input.get("path") or ""), | |
| mode=str(input.get("mode") or "commit"), | |
| ) | |
| except WorkspaceRejectedError as exc: | |
| return {"ok": False, "locked": True, "error": str(exc)} | |
| except TimeTravelError as exc: | |
| return {"ok": False, "error": str(exc)} | |