-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENHANCEMENT][REFACTOR] SDK: allow to remove settings (#5584)
# 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 allows users to change all the settings before creating the dataset, and metadata and vector, when the dataset is created. I included the `remove` method instead of a new `settings.add(override=True)` since this change requires a lot of internal refactor with the current design. An example of how to use could be to change inferred settings from hub before create the final dataset ```python settings = rg.Settings.from_hub("google/frames-benchmark") settings.fields.remove("answer") for field in settings.fields: if field.name.startswith("wiki"): settings.fields.remove(field) settings.metadata.add(rg.TermsMetadataProperty(field.name)) settings.questions.add(rg.TextQuestion(name="answer", title="Answer")) dataset = rg.Dataset.from_hub("google/frames-benchmark", settings=settings) ``` Or adding new metadata or vector settings when the dataset is created: ```python dataset = client.dataset("my-dataset") dataset.metadata.add([rg.TermsMetadata(name="split")]) dataset.update() # this line sends the change to the argilla server ``` ## Updated You can remove a property by name: ```python settings.fields.remove("text") ``` or by property instance ```python for field in settings.fields: if field.name.startwith("wiki"): settings.fields.remove(field) ```` And you can override existing properties to change the property type, using the new `settings.add` method: ```python settings = Settings.from_hub(...) # change some settings definitions before create the dataset settings.add(rg.TermsMetadata("wikipedia_1")) # this will remove the existing wikipedia_1 property and will create a new terms metadata one ``` **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Refactor (change restructuring the codebase without changing functionality) - 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. --> **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: burtenshaw <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
02df3d1
commit af2033c
Showing
6 changed files
with
195 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters