Skip to content

Commit 70b9d30

Browse files
authored
feat: Add basic support to bool features (#5576)
# 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. --> Also, relax type casting for metadata values, accepting Any. **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/)
1 parent e4b2d79 commit 70b9d30

File tree

12 files changed

+452
-339
lines changed

12 files changed

+452
-339
lines changed

argilla-server/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ These are the section headers that we use:
1616

1717
## [Unreleased]()
1818

19+
### Changed
20+
21+
- Changed supported values for terms metadata options to accept other than strings values. ([#5589](https://github.com/argilla-io/argilla/pull/5589))
22+
1923
### Removed
2024

2125
- Removed name pattern validation for Workspaces, Datasets, and Users. ([#5575](https://github.com/argilla-io/argilla/pull/5575))

argilla-server/src/argilla_server/api/schemas/v1/metadata_properties.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
class TermsMetadataMetrics(BaseModel):
4343
class TermCount(BaseModel):
44-
term: str
44+
term: Any
4545
count: int
4646

4747
type: Literal[MetadataPropertyType.terms] = Field(MetadataPropertyType.terms, const=True)
@@ -72,13 +72,18 @@ def round_result(cls, v: float):
7272

7373

7474
MetadataMetrics = Annotated[
75-
Union[TermsMetadataMetrics, IntegerMetadataMetrics, FloatMetadataMetrics], Field(..., discriminator="type")
75+
Union[
76+
TermsMetadataMetrics,
77+
IntegerMetadataMetrics,
78+
FloatMetadataMetrics,
79+
],
80+
Field(..., discriminator="type"),
7681
]
7782

7883

7984
class TermsMetadataProperty(BaseModel):
8085
type: Literal[MetadataPropertyType.terms]
81-
values: Optional[List[str]] = None
86+
values: Optional[List[Any]] = None
8287

8388

8489
class IntegerMetadataProperty(BaseModel):
@@ -98,7 +103,6 @@ class FloatMetadataProperty(BaseModel):
98103
Field(..., discriminator="type"),
99104
]
100105

101-
102106
MetadataPropertyName = Annotated[
103107
str,
104108
Field(
@@ -109,7 +113,6 @@ class FloatMetadataProperty(BaseModel):
109113
),
110114
]
111115

112-
113116
MetadataPropertyTitle = Annotated[
114117
constr(min_length=METADATA_PROPERTY_CREATE_TITLE_MIN_LENGTH, max_length=METADATA_PROPERTY_CREATE_TITLE_MAX_LENGTH),
115118
Field(..., description="The title of the metadata property"),
@@ -133,7 +136,7 @@ def check_bounds(cls, values: Dict[str, Any]) -> Dict[str, Any]:
133136

134137
class TermsMetadataPropertyCreate(BaseModel):
135138
type: Literal[MetadataPropertyType.terms]
136-
values: Optional[List[str]] = Field(
139+
values: Optional[List[Any]] = Field(
137140
None, min_items=TERMS_METADATA_PROPERTY_VALUES_MIN_ITEMS, max_items=TERMS_METADATA_PROPERTY_VALUES_MAX_ITEMS
138141
)
139142

argilla-server/src/argilla_server/models/metadata_properties.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ def check_metadata(self, value: Any) -> None:
4141

4242
class TermsMetadataPropertySettings(BaseMetadataPropertySettings):
4343
type: Literal[MetadataPropertyType.terms]
44-
values: Optional[List[str]] = None
44+
values: Optional[List[Any]] = None
4545

46-
def check_metadata(self, value: Union[str, List[str]]) -> None:
46+
def check_metadata(self, value: Any) -> None:
4747
if self.values is None:
4848
return
4949

5050
values = value
51-
if isinstance(values, str):
51+
if not isinstance(values, list):
5252
values = [value]
5353

5454
for v in values:

0 commit comments

Comments
 (0)