Skip to content

Commit e28f60c

Browse files
authored
Merge pull request #13 from explodinggradients/fix/select-url
fix: select, URL and ordering via SDK
2 parents 4dfa992 + 3b0e6e8 commit e28f60c

File tree

11 files changed

+940
-910
lines changed

11 files changed

+940
-910
lines changed

nbs/backends/ragas_api_client.ipynb

Lines changed: 140 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -988,19 +988,7 @@
988988
{
989989
"cell_type": "markdown",
990990
"metadata": {},
991-
"source": [
992-
"The API supports the following column types:\n",
993-
"\n",
994-
"- `number`: Numeric values\n",
995-
"- `longText`: Text content\n",
996-
"- `select`: Single selection from predefined options\n",
997-
"- `date`: Date values\n",
998-
"- `multiSelect`: Multiple selections from predefined options\n",
999-
"- `checkbox`: Boolean values\n",
1000-
"- `custom`: Custom column types with specific behavior\n",
1001-
"\n",
1002-
"Each column type has specific settings that can be configured through the `settings` object."
1003-
]
991+
"source": []
1004992
},
1005993
{
1006994
"cell_type": "code",
@@ -1099,13 +1087,13 @@
10991087
{
11001088
"data": {
11011089
"text/plain": [
1102-
"{'id': 'ebc3dd3e-f88b-4f8b-8c72-6cfcae0a0cd4',\n",
1090+
"{'id': 'cc6794e1-3505-4d5c-b403-ca7e55142bbc',\n",
11031091
" 'name': 'New Dataset for testing columns',\n",
11041092
" 'description': 'This is a new dataset for testing columns',\n",
1105-
" 'updated_at': '2025-04-10T00:12:43.359691+00:00',\n",
1106-
" 'created_at': '2025-04-10T00:12:43.359691+00:00',\n",
1093+
" 'updated_at': '2025-04-16T18:05:53.249101+00:00',\n",
1094+
" 'created_at': '2025-04-16T18:05:53.249101+00:00',\n",
11071095
" 'version_counter': 0,\n",
1108-
" 'project_id': '26b0e577-8ff8-4014-bc7a-cfc410df3488'}"
1096+
" 'project_id': '3d9b529b-c23f-4e87-8a26-dd1923749aa7'}"
11091097
]
11101098
},
11111099
"execution_count": null,
@@ -1130,17 +1118,21 @@
11301118
{
11311119
"data": {
11321120
"text/plain": [
1133-
"{'id': 'new_column_3',\n",
1134-
" 'name': 'New Column 3',\n",
1135-
" 'type': 'text',\n",
1136-
" 'settings': {'id': 'new_column_3',\n",
1137-
" 'name': 'New Column 3',\n",
1138-
" 'type': 'text',\n",
1139-
" 'max_length': 255,\n",
1140-
" 'is_required': True},\n",
1141-
" 'created_at': '2025-04-10T02:22:07.300895+00:00',\n",
1142-
" 'updated_at': '2025-04-10T02:22:07.300895+00:00',\n",
1143-
" 'datatable_id': 'ebc3dd3e-f88b-4f8b-8c72-6cfcae0a0cd4'}"
1121+
"{'id': 'new_column_5',\n",
1122+
" 'name': 'New Column 5',\n",
1123+
" 'type': 'select',\n",
1124+
" 'settings': {'id': 'new_column_5',\n",
1125+
" 'name': 'New Column 5',\n",
1126+
" 'type': 'select',\n",
1127+
" 'width': 255,\n",
1128+
" 'options': [{'name': 'name', 'value': 'name'},\n",
1129+
" {'name': 'age', 'value': 'age'},\n",
1130+
" {'name': 'gender', 'value': 'gender'}],\n",
1131+
" 'isVisible': True,\n",
1132+
" 'isEditable': True},\n",
1133+
" 'created_at': '2025-04-16T18:11:14.305975+00:00',\n",
1134+
" 'updated_at': '2025-04-16T18:11:14.305975+00:00',\n",
1135+
" 'datatable_id': 'cc6794e1-3505-4d5c-b403-ca7e55142bbc'}"
11441136
]
11451137
},
11461138
"execution_count": null,
@@ -1153,12 +1145,18 @@
11531145
"new_column = await client.create_dataset_column(\n",
11541146
" project_id=projects[\"items\"][0][\"id\"],\n",
11551147
" dataset_id=datasets[\"id\"],\n",
1156-
" id=\"new_column_3\",\n",
1148+
" id=\"new_column_5\",\n",
11571149
" name=\"New Column 3\",\n",
1158-
" type=ColumnType.TEXT.value,\n",
1150+
" type=ColumnType.SELECT.value,\n",
11591151
" settings={\n",
1160-
" \"max_length\": 255,\n",
1161-
" \"is_required\": True,\n",
1152+
" \"width\": 255,\n",
1153+
" \"isVisible\": True,\n",
1154+
" \"isEditable\": True,\n",
1155+
" \"options\": [\n",
1156+
" {\"name\": \"name\", \"color\": \"hsl(200, 100%, 50%)\", \"value\": \"name\"},\n",
1157+
" {\"name\": \"age\", \"color\": \"hsl(200, 100%, 50%)\", \"value\": \"age\"},\n",
1158+
" {\"name\": \"gender\", \"color\": \"hsl(200, 100%, 50%)\", \"value\": \"gender\"},\n",
1159+
" ]\n",
11621160
" },\n",
11631161
")\n",
11641162
"new_column"
@@ -1172,20 +1170,90 @@
11721170
{
11731171
"data": {
11741172
"text/plain": [
1175-
"{'items': [{'id': 'new_column_3',\n",
1176-
" 'name': 'New Column 3',\n",
1177-
" 'type': 'text',\n",
1178-
" 'settings': {'id': 'new_column_3',\n",
1179-
" 'name': 'New Column 3',\n",
1180-
" 'type': 'text',\n",
1181-
" 'max_length': 255,\n",
1182-
" 'is_required': True},\n",
1183-
" 'created_at': '2025-04-10T02:22:07.300895+00:00',\n",
1184-
" 'updated_at': '2025-04-10T02:22:07.300895+00:00',\n",
1185-
" 'datatable_id': 'ebc3dd3e-f88b-4f8b-8c72-6cfcae0a0cd4'}],\n",
1173+
"{'items': [{'id': 'dQ7hCb1AUfog',\n",
1174+
" 'name': 'tags_color_coded',\n",
1175+
" 'type': 'select',\n",
1176+
" 'settings': {'id': 'dQ7hCb1AUfog',\n",
1177+
" 'name': 'tags_color_coded',\n",
1178+
" 'type': 'select',\n",
1179+
" 'width': 255,\n",
1180+
" 'options': [{'name': 'red', 'color': 'hsl(0, 85%, 60%)', 'value': 'red'},\n",
1181+
" {'name': 'green', 'color': 'hsl(30, 85%, 60%)', 'value': 'green'},\n",
1182+
" {'name': 'blue', 'color': 'hsl(45, 85%, 60%)', 'value': 'blue'}],\n",
1183+
" 'isVisible': True,\n",
1184+
" 'isEditable': True},\n",
1185+
" 'created_at': '2025-04-16T19:00:39.936764+00:00',\n",
1186+
" 'updated_at': '2025-04-16T19:00:39.936764+00:00',\n",
1187+
" 'datatable_id': '271b8bc7-2d04-43b8-8960-ce20365f546b'},\n",
1188+
" {'id': 'eCAiMBRqm0Uc',\n",
1189+
" 'name': 'id',\n",
1190+
" 'type': 'number',\n",
1191+
" 'settings': {'id': 'eCAiMBRqm0Uc',\n",
1192+
" 'name': 'id',\n",
1193+
" 'type': 'number',\n",
1194+
" 'width': 255,\n",
1195+
" 'isVisible': True,\n",
1196+
" 'isEditable': True},\n",
1197+
" 'created_at': '2025-04-16T19:00:39.971857+00:00',\n",
1198+
" 'updated_at': '2025-04-16T19:00:39.971857+00:00',\n",
1199+
" 'datatable_id': '271b8bc7-2d04-43b8-8960-ce20365f546b'},\n",
1200+
" {'id': 'fRegl7Ucx3Sp',\n",
1201+
" 'name': 'description',\n",
1202+
" 'type': 'longText',\n",
1203+
" 'settings': {'id': 'fRegl7Ucx3Sp',\n",
1204+
" 'name': 'description',\n",
1205+
" 'type': 'longText',\n",
1206+
" 'width': 255,\n",
1207+
" 'isVisible': True,\n",
1208+
" 'isEditable': True,\n",
1209+
" 'max_length': 1000},\n",
1210+
" 'created_at': '2025-04-16T19:00:40.055047+00:00',\n",
1211+
" 'updated_at': '2025-04-16T19:00:40.055047+00:00',\n",
1212+
" 'datatable_id': '271b8bc7-2d04-43b8-8960-ce20365f546b'},\n",
1213+
" {'id': 'foebrzYhiu9x',\n",
1214+
" 'name': 'tags',\n",
1215+
" 'type': 'select',\n",
1216+
" 'settings': {'id': 'foebrzYhiu9x',\n",
1217+
" 'name': 'tags',\n",
1218+
" 'type': 'select',\n",
1219+
" 'width': 255,\n",
1220+
" 'options': [{'name': 'tag1', 'color': 'hsl(0, 85%, 60%)', 'value': 'tag1'},\n",
1221+
" {'name': 'tag2', 'color': 'hsl(30, 85%, 60%)', 'value': 'tag2'},\n",
1222+
" {'name': 'tag3', 'color': 'hsl(45, 85%, 60%)', 'value': 'tag3'}],\n",
1223+
" 'isVisible': True,\n",
1224+
" 'isEditable': True},\n",
1225+
" 'created_at': '2025-04-16T19:00:40.084457+00:00',\n",
1226+
" 'updated_at': '2025-04-16T19:00:40.084457+00:00',\n",
1227+
" 'datatable_id': '271b8bc7-2d04-43b8-8960-ce20365f546b'},\n",
1228+
" {'id': 'ciAzRUhKct9c',\n",
1229+
" 'name': 'name',\n",
1230+
" 'type': 'longText',\n",
1231+
" 'settings': {'id': 'ciAzRUhKct9c',\n",
1232+
" 'name': 'name',\n",
1233+
" 'type': 'longText',\n",
1234+
" 'width': 255,\n",
1235+
" 'isVisible': True,\n",
1236+
" 'isEditable': True,\n",
1237+
" 'max_length': 1000},\n",
1238+
" 'created_at': '2025-04-16T19:00:40.232989+00:00',\n",
1239+
" 'updated_at': '2025-04-16T19:00:40.232989+00:00',\n",
1240+
" 'datatable_id': '271b8bc7-2d04-43b8-8960-ce20365f546b'},\n",
1241+
" {'id': 'iAW5muBh9mc251p8-LqKz',\n",
1242+
" 'name': 'url',\n",
1243+
" 'type': 'url',\n",
1244+
" 'settings': {'id': 'iAW5muBh9mc251p8-LqKz',\n",
1245+
" 'name': 'url',\n",
1246+
" 'type': 'url',\n",
1247+
" 'width': 192,\n",
1248+
" 'position': 5,\n",
1249+
" 'isVisible': True,\n",
1250+
" 'isEditable': True},\n",
1251+
" 'created_at': '2025-04-16T20:13:09.418698+00:00',\n",
1252+
" 'updated_at': '2025-04-16T20:13:16.914367+00:00',\n",
1253+
" 'datatable_id': '271b8bc7-2d04-43b8-8960-ce20365f546b'}],\n",
11861254
" 'pagination': {'offset': 0,\n",
11871255
" 'limit': 50,\n",
1188-
" 'total': 1,\n",
1256+
" 'total': 6,\n",
11891257
" 'order_by': 'created_at',\n",
11901258
" 'sort_dir': 'asc'}}"
11911259
]
@@ -1196,7 +1264,7 @@
11961264
}
11971265
],
11981266
"source": [
1199-
"await client.list_dataset_columns(projects[\"items\"][0][\"id\"], datasets[\"id\"])"
1267+
"await client.list_dataset_columns(projects[\"items\"][0][\"id\"], \"271b8bc7-2d04-43b8-8960-ce20365f546b\")"
12001268
]
12011269
},
12021270
{
@@ -1362,11 +1430,31 @@
13621430
{
13631431
"data": {
13641432
"text/plain": [
1365-
"{'id': 'new_row_1',\n",
1366-
" 'data': {'id': 'new_row_1', 'new_column_1': 'value', 'new_column_2': 'value'},\n",
1367-
" 'created_at': '2025-04-10T02:22:34.470887+00:00',\n",
1368-
" 'updated_at': '2025-04-10T02:22:34.470887+00:00',\n",
1369-
" 'datatable_id': 'ebc3dd3e-f88b-4f8b-8c72-6cfcae0a0cd4'}"
1433+
"'3374b891-8398-41bd-8f81-2867759df294'"
1434+
]
1435+
},
1436+
"execution_count": null,
1437+
"metadata": {},
1438+
"output_type": "execute_result"
1439+
}
1440+
],
1441+
"source": [
1442+
"datasets[\"id\"]"
1443+
]
1444+
},
1445+
{
1446+
"cell_type": "code",
1447+
"execution_count": null,
1448+
"metadata": {},
1449+
"outputs": [
1450+
{
1451+
"data": {
1452+
"text/plain": [
1453+
"{'id': '',\n",
1454+
" 'data': {'id': '', 'new_column_3': 'name'},\n",
1455+
" 'created_at': '2025-04-16T17:46:39.100525+00:00',\n",
1456+
" 'updated_at': '2025-04-16T17:46:39.100525+00:00',\n",
1457+
" 'datatable_id': '3374b891-8398-41bd-8f81-2867759df294'}"
13701458
]
13711459
},
13721460
"execution_count": null,
@@ -1378,8 +1466,8 @@
13781466
"await client.create_dataset_row(\n",
13791467
" project_id=projects[\"items\"][0][\"id\"],\n",
13801468
" dataset_id=datasets[\"id\"],\n",
1381-
" id=\"new_row_1\",\n",
1382-
" data={\"new_column_1\": \"value\", \"new_column_2\": \"value\"},\n",
1469+
" id=\"\",\n",
1470+
" data={\"new_column_3\": \"name\"},\n",
13831471
")\n"
13841472
]
13851473
},

nbs/dataset.ipynb

Lines changed: 16 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
" id: int\n",
165165
" name: str\n",
166166
" description: str\n",
167+
" tags: t.Literal[\"tag1\", \"tag2\", \"tag3\"]\n",
167168
" result: MetricResult"
168169
]
169170
},
@@ -184,7 +185,7 @@
184185
{
185186
"data": {
186187
"text/plain": [
187-
"TestModel(id=0, name='test', description='test description', result=0.5)"
188+
"TestModel(id=0, name='test', description='test description', tags='tag1', result=0.5)"
188189
]
189190
},
190191
"execution_count": null,
@@ -193,7 +194,13 @@
193194
}
194195
],
195196
"source": [
196-
"test_model = TestModel(id=0, name=\"test\", description=\"test description\", result=MetricResult(result=0.5, reason=\"test reason\"))\n",
197+
"test_model = TestModel(\n",
198+
" id=0, \n",
199+
" name=\"test\", \n",
200+
" description=\"test description\", \n",
201+
" result=MetricResult(result=0.5, reason=\"test reason\"), \n",
202+
" tags=\"tag1\"\n",
203+
")\n",
197204
"test_model"
198205
]
199206
},
@@ -208,6 +215,7 @@
208215
"{'id': 'id',\n",
209216
" 'name': 'name',\n",
210217
" 'description': 'description',\n",
218+
" 'tags': 'tags',\n",
211219
" 'result': 'result',\n",
212220
" 'result_reason': 'result_reason'}"
213221
]
@@ -270,7 +278,7 @@
270278
}
271279
],
272280
"source": [
273-
"p = Project(project_id=\"1ef0843b-231f-4a2c-b64d-d39bcee9d830\", ragas_app_client=ragas_api_client)\n",
281+
"p = Project(project_id=\"3d9b529b-c23f-4e87-8a26-dd1923749aa7\", ragas_app_client=ragas_api_client)\n",
274282
"test_dataset = p.create_dataset(name=\"TestModel_with_long_text\", model=TestModel)\n",
275283
"test_dataset"
276284
]
@@ -283,13 +291,13 @@
283291
{
284292
"data": {
285293
"text/plain": [
286-
"{'id': 'a7bd8b1f-dc29-4ae0-b1e5-24f0dfb76f7a',\n",
294+
"{'id': 'aa1fb420-4820-45a6-9502-6cfb7938b7a3',\n",
287295
" 'name': 'TestModel_with_long_text',\n",
288296
" 'description': None,\n",
289-
" 'created_at': '2025-04-16T00:02:58.149112+00:00',\n",
290-
" 'updated_at': '2025-04-16T00:02:58.149112+00:00',\n",
297+
" 'created_at': '2025-04-16T18:54:04.355883+00:00',\n",
298+
" 'updated_at': '2025-04-16T18:54:04.355883+00:00',\n",
291299
" 'version_counter': 0,\n",
292-
" 'project_id': '1ef0843b-231f-4a2c-b64d-d39bcee9d830'}"
300+
" 'project_id': '3d9b529b-c23f-4e87-8a26-dd1923749aa7'}"
293301
]
294302
},
295303
"execution_count": null,
@@ -306,31 +314,6 @@
306314
"test_dataset"
307315
]
308316
},
309-
{
310-
"cell_type": "code",
311-
"execution_count": null,
312-
"metadata": {},
313-
"outputs": [
314-
{
315-
"data": {
316-
"text/plain": [
317-
"{'items': [],\n",
318-
" 'pagination': {'offset': 0,\n",
319-
" 'limit': 50,\n",
320-
" 'total': 0,\n",
321-
" 'order_by': 'created_at',\n",
322-
" 'sort_dir': 'asc'}}"
323-
]
324-
},
325-
"execution_count": null,
326-
"metadata": {},
327-
"output_type": "execute_result"
328-
}
329-
],
330-
"source": [
331-
"await ragas_api_client.list_dataset_rows(project_id=TEST_PROJECT_ID, dataset_id=TEST_DATASET_ID)"
332-
]
333-
},
334317
{
335318
"cell_type": "code",
336319
"execution_count": null,
@@ -342,30 +325,6 @@
342325
")"
343326
]
344327
},
345-
{
346-
"cell_type": "code",
347-
"execution_count": null,
348-
"metadata": {},
349-
"outputs": [
350-
{
351-
"data": {
352-
"text/plain": [
353-
"{'id': 'eCYjJtBbLSDL',\n",
354-
" 'name': '1sfEb8iJ1TUg',\n",
355-
" 'description': 'gYsqmPXHbOyy',\n",
356-
" 'result': 'cAZanmY0CwWT',\n",
357-
" 'result_reason': 'e7IgZXICkmhA'}"
358-
]
359-
},
360-
"execution_count": null,
361-
"metadata": {},
362-
"output_type": "execute_result"
363-
}
364-
],
365-
"source": [
366-
"dataset.model.__column_mapping__"
367-
]
368-
},
369328
{
370329
"cell_type": "code",
371330
"execution_count": null,
@@ -506,7 +465,7 @@
506465
{
507466
"data": {
508467
"text/plain": [
509-
"12"
468+
"10"
510469
]
511470
},
512471
"execution_count": null,

0 commit comments

Comments
 (0)