Skip to content

Commit

Permalink
fix: Getting started ipynb (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
makseq authored Aug 13, 2024
1 parent ef479eb commit 2db455a
Showing 1 changed file with 116 additions and 38 deletions.
154 changes: 116 additions & 38 deletions examples/getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
},
{
"cell_type": "code",
"outputs": [],
"source": [
"from label_studio_sdk.client import LabelStudio\n",
"\n",
"ls = LabelStudio(\n",
" base_url='http://localhost:8080',\n",
" api_key='27c982caa9e599c9d81b25b00663e7d4f82c9e3c',\n",
" api_key='78258cfc11b3c9f50104774d1c004842bd06bc80',\n",
")"
],
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-07-09T09:27:32.753924Z",
"start_time": "2024-07-09T09:27:31.538397Z"
"end_time": "2024-08-13T11:45:44.791239Z",
"start_time": "2024-08-13T11:45:44.781498Z"
}
},
"id": "initial_id",
"execution_count": 1
"outputs": [],
"execution_count": 9
},
{
"cell_type": "markdown",
Expand All @@ -45,21 +45,6 @@
},
{
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<View>\n",
" <Text name=\"text\" value=\"$text\"/>\n",
" <Choices name=\"label\" toName=\"text\">\n",
" <Choice value=\"Positive\"/>\n",
" <Choice value=\"Negative\"/>\n",
" </Choices>\n",
"</View>\n"
]
}
],
"source": [
"from label_studio_sdk.label_interface import LabelInterface\n",
"from label_studio_sdk.label_interface.create import choices\n",
Expand All @@ -73,12 +58,28 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-09T08:40:57.172903Z",
"start_time": "2024-07-09T08:40:57.167649Z"
"end_time": "2024-08-13T11:45:44.814719Z",
"start_time": "2024-08-13T11:45:44.809849Z"
}
},
"id": "93e728713446e20f",
"execution_count": 3
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<View>\n",
" <Text name=\"text\" value=\"$text\"/>\n",
" <Choices name=\"label\" toName=\"text\">\n",
" <Choice value=\"Positive\"/>\n",
" <Choice value=\"Negative\"/>\n",
" </Choices>\n",
"</View>\n",
"\n"
]
}
],
"execution_count": 10
},
{
"cell_type": "markdown",
Expand All @@ -94,7 +95,6 @@
},
{
"cell_type": "code",
"outputs": [],
"source": [
"project = ls.projects.create(\n",
" title='Text Classification',\n",
Expand All @@ -104,9 +104,24 @@
"print(f'Created project:\\n{ls._client_wrapper.get_base_url()}/projects/{project.id}')"
],
"metadata": {
"collapsed": false
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-08-13T11:45:44.872356Z",
"start_time": "2024-08-13T11:45:44.816740Z"
}
},
"id": "7f05d9e5f6d25125"
"id": "7f05d9e5f6d25125",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Created project:\n",
"http://localhost:8080/projects/7\n"
]
}
],
"execution_count": 11
},
{
"cell_type": "markdown",
Expand All @@ -120,7 +135,6 @@
},
{
"cell_type": "code",
"outputs": [],
"source": [
"ls.projects.import_tasks(\n",
" id=project.id,\n",
Expand All @@ -132,10 +146,26 @@
")"
],
"metadata": {
"collapsed": false
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-08-13T11:45:44.975709Z",
"start_time": "2024-08-13T11:45:44.874324Z"
}
},
"id": "f4d556fb04165434",
"execution_count": null
"outputs": [
{
"data": {
"text/plain": [
"ProjectsImportTasksResponse(task_count=3, annotation_count=0, predictions_count=None, duration=0.03037261962890625, file_upload_ids=[], could_be_tasks_list=False, found_formats=[], data_columns=[], prediction_count=0)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 12
},
{
"cell_type": "markdown",
Expand All @@ -149,7 +179,6 @@
},
{
"cell_type": "code",
"outputs": [],
"source": [
"ls.projects.import_tasks(\n",
" id=project.id,\n",
Expand All @@ -162,10 +191,26 @@
")"
],
"metadata": {
"collapsed": false
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-08-13T11:45:45.075813Z",
"start_time": "2024-08-13T11:45:44.977719Z"
}
},
"id": "5df9f60ae30651f8",
"execution_count": null
"outputs": [
{
"data": {
"text/plain": [
"ProjectsImportTasksResponse(task_count=3, annotation_count=0, predictions_count=None, duration=0.029715776443481445, file_upload_ids=[], could_be_tasks_list=False, found_formats=[], data_columns=[], prediction_count=3)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 13
},
{
"cell_type": "markdown",
Expand All @@ -179,7 +224,6 @@
},
{
"cell_type": "code",
"outputs": [],
"source": [
"from label_studio_sdk.label_interface.objects import PredictionValue\n",
"\n",
Expand All @@ -201,10 +245,15 @@
" ls.predictions.create(task=task_id, **prediction.model_dump())\n"
],
"metadata": {
"collapsed": false
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-08-13T11:45:45.818898Z",
"start_time": "2024-08-13T11:45:45.077904Z"
}
},
"id": "687a17f9e370f275",
"execution_count": null
"outputs": [],
"execution_count": 14
},
{
"cell_type": "markdown",
Expand All @@ -218,18 +267,47 @@
},
{
"cell_type": "code",
"outputs": [],
"source": [
"for task in ls.tasks.list(project=project.id):\n",
" print(task.id)\n",
" print(task.annotations)\n",
" print(task.predictions)"
],
"metadata": {
"collapsed": false
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-08-13T11:45:46.003612Z",
"start_time": "2024-08-13T11:45:45.821692Z"
}
},
"id": "24e1333f469965b",
"execution_count": null
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"16\n",
"[]\n",
"[{'id': 107, 'result': [{'id': '05776213-adb7-4f9d-a31f-43cb843f6ab3', 'from_name': 'label', 'to_name': 'text', 'type': 'choices', 'value': {'choices': ['Positive']}}], 'model_version': 'my_model_v1', 'created_ago': '0\\xa0minutes', 'score': 0.0, 'cluster': None, 'neighbors': None, 'mislabeling': 0.0, 'created_at': '2024-08-13T11:45:45.273976Z', 'updated_at': '2024-08-13T11:45:45.274003Z', 'model': None, 'model_run': None, 'task': 16, 'project': 7}]\n",
"17\n",
"[]\n",
"[{'id': 108, 'result': [{'id': '0e44dfd5-18cb-4544-a6df-31c0a944d36b', 'from_name': 'label', 'to_name': 'text', 'type': 'choices', 'value': {'choices': ['Positive']}}], 'model_version': 'my_model_v1', 'created_ago': '0\\xa0minutes', 'score': 0.0, 'cluster': None, 'neighbors': None, 'mislabeling': 0.0, 'created_at': '2024-08-13T11:45:45.367334Z', 'updated_at': '2024-08-13T11:45:45.367367Z', 'model': None, 'model_run': None, 'task': 17, 'project': 7}]\n",
"18\n",
"[]\n",
"[{'id': 109, 'result': [{'id': '7cf85fab-c0e5-465e-a397-5b54516547b6', 'from_name': 'label', 'to_name': 'text', 'type': 'choices', 'value': {'choices': ['Positive']}}], 'model_version': 'my_model_v1', 'created_ago': '0\\xa0minutes', 'score': 0.0, 'cluster': None, 'neighbors': None, 'mislabeling': 0.0, 'created_at': '2024-08-13T11:45:45.450186Z', 'updated_at': '2024-08-13T11:45:45.450221Z', 'model': None, 'model_run': None, 'task': 18, 'project': 7}]\n",
"19\n",
"[]\n",
"[{'id': 104, 'result': [{'from_name': 'label', 'to_name': 'text', 'type': 'choices', 'value': {'choices': ['Positive']}}], 'model_version': 'undefined', 'created_ago': '0\\xa0minutes', 'score': None, 'cluster': None, 'neighbors': None, 'mislabeling': 0.0, 'created_at': '2024-08-13T11:45:45.004099Z', 'updated_at': '2024-08-13T11:45:45.004121Z', 'model': None, 'model_run': None, 'task': 19, 'project': 7}, {'id': 110, 'result': [{'id': 'c81a48ed-71bf-4058-bb1f-eee2b6e00a92', 'from_name': 'label', 'to_name': 'text', 'type': 'choices', 'value': {'choices': ['Positive']}}], 'model_version': 'my_model_v1', 'created_ago': '0\\xa0minutes', 'score': 0.0, 'cluster': None, 'neighbors': None, 'mislabeling': 0.0, 'created_at': '2024-08-13T11:45:45.528966Z', 'updated_at': '2024-08-13T11:45:45.528997Z', 'model': None, 'model_run': None, 'task': 19, 'project': 7}]\n",
"20\n",
"[]\n",
"[{'id': 105, 'result': [{'from_name': 'label', 'to_name': 'text', 'type': 'choices', 'value': {'choices': ['Negative']}}], 'model_version': 'undefined', 'created_ago': '0\\xa0minutes', 'score': None, 'cluster': None, 'neighbors': None, 'mislabeling': 0.0, 'created_at': '2024-08-13T11:45:45.004157Z', 'updated_at': '2024-08-13T11:45:45.004168Z', 'model': None, 'model_run': None, 'task': 20, 'project': 7}, {'id': 111, 'result': [{'id': '946986b3-59f1-45af-b1fd-2868c1500bcd', 'from_name': 'label', 'to_name': 'text', 'type': 'choices', 'value': {'choices': ['Positive']}}], 'model_version': 'my_model_v1', 'created_ago': '0\\xa0minutes', 'score': 0.0, 'cluster': None, 'neighbors': None, 'mislabeling': 0.0, 'created_at': '2024-08-13T11:45:45.610859Z', 'updated_at': '2024-08-13T11:45:45.610895Z', 'model': None, 'model_run': None, 'task': 20, 'project': 7}]\n",
"21\n",
"[]\n",
"[{'id': 106, 'result': [{'from_name': 'label', 'to_name': 'text', 'type': 'choices', 'value': {'choices': ['Positive']}}], 'model_version': 'undefined', 'created_ago': '0\\xa0minutes', 'score': None, 'cluster': None, 'neighbors': None, 'mislabeling': 0.0, 'created_at': '2024-08-13T11:45:45.004200Z', 'updated_at': '2024-08-13T11:45:45.004210Z', 'model': None, 'model_run': None, 'task': 21, 'project': 7}, {'id': 112, 'result': [{'id': 'a2598093-a978-48dd-80d0-3e1afd0afaa6', 'from_name': 'label', 'to_name': 'text', 'type': 'choices', 'value': {'choices': ['Positive']}}], 'model_version': 'my_model_v1', 'created_ago': '0\\xa0minutes', 'score': 0.0, 'cluster': None, 'neighbors': None, 'mislabeling': 0.0, 'created_at': '2024-08-13T11:45:45.691258Z', 'updated_at': '2024-08-13T11:45:45.691294Z', 'model': None, 'model_run': None, 'task': 21, 'project': 7}]\n"
]
}
],
"execution_count": 15
},
{
"cell_type": "markdown",
Expand Down

0 comments on commit 2db455a

Please sign in to comment.