Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] argilla: prevent enum literal validation errors #5679

Merged
merged 8 commits into from
Dec 11, 2024

Conversation

frascuchon
Copy link
Member

Description

In some environments, working with enun instances as string values may lead to some validation errors. See this discord discussion.

This PR reviews how metadata settings classes are defined, and defines type directly as a literal string, in the same way we do fo questions or fields, instead of using the MetadataPropertyType class.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (change restructuring the codebase without changing functionality)

How Has This Been Tested

Checklist

  • 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/)

@@ -122,13 +121,12 @@ def __init__(
super().__init__(client=client)

try:
settings = TermsMetadataPropertySettings(values=options, type=MetadataPropertyType.terms)
settings = TermsMetadataPropertySettings(values=options)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the type here anymore. Each setting instance defines its type.

except ValueError as e:
raise MetadataError(f"Error defining metadata settings for {name}") from e

self._model = MetadataFieldModel(
name=name,
type=MetadataPropertyType.float,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is redundant. Model should use the one defined under the settings attribute

@frascuchon frascuchon changed the title [BUGFIX] argilla: prevent enum literal validations [BUGFIX] argilla: prevent enum literal validation errors Nov 7, 2024
@frascuchon frascuchon added this to the v2.5.0 milestone Nov 14, 2024
@jfcalvo jfcalvo modified the milestones: v2.5.0, v2.6.0 Nov 20, 2024
@frascuchon frascuchon requested a review from jfcalvo December 11, 2024 09:11
@frascuchon frascuchon merged commit 1a34f54 into develop Dec 11, 2024
7 checks passed
@frascuchon frascuchon deleted the bugfixes/argilla/prevent-enum-literal-validations branch December 11, 2024 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants