class DatasetV2(SQLModel, table=True):
"""
Dataset table.
"""
model_config = ConfigDict(arbitrary_types_allowed=True)
id: int | None = Field(default=None, primary_key=True)
name: str
project_id: int = Field(foreign_key="projectv2.id", ondelete="CASCADE")
project: "ProjectV2" = Relationship( # noqa: F821
sa_relationship_kwargs=dict(lazy="selectin"),
)
history: list[dict[str, Any]] = Field(
sa_column=Column(JSONB, server_default="[]", nullable=False)
)
timestamp_created: datetime = Field(
default_factory=get_timestamp,
sa_column=Column(DateTime(timezone=True), nullable=False),
)
zarr_dir: str
images: list[dict[str, Any]] = Field(
sa_column=Column(JSONB, server_default="[]", nullable=False)
)
@property
def image_zarr_urls(self) -> list[str]:
return [image["zarr_url"] for image in self.images]