Skip to content

Commit

Permalink
feat: add method in settings resource
Browse files Browse the repository at this point in the history
  • Loading branch information
burtenshaw committed Oct 8, 2024
1 parent abc36d0 commit f47fd6d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions argilla/src/argilla/settings/_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,27 @@ def from_hub(
def __eq__(self, other: "Settings") -> bool:
return self.serialize() == other.serialize() # TODO: Create proper __eq__ methods for fields and questions

def add(
self, property: Union[Field, VectorField, MetadataType, QuestionType]
) -> Union[Field, VectorField, MetadataType, QuestionType]:
# review all settings properties and remove any existing property with the same name
for attributes in [self.fields, self.questions, self.vectors, self.metadata]:
for prop in attributes:
if prop.name == property.name:
attributes.remove(prop)

if isinstance(property, Field):
self.fields.add(property)
elif isinstance(property, QuestionType):
self.questions.add(property)
elif isinstance(property, VectorField):
self.vectors.add(property)
elif isinstance(property, MetadataType):
self.metadata.add(property)
else:
raise ValueError(f"Unsupported property type: {type(property).__name__}")
return property

#####################
# Repr Methods #
#####################
Expand Down

0 comments on commit f47fd6d

Please sign in to comment.