chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:17:40 +08:00
commit f1825c8ceb
10096 changed files with 2364182 additions and 0 deletions
@@ -0,0 +1,24 @@
import io
from typing import Any, Dict
import pyarrow
from ray.data.datasource.file_datasink import RowBasedFileDatasink
class ImageDatasink(RowBasedFileDatasink):
def __init__(
self, path: str, column: str, file_format: str, **file_datasink_kwargs
):
super().__init__(path, file_format=file_format, **file_datasink_kwargs)
self.column = column
self.file_format = file_format
def write_row_to_file(self, row: Dict[str, Any], file: "pyarrow.NativeFile"):
from PIL import Image
image = Image.fromarray(row[self.column])
buffer = io.BytesIO()
image.save(buffer, format=self.file_format)
file.write(buffer.getvalue())