We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b830393 commit 8d35d4bCopy full SHA for 8d35d4b
src/virtualship/cli/_fetch.py
@@ -37,11 +37,18 @@ def hash_model(model: BaseModel) -> str:
37
38
def filename_to_hash(filename: str) -> str:
39
"""Extract hash from filename of the format YYYYMMDD_HHMMSS_{hash}."""
40
- return filename.split("_")[-1]
+ parts = filename.split("_")
41
+ if len(parts) != 3:
42
+ raise ValueError(
43
+ f"Filename '{filename}' must have 3 parts delimited with underscores."
44
+ )
45
+ return parts[-1]
46
47
48
def hash_to_filename(hash: str) -> str:
49
"""Return a filename of the format YYYYMMDD_HHMMSS_{hash}."""
50
+ if "_" in hash:
51
+ raise ValueError("Hash cannot contain underscores.")
52
return f"{datetime.now().strftime('%Y%m%d_%H%M%S')}_{hash}"
53
54
0 commit comments