Skip to content

Commit 1fe3e0a

Browse files
burtenshawpre-commit-ci[bot]frascuchon
authored
[BUGFIX] Catch None in image feature columns (#5626)
# Description <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. --> This PR fixes this snippet: ```python import argilla as rg from datasets import load_dataset client = rg.Argilla( api_url="https://frascuchon-argilla.hf.space", api_key="argilla.apikey" ) ds = load_dataset("derek-thomas/ScienceQA", name="default", split="train") dataset = client.datasets(name="science_qa", workspace="argilla") dataset.records.log( ds, mapping={"task": "text_0.suggestion", "subject": "text_1.suggestion"} ) ``` Closes #<issue_number> **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Refactor (change restructuring the codebase without changing functionality) - Improvement (change adding some improvement to an existing functionality) - Documentation update **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> **Checklist** <!-- Please go over the list and make sure you've taken everything into account --> - I added relevant documentation - I followed the style guidelines of this project - I did a self-review of my code - I made corresponding changes to the documentation - I confirm My changes generate no new warnings - I have added tests that prove my fix is effective or that my feature works - I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Francisco Aranda <[email protected]>
1 parent b02eba8 commit 1fe3e0a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

argilla/src/argilla/_helpers/_media.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616
import io
1717
import warnings
1818
from pathlib import Path
19-
from typing import Union
19+
from typing import Union, Optional
2020

2121
from PIL import Image
2222

2323

24-
def pil_to_data_uri(image_object: "Image") -> str:
24+
def pil_to_data_uri(image_object: Optional["Image"]) -> Optional[str]:
2525
"""Convert a PIL image to a base64 data URI string.
2626
Parameters:
2727
image_object (Image): The PIL image to convert to a base64 data URI.
2828
Returns:
2929
str: The data URI string.
3030
"""
31+
if image_object is None:
32+
return None
3133
if not isinstance(image_object, Image.Image):
3234
raise ValueError("The image_object must be a PIL Image object.")
3335

0 commit comments

Comments
 (0)