Skip to content

Commit c2cb44a

Browse files
committed
got select working
1 parent 721314a commit c2cb44a

File tree

9 files changed

+392
-207
lines changed

9 files changed

+392
-207
lines changed

nbs/backends/ragas_api_client.ipynb

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,13 +1099,13 @@
10991099
{
11001100
"data": {
11011101
"text/plain": [
1102-
"{'id': 'ebc3dd3e-f88b-4f8b-8c72-6cfcae0a0cd4',\n",
1102+
"{'id': 'cc6794e1-3505-4d5c-b403-ca7e55142bbc',\n",
11031103
" 'name': 'New Dataset for testing columns',\n",
11041104
" '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",
1105+
" 'updated_at': '2025-04-16T18:05:53.249101+00:00',\n",
1106+
" 'created_at': '2025-04-16T18:05:53.249101+00:00',\n",
11071107
" 'version_counter': 0,\n",
1108-
" 'project_id': '26b0e577-8ff8-4014-bc7a-cfc410df3488'}"
1108+
" 'project_id': '3d9b529b-c23f-4e87-8a26-dd1923749aa7'}"
11091109
]
11101110
},
11111111
"execution_count": null,
@@ -1130,17 +1130,21 @@
11301130
{
11311131
"data": {
11321132
"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'}"
1133+
"{'id': 'new_column_5',\n",
1134+
" 'name': 'New Column 5',\n",
1135+
" 'type': 'select',\n",
1136+
" 'settings': {'id': 'new_column_5',\n",
1137+
" 'name': 'New Column 5',\n",
1138+
" 'type': 'select',\n",
1139+
" 'width': 255,\n",
1140+
" 'options': [{'name': 'name', 'value': 'name'},\n",
1141+
" {'name': 'age', 'value': 'age'},\n",
1142+
" {'name': 'gender', 'value': 'gender'}],\n",
1143+
" 'isVisible': True,\n",
1144+
" 'isEditable': True},\n",
1145+
" 'created_at': '2025-04-16T18:11:14.305975+00:00',\n",
1146+
" 'updated_at': '2025-04-16T18:11:14.305975+00:00',\n",
1147+
" 'datatable_id': 'cc6794e1-3505-4d5c-b403-ca7e55142bbc'}"
11441148
]
11451149
},
11461150
"execution_count": null,
@@ -1153,12 +1157,18 @@
11531157
"new_column = await client.create_dataset_column(\n",
11541158
" project_id=projects[\"items\"][0][\"id\"],\n",
11551159
" dataset_id=datasets[\"id\"],\n",
1156-
" id=\"new_column_3\",\n",
1160+
" id=\"new_column_5\",\n",
11571161
" name=\"New Column 3\",\n",
1158-
" type=ColumnType.TEXT.value,\n",
1162+
" type=ColumnType.SELECT.value,\n",
11591163
" settings={\n",
1160-
" \"max_length\": 255,\n",
1161-
" \"is_required\": True,\n",
1164+
" \"width\": 255,\n",
1165+
" \"isVisible\": True,\n",
1166+
" \"isEditable\": True,\n",
1167+
" \"options\": [\n",
1168+
" {\"name\": \"name\", \"color\": \"hsl(200, 100%, 50%)\", \"value\": \"name\"},\n",
1169+
" {\"name\": \"age\", \"color\": \"hsl(200, 100%, 50%)\", \"value\": \"age\"},\n",
1170+
" {\"name\": \"gender\", \"color\": \"hsl(200, 100%, 50%)\", \"value\": \"gender\"},\n",
1171+
" ]\n",
11621172
" },\n",
11631173
")\n",
11641174
"new_column"
@@ -1362,11 +1372,31 @@
13621372
{
13631373
"data": {
13641374
"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'}"
1375+
"'3374b891-8398-41bd-8f81-2867759df294'"
1376+
]
1377+
},
1378+
"execution_count": null,
1379+
"metadata": {},
1380+
"output_type": "execute_result"
1381+
}
1382+
],
1383+
"source": [
1384+
"datasets[\"id\"]"
1385+
]
1386+
},
1387+
{
1388+
"cell_type": "code",
1389+
"execution_count": null,
1390+
"metadata": {},
1391+
"outputs": [
1392+
{
1393+
"data": {
1394+
"text/plain": [
1395+
"{'id': '',\n",
1396+
" 'data': {'id': '', 'new_column_3': 'name'},\n",
1397+
" 'created_at': '2025-04-16T17:46:39.100525+00:00',\n",
1398+
" 'updated_at': '2025-04-16T17:46:39.100525+00:00',\n",
1399+
" 'datatable_id': '3374b891-8398-41bd-8f81-2867759df294'}"
13701400
]
13711401
},
13721402
"execution_count": null,
@@ -1378,8 +1408,8 @@
13781408
"await client.create_dataset_row(\n",
13791409
" project_id=projects[\"items\"][0][\"id\"],\n",
13801410
" dataset_id=datasets[\"id\"],\n",
1381-
" id=\"new_row_1\",\n",
1382-
" data={\"new_column_1\": \"value\", \"new_column_2\": \"value\"},\n",
1411+
" id=\"\",\n",
1412+
" data={\"new_column_3\": \"name\"},\n",
13831413
")\n"
13841414
]
13851415
},

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,

nbs/project/core.ipynb

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,27 @@
144144
"project"
145145
]
146146
},
147+
{
148+
"cell_type": "code",
149+
"execution_count": null,
150+
"metadata": {},
151+
"outputs": [
152+
{
153+
"data": {
154+
"text/plain": [
155+
"Project(name='Demo Project')"
156+
]
157+
},
158+
"execution_count": null,
159+
"metadata": {},
160+
"output_type": "execute_result"
161+
}
162+
],
163+
"source": [
164+
"project = Project(project_id=\"3d9b529b-c23f-4e87-8a26-dd1923749aa7\")\n",
165+
"project"
166+
]
167+
},
147168
{
148169
"cell_type": "code",
149170
"execution_count": null,
@@ -224,10 +245,7 @@
224245
" id=create_nano_id(),\n",
225246
" name=column[\"name\"],\n",
226247
" type=column[\"type\"],\n",
227-
" settings={\n",
228-
" \"max_length\": 255,\n",
229-
" \"is_required\": True,\n",
230-
" },\n",
248+
" settings=column[\"settings\"],\n",
231249
" ))\n",
232250
" return await asyncio.gather(*tasks)\n"
233251
]
@@ -283,48 +301,24 @@
283301
"cell_type": "code",
284302
"execution_count": null,
285303
"metadata": {},
286-
"outputs": [
287-
{
288-
"data": {
289-
"text/plain": [
290-
"Dataset(name=TestModel, model=TestModel, len=0)"
291-
]
292-
},
293-
"execution_count": null,
294-
"metadata": {},
295-
"output_type": "execute_result"
296-
}
297-
],
304+
"outputs": [],
298305
"source": [
299-
"# create an example dataset\n",
300-
"class TestModel(BaseModel):\n",
301-
" id: int\n",
302-
" name: str\n",
303-
" description: str\n",
304-
"\n",
305-
"\n",
306-
"test_dataset = project.create_dataset(TestModel)\n",
307-
"test_dataset"
306+
"import ragas_experimental.typing as rt"
308307
]
309308
},
310309
{
311310
"cell_type": "code",
312311
"execution_count": null,
313312
"metadata": {},
314-
"outputs": [
315-
{
316-
"data": {
317-
"text/plain": [
318-
"'3d9b529b-c23f-4e87-8a26-dd1923749aa7'"
319-
]
320-
},
321-
"execution_count": null,
322-
"metadata": {},
323-
"output_type": "execute_result"
324-
}
325-
],
313+
"outputs": [],
326314
"source": [
327-
"project.project_id"
315+
"# create an example dataset\n",
316+
"class TestModel(BaseModel):\n",
317+
" id: int\n",
318+
" name: str\n",
319+
" description: str\n",
320+
" tags: t.Literal[\"tag1\", \"tag2\", \"tag3\"]\n",
321+
" tags_color_coded: t.Annotated[t.Literal[\"red\", \"green\", \"blue\"], rt.Select(colors=[\"red\", \"green\", \"blue\"])]"
328322
]
329323
},
330324
{
@@ -335,7 +329,7 @@
335329
{
336330
"data": {
337331
"text/plain": [
338-
"'5f7839e7-f4f9-4ada-9082-bc1c5528c259'"
332+
"Dataset(name=TestModel, model=TestModel, len=0)"
339333
]
340334
},
341335
"execution_count": null,
@@ -344,7 +338,9 @@
344338
}
345339
],
346340
"source": [
347-
"test_dataset.dataset_id"
341+
"\n",
342+
"test_dataset = project.create_dataset(TestModel)\n",
343+
"test_dataset"
348344
]
349345
},
350346
{

0 commit comments

Comments
 (0)