Skip to content

Commit

Permalink
[ENHANCEMENT] docs: Add howto update record vectors (#5052)
Browse files Browse the repository at this point in the history
<!-- Thanks for your contribution! As part of our Community Growers
initiative 🌱, we're donating Justdiggit bunds in your name to reforest
sub-Saharan Africa. To claim your Community Growers certificate, please
contact David Berenstein in our Slack community or fill in this form
https://tally.so/r/n9XrxK once your PR has been merged. -->

# Description

This PR adds how to update record vectors in how-to guides. Since the
fields cannot be updated, the how-to guides skip them for now.


**How Has This Been Tested**

(Please describe the tests that you ran to verify your changes.)

- [ ] `sphinx-autobuild` (read [Developer
Documentation](https://docs.argilla.io/en/latest/community/developer_docs.html#building-the-documentation)
for more details)

**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
- [ ] My changes generate no new warnings
- [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK)
(see text above)
- [ ] I have added relevant notes to the `CHANGELOG.md` file (See
https://keepachangelog.com/)
  • Loading branch information
frascuchon authored Jun 19, 2024
1 parent fa52a6e commit 1ab171c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion argilla/docs/how_to_guides/record.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ updated_data = [
dataset.records.log(records=updated_data)
```

!!! note "Update the metadata"
=== "Update the metadata"
The `metadata` of `Record` object is a python dictionary. So to update the metadata of a record, you can iterate over the records and update the metadata by key or using `metadata.update`. After that, you should update the records in the dataset.

```python
Expand All @@ -452,6 +452,22 @@ dataset.records.log(records=updated_data)
dataset.records.log(records=updated_records)
```

=== "Update vectors"
When a new vector field is added to the dataset settings, or some value for the existing record vectors must updated, you can iterate over the records and update the vectors in the same way as the metadata.

```python
updated_records = []

for record in dataset.records():

record.vectors["new_vector"] = [...]
record.vector["v"] = [...]

updated_records.append(record)

dataset.records.log(records=updated_records)
```

## Delete records

You can delete records in a dataset calling the `delete` method on the `Dataset` object. To delete records, you need to retrieve them from the server and get a list with those that you want to delete.
Expand Down

0 comments on commit 1ab171c

Please sign in to comment.