-
Notifications
You must be signed in to change notification settings - Fork 398
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
[ENHANCEMENT][REFACTOR] SDK: allow to remove settings #5584
Conversation
Just so I understand, there is still a singular way to remove settings? And this is just an example of iteration: for field in settings.fields:
if field.name.startswith("wiki"):
settings.fields.remove(field)
settings.metadata.add(rg.TermsMetadataProperty(field.name)) for example, fields can be deleted by their name:
|
I get that this requires a refactor, but I think that with two steps, it makes the feature highly niche and expert. Since we're working completely locally now, can we not add the |
# 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 implements a method to override settings properties in the settings resource: ```python settings = rg.Settings.from_hub("google/frames-benchmark") settings.add(rg.TextQuestion(name="answer", title="Answer")) dataset = rg.Dataset.from_hub("google/frames-benchmark", settings=settings, name=f"frames-benchmark-{uuid4()}") ``` **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/) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Yes, sorry. I didn't include it in the example. You can also remove the setting by name: settings.fields.remove("text") is a valid statement for this PR |
@frascuchon Should we put all the add and remove options in the description and the get feedback on the API? |
@frascuchon We haven't got feedback on this. I think we should move forward with the current implementation. Or ask again. |
I will add some related tests and documents. I vote to merge it. |
Done @burtenshaw. Here are the comments: |
a407b25
to
c2de471
Compare
@burtenshaw take a look at the latest changes, please |
@frascuchon This looks good to me. sorry for the delay. |
Description
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 newsettings.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
Or adding new metadata or vector settings when the dataset is created:
Updated
You can remove a property by name:
or by property instance
And you can override existing properties to change the property type, using the new
settings.add
method:Type of change
How Has This Been Tested
Checklist