Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit 5dcbe16

Browse files
Merge pull request #16 from refuel-ai/order_by_docs
Update docs for sorting with SDK
2 parents e2507bc + 14d9c4a commit 5dcbe16

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

autolabel

Submodule autolabel updated 54 files

docs/python-sdk.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,36 @@ items = refuel_client.get_items(
182182

183183
#### Applying sort ordering when querying items
184184

185-
By default, the API will use Refuel’s sort order (by decreasing order of diversity). But you can specify any other column in the dataset that you would lille to sort by, when querying for items in the dataset:
185+
By default, the API will use Refuel’s sort order (by decreasing order of diversity). You can use the `order_by` param to sort by any other columns in the dataset or by the label or confidence score from a labeling task.
186+
187+
1) Sort by dataset column
188+
189+
```python
190+
items = refuel_client.get_items(
191+
dataset='<DATASET NAME>',
192+
max_items=100,
193+
order_by=[{'field': '<COLUMN NAME TO SORT BY>', 'direction': '<ASC or DESC>'}],
194+
)
195+
```
196+
197+
2) Sort by label or confidence score from a labeling task. Note that this requires a task name and a subtask name to be specified. `field` can be either 'label' or 'confidence'.
186198

187199
```python
188200
items = refuel_client.get_items(
189201
dataset='<DATASET NAME>',
202+
task='<LABELING TASK NAME>',
190203
max_items=100,
191-
order_by='<COLUMN NAME TO SORT BY>',
192-
order_direction='ASC'
204+
order_by=[{'field': 'confidence', 'direction': '<ASC or DESC>', 'subtask': '<SUBTASK NAME>'}],
193205
)
194206
```
195207

196-
Some details about sorting related function parameters:
208+
You may have multiple dicts in the `order_by` list if you would like to sort by multiple columns (used in the case of ties). Some details about the keys for each dict in the `order_by` list:
197209

198-
| Option | Is Required | Default Value | Comments |
199-
| :--------------- | :-----------| :-----------------------| :------- |
200-
| `order_by` | No | Refuel’s default sort (by diversity) | Name of the dataset you want to query and retrieve items (rows) from |
201-
| `order_direction` | No | 100 | Valid values: ASC or DESC |
210+
| Key | Is Required | Default Value | Description | Comments |
211+
| :--------------- | :-----------| :-----------------------|:-----------------------| :------- |
212+
| `field` | Yes | | The name of the column in the dataset to sort by | In addition to the columns in the dataset, the field can also be 'label' or 'confidence', if the task and subtask names are specified. |
213+
| `direction` | No | `ASC` | The direction that you would like to sort the specified column by | Should be `ASC` or `DESC` |
214+
| `subtask` | No | null | The name of the subtask for which you would like to sort by label or confidence | This should only be provided if the field is 'label' or 'confidence' and requires a task name to be specified in the function params. |
202215

203216
#### Applying filters when querying items
204217

0 commit comments

Comments
 (0)