refactor skyvern current state json file (#2489)

This commit is contained in:
Shuchang Zheng
2025-05-27 17:38:24 -07:00
committed by GitHub
parent 306eac8a58
commit 1e16559141
3 changed files with 34 additions and 5 deletions

View File

@@ -94,7 +94,7 @@ class BaseStorage(ABC):
pass
@abstractmethod
async def get_streaming_file(self, organization_id: str, file_name: str, use_default: bool = True) -> bytes | None:
async def get_streaming_file(self, organization_id: str, file_name: str) -> bytes | None:
pass
@abstractmethod

View File

@@ -116,10 +116,10 @@ class LocalStorage(BaseStorage):
async def save_streaming_file(self, organization_id: str, file_name: str) -> None:
return
async def get_streaming_file(self, organization_id: str, file_name: str, use_default: bool = True) -> bytes | None:
file_path = Path(f"{get_skyvern_temp_dir()}/skyvern_screenshot.png")
if not use_default:
file_path = Path(f"{get_skyvern_temp_dir()}/{organization_id}/{file_name}")
async def get_streaming_file(self, organization_id: str, file_name: str) -> bytes | None:
# make the directory if it doesn't exist
Path(f"{get_skyvern_temp_dir()}/{organization_id}").mkdir(parents=True, exist_ok=True)
file_path = Path(f"{get_skyvern_temp_dir()}/{organization_id}/{file_name}")
try:
with open(file_path, "rb") as f:
return f.read()