(self)
| 58 | filename: str | None = None |
| 59 | |
| 60 | def load_bytes(self) -> bytes: |
| 61 | if self.source_kind == "bytes": |
| 62 | if isinstance(self.value, bytes): |
| 63 | return self.value |
| 64 | raise ValueError( |
| 65 | f"generic model 'unknown' does not support {self.modality.value!r} source " |
| 66 | f"{self.source_kind!r} for field 'unknown'." |
| 67 | ) |
| 68 | if self.source_kind == "base64": |
| 69 | if not isinstance(self.value, str): |
| 70 | raise ValueError("base64 media value must be a string") |
| 71 | raw = self.value |
| 72 | if raw.startswith("data:") and "," in raw: |
| 73 | raw = raw.split(",", 1)[1] |
| 74 | return base64.b64decode(raw) |
| 75 | if self.source_kind == "path": |
| 76 | if not isinstance(self.value, str): |
| 77 | raise ValueError("path media value must be a string") |
| 78 | return Path(self.value).read_bytes() |
| 79 | raise ValueError( |
| 80 | f"generic model 'unknown' does not support {self.modality.value!r} source " |
| 81 | f"{self.source_kind!r} for field 'unknown'." |
| 82 | ) |
| 83 | |
| 84 | def fingerprint(self) -> str: |
| 85 | digest = hashlib.sha256() |
no outgoing calls
no test coverage detected