Skip to content

Commit 4482e7e

Browse files
authored
feat: make temp uri readable, and enlarge timeout of add-resource (#165)
1 parent f1f6b9b commit 4482e7e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

openviking/storage/viking_fs.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,10 +1021,7 @@ async def move_file(
10211021

10221022
def create_temp_uri(self) -> str:
10231023
"""Create temp directory URI."""
1024-
import uuid
1025-
1026-
temp_id = uuid.uuid4().hex[:8]
1027-
return f"viking://temp/{temp_id}"
1024+
return VikingURI.create_temp_uri()
10281025

10291026
async def delete_temp(self, temp_uri: str) -> None:
10301027
"""Delete temp directory and its contents."""

openviking_cli/cli/commands/resources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def add_resource_command(
2020
reason: str = typer.Option("", help="Reason for import"),
2121
instruction: str = typer.Option("", help="Additional instruction"),
2222
wait: bool = typer.Option(False, "--wait", help="Wait until processing is complete"),
23-
timeout: Optional[float] = typer.Option(None, help="Wait timeout in seconds"),
23+
timeout: Optional[float] = typer.Option(600.0, help="Wait timeout in seconds"),
2424
) -> None:
2525
"""Add resources into OpenViking."""
2626
run(
@@ -40,7 +40,7 @@ def add_skill_command(
4040
ctx: typer.Context,
4141
data: str = typer.Argument(..., help="Skill directory, SKILL.md, or raw content"),
4242
wait: bool = typer.Option(False, "--wait", help="Wait until processing is complete"),
43-
timeout: Optional[float] = typer.Option(None, help="Wait timeout in seconds"),
43+
timeout: Optional[float] = typer.Option(600.0, help="Wait timeout in seconds"),
4444
) -> None:
4545
"""Add a skill into OpenViking."""
4646
run(

openviking_cli/utils/uri.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,12 @@ def __eq__(self, other) -> bool:
244244

245245
def __hash__(self) -> int:
246246
return hash(self.uri)
247+
248+
@classmethod
249+
def create_temp_uri(cls) -> str:
250+
"""Create temp directory URI like viking://temp/MMDDHHMM_XXXXXX"""
251+
import datetime
252+
import uuid
253+
254+
temp_id = uuid.uuid4().hex[:6]
255+
return f"viking://temp/{datetime.datetime.now().strftime('%m%d%H%M')}_{temp_id}"

0 commit comments

Comments
 (0)