Skip to content

Commit ebaff3e

Browse files
__repr__ implemented for SettingProperties. (#5497)
`__repr__ ` implementation for SettingsProperties. This will allow…… use to print human readable representation of Settings # 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. --> - Implemented `__repr__` method to SettingProperties class. - Added more attributes to settings object in `test_settings_repr` function under test_settings.py Closes #5380 **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Improvement (change adding some improvement to an existing functionality) **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> Executed the unit test using `pytest tests/unit` **Checklist** <!-- Please go over the list and make sure you've taken everything into account --> - I followed the style guidelines of this project - I did a self-review of my code - I have added tests that prove my fix is effective or that my feature works --------- Co-authored-by: David Berenstein <[email protected]>
1 parent d57a83b commit ebaff3e

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

argilla/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ These are the section headers that we use:
2020

2121
- Added `limit` argument when fetching records. ([#5525](https://github.com/argilla-io/argilla/pull/5525)
2222

23+
### Changed
24+
25+
- Changed the __repr__ method for `SettingsProperties` to display the details of all the properties in `Setting` object. ([#5380](https://github.com/argilla-io/argilla/issues/5380))
2326
### Fixed
2427

2528
- Fixed the deployment yaml used to create a new Argilla server in K8s. Added `USERNAME` and `PASSWORD` to the environment variables of pod template. ([#5434](https://github.com/argilla-io/argilla/issues/5434))
@@ -52,6 +55,7 @@ These are the section headers that we use:
5255
- Added multiple error handling methods to the `rg.Dataset.records.log` method to warn, ignore, or raise errors. ([#5466](https://github.com/argilla-io/argilla/pull/5463))
5356
- Changed dataset import and export of `rg.LabelQuestion` to use `datasets.ClassLabel` not `datasets.Value`. ([#5474](https://github.com/argilla-io/argilla/pull/5474))
5457

58+
5559
## [2.1.0](https://github.com/argilla-io/argilla/compare/v2.0.1...v2.1.0)
5660

5761
### Added

argilla/src/argilla/settings/_resource.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,11 @@ def _validate_new_property(self, property: Property) -> None:
514514
if property.name in dir(self):
515515
raise ValueError(f"Property with name {property.name!r} conflicts with an existing attribute")
516516

517+
def __repr__(self) -> str:
518+
"""Return a string representation of the object."""
519+
520+
return f"{repr([prop for prop in self])}"
521+
517522

518523
class QuestionsProperties(SettingsProperties[QuestionType]):
519524
"""

argilla/tests/unit/test_settings/test_settings.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,25 @@ def test_settings_repr(self):
7373
settings = rg.Settings(
7474
fields=[
7575
rg.TextField(name="text", title="text"),
76+
rg.ImageField(name="image", title="image"),
7677
],
7778
metadata=[
7879
rg.FloatMetadataProperty("source"),
7980
],
8081
questions=[
8182
rg.LabelQuestion(name="label", title="text", labels=["positive", "negative"]),
83+
rg.RatingQuestion(name="rating", title="text", values=[1, 2, 3, 4, 5]),
84+
rg.TextQuestion(name="text", title="text"),
85+
rg.SpanQuestion(
86+
name="span",
87+
title="text",
88+
field="text",
89+
labels=["Apparatus", "Method", "Machine", "Manufacture", "Design"],
90+
visible_labels=3,
91+
),
8292
],
8393
vectors=[rg.VectorField(name="text", dimensions=3)],
8494
)
85-
8695
assert (
8796
settings.__repr__() == f"Settings(guidelines=None, allow_extra_metadata=False, "
8897
"distribution=OverlapTaskDistribution(min_submitted=1), "

0 commit comments

Comments
 (0)