Skip to content

Commit

Permalink
Add client side support for the DocumentAsset type (#736)
Browse files Browse the repository at this point in the history
* Add client side support for the DocumentAsset type

* Allow for .md and .log files as well
  • Loading branch information
munkyshi authored Jan 7, 2025
1 parent 3c8fb7e commit a623c29
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/dataset/core-concepts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ as text. Below table outlines what extensions are supported for optimal visualiz
| Image | `jpg`, `jpeg`, `png`, `gif`, `bmp` and other web browser supported image types. |
| Audio | `flac`, `mp3`, `wav`, `acc`, `ogg`, `ra` and other web browser supported audio types. |
| Video | `mov`, `mp4`, `mpeg` and other web browser supported video types. |
| Document | `txt` and `pdf` files. |
| Document | `txt`, `pdf`, `log`, `md` files. |
| Point Cloud | `pcd` files. |

**Assets**: allow you to connect multiple referenced files to each datapoint for visualization and analysis.
Expand All @@ -81,6 +81,7 @@ Multiple assets can be attached to a single datapoint.
| [`VideoAsset`](../../reference/asset.md#kolena.asset.VideoAsset) | Useful if you want to attach a video file. | Same as above reference files |
| [`PointCloudAsset`](../../reference/asset.md#kolena.asset.PointCloudAsset) | Useful for attaching 3D point cloud data. | `.pcd`, `.npy`, `.npz` |
| [`MeshAsset`](../../reference/asset.md#kolena.asset.MeshAsset) | Useful for attaching and visualizing 3D mesh files. | `.ply` |
| [`DocumentAsset`](../../reference/asset.md#kolena.asset.DocumentAsset) | Useful if you want to attach a document file. | `.pdf`, `.txt`, `.log`, `.md` |

**Annotations**: allow you to visualize overlays on top of datapoints through the use of[`annotation`](../../reference/annotation.md).
We currently support 10 different types of annotations each enabling a specific modality.
Expand Down
19 changes: 19 additions & 0 deletions kolena/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- [`VideoAsset`][kolena.asset.VideoAsset]
- [`AudioAsset`][kolena.asset.AudioAsset]
- [`MeshAsset`][kolena.asset.MeshAsset]
- [`DocumentAsset`][kolena.asset.DocumentAsset]
"""
from abc import ABCMeta
Expand All @@ -44,6 +45,7 @@ class _AssetType(DataType):
VIDEO = "VIDEO"
AUDIO = "AUDIO"
MESH = "MESH"
DOCUMENT = "DOCUMENT"

@staticmethod
def _data_category() -> DataCategory:
Expand Down Expand Up @@ -188,6 +190,22 @@ def _data_type() -> _AssetType:
return _AssetType.MESH


@dataclass(frozen=True, config=ValidatorConfig)
class DocumentAsset(Asset):
"""
A document file in a cloud bucket or served at a URL.
Supported extensions include `.pdf`, `.txt`, `.log`, and `.md`.
"""

locator: str
"""The location of this document file in a cloud bucket, e.g. `s3://my-bucket/path/to/my-document-asset.pdf`."""

@staticmethod
def _data_type() -> _AssetType:
return _AssetType.DOCUMENT


_ASSET_TYPES = [
ImageAsset,
PlainTextAsset,
Expand All @@ -197,4 +215,5 @@ def _data_type() -> _AssetType:
VideoAsset,
AudioAsset,
MeshAsset,
DocumentAsset,
]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies = [
"numpy >=1.26,<2; python_version >= '3.12'",
"pandas >=1.1,<3; python_version < '3.12'",
"pandas >=2.1.1,<3; python_version >= '3.12'",
"pandera>=0.9,<1",
"pandera>=0.22.1,<1",
"pydantic>=1.10,<3",
"dacite>=1.6,<2",
"requests>=2.20,<3",
Expand Down

0 comments on commit a623c29

Please sign in to comment.