Skip to content

Commit

Permalink
docs: add delete method
Browse files Browse the repository at this point in the history
  • Loading branch information
sdiazlor committed Jun 7, 2024
1 parent 6f29068 commit 9080653
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions argilla-sdk/docs/guides/how_to_guides/record.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,6 @@ If your dataset includes some annotations, you can add those to the records as y
dataset.records.log(data, user_id=user.id)
```



## List records

To list records in a dataset, you can use the `records` method on the `Dataset` object. This method returns a list of `Record` objects that can be iterated over to access the record properties.
Expand All @@ -422,7 +420,7 @@ for record in dataset.records(

## Update records

You can update records in a dataset calling the `update` method on the `Dataset` object. To update a record, you need to provide the record `id` and the new data to be updated.
You can update records in a dataset calling the `log` method on the `Dataset` object. To update a record, you need to provide the record `id` and the new data to be updated.

```python
data = dataset.records.to_list(flatten=True)
Expand All @@ -436,8 +434,8 @@ updated_data = [
for sample in data
]
dataset.records.log(records=updated_data)

```

!!! note "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.

Expand All @@ -452,4 +450,32 @@ dataset.records.log(records=updated_data)
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 a record, you need to retrieve them from the server and get a list with those that you want to delete.

```python
# Delete a single record
record_to_delete = [list(dataset.records)[0]]
dataset.records.delete(records=record_to_delete)

# Delete multiple records
records_to_delete = list(dataset.records)[:5]
dataset.records.delete(records=records_to_delete)
```

!!! tip "Delete records based on a query"
It can be very useful to avoid eliminating records with answers.

> For more information about the query syntax, check this [how-to guide](query_export.md).

```python
status_filter = rg.Query(
filter = rg.Filter(("status", "==", "pending"))
)
records_to_delete = list(dataset.records(status_filter))

dataset.records.delete(records_to_delete)
```

0 comments on commit 9080653

Please sign in to comment.