Skip to content

Commit

Permalink
earlier error handling for missing bitstream files
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakers-the-rat committed Nov 6, 2024
1 parent bcb69df commit 08a0da3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions miniscope_io/models/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,12 @@ def resolve_relative(cls, value: Path) -> Path:
if not value.is_absolute():
value = DEVICE_DIR / value
return value

@field_validator("bitstream", mode="after")
def ensure_exists(cls, value: Optional[Path]) -> Optional[Path]:
"""If a bitstream file has been provided, ensure it exists"""
if isinstance(value, Path):
assert (
value.exists()
), f"Configured to use bitstream file {value}, but it does not exist"
return value

0 comments on commit 08a0da3

Please sign in to comment.