Skip to content

Commit

Permalink
docs: Add notes about old version in examples (#323)
Browse files Browse the repository at this point in the history
Co-authored-by: caitlinwheeless <[email protected]>
  • Loading branch information
makseq and caitlinwheeless authored Sep 30, 2024
1 parent 614ee9b commit 34b9124
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 20 deletions.
4 changes: 3 additions & 1 deletion examples/active_learning/active_learning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34). While the newer versions v1.0 and above still support the functionalities of the old version (see `label_studio_sdk._legacy` for reference), we recommend using the latest Label Studio SDK v1.0 or higher.\n",
"\n",
"Active learning is a branch of machine learning that seeks to minimize the total amount of data required for labeling by strategically sampling data that provides insight into the problem you're trying to solve so that you can focus on labeling that data.\n",
"\n",
"Follow this example to write a Python script using the [Label Studio SDK](https://labelstud.io/sdk/index.html) that performs active learning with a text classification machine learning model. "
Expand Down Expand Up @@ -88,7 +90,7 @@
"metadata": {},
"outputs": [],
"source": [
"from label_studio_sdk.project import ProjectSampling\n",
"from label_studio_sdk._legacy.project import ProjectSampling\n",
"\n",
"project = ls.start_project(\n",
" title='AL Project Created from SDK - DEMO',\n",
Expand Down
11 changes: 9 additions & 2 deletions examples/active_learning/active_learning.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
"""
**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../../README.md) in your script.
"""

import random

from label_studio_sdk import Client
from label_studio_sdk.project import ProjectSampling
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline

from label_studio_sdk import Client
from label_studio_sdk._legacy.project import ProjectSampling

LABEL_STUDIO_URL = "http://localhost:8080"
API_KEY = "91b3b61589784ed069b138eae3d5a5fe1e909f57"

Expand Down
12 changes: 9 additions & 3 deletions examples/adding_new_labels_to_project.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"source": [
"This tutorial demonstrates how to add new labels to an ongoing project in real-time. The included example showcases the use of the `<Taxonomy>` tag, which can be applied to the entire document. However, this same principle can also be used for other cases, such as \n",
"- modifying labels for computer vision applications (bounding boxes, polygons, etc.), or segments in text and audio using nested `<Taxonomy>` tags. \n",
"- modify other tags that contain lists of labels, such as `<Choices>` and `<Labels>`."
"- modify other tags that contain lists of labels, such as `<Choices>` and `<Labels>`.\n",
"\n",
"**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).\n",
"The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify\n",
"[`label_studio_sdk._legacy`](../README.md) in your script."
]
},
{
Expand Down Expand Up @@ -222,7 +226,8 @@
"pycharm": {
"name": "#%% md\n"
}
}
},
"id": "641c8dd06b76348c"
},
{
"cell_type": "code",
Expand All @@ -237,7 +242,8 @@
"pycharm": {
"name": "#%%\n"
}
}
},
"id": "fa55edf2c553b707"
}
],
"metadata": {
Expand Down
7 changes: 7 additions & 0 deletions examples/annotate_data_from_gcs/annotate_data_from_gcs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
"""
Note: This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../../README.md) in your script.
"""

import os

from google.cloud import storage as google_storage

from label_studio_sdk import Client

BUCKET_NAME = "my-bucket" # specify your bucket name here
Expand Down
10 changes: 10 additions & 0 deletions examples/cloud_storages/cloud_storage_guide.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
},
"id": "b0600d1650011dc6"
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).\n",
"The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify\n",
"[`label_studio_sdk._legacy`](../../README.md) in your script."
],
"id": "57cd42b243a4ea45"
},
{
"cell_type": "code",
"outputs": [],
Expand Down
7 changes: 7 additions & 0 deletions examples/export_snapshots.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
"""
**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../README.md) in your script.
"""

import os
import time

from label_studio_sdk import Client

LABEL_STUDIO_URL = os.getenv("LABEL_STUDIO_URL", default="http://localhost:8080")
Expand Down
6 changes: 5 additions & 1 deletion examples/export_with_filters.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
""" Export a snapshot with tasks filtered by ID range.
Note: at this moment it's not possible to export snapshots with filters,
**Note:** at this moment it's not possible to export snapshots with filters,
LS API doesn't support it yet. However, it's achievable by creating a view
with a filter and then exporting a snapshot using this view.
This approach is hidden behind the `project.export()` method.
**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../README.md) in your script.
"""

from label_studio_sdk import Client
Expand Down
9 changes: 8 additions & 1 deletion examples/import_preannotations/import_brush_predictions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
"""
**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../../README.md) in your script.
"""

# Create a new project with several tasks and brush preannotations
# Contributed by https://github.com/berombau:
# https://github.com/heartexlabs/label-studio-sdk/issues/19#issuecomment-992327281

import numpy as np
import label_studio_converter.brush as brush

import label_studio_sdk.converter.brush as brush
from label_studio_sdk import Client

LABEL_STUDIO_URL = "http://localhost:8080"
Expand Down
9 changes: 8 additions & 1 deletion examples/import_preannotations/import_preannotations.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
"""
**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../../README.md) in your script.
"""

# Import tasks with pre-annotations (predictions) using SDK,
# then calculate agreement scores (accuracy) per tasks.

import pandas as pd
from evalme.metrics import (
get_agreement,
) # run first `pip install label-studio-evalme` to use this package

from label_studio_sdk import Client
import pandas as pd

LABEL_STUDIO_URL = "http://localhost:8080"
API_KEY = "91b3b61589784ed069b138eae3d5a5fe1e909f57"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
This script is meant to automatically tag tasks within a project using a random distribution and
then assign those that receive a specific tag to a reviewer for further reviewing.
**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../../README.md) in your script.
"""

from label_studio_sdk import Client
Expand Down
11 changes: 8 additions & 3 deletions examples/label_studio_enterprise/assigner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
""" This script runs every 10 seconds and assigns users to a new batch of tasks filtered by the specified column.
Notes:
**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../../README.md) in your script.
Advanced notes:
1. Don't forget to enable Manual mode in Annotation settings
2. Be careful when adding email users: users who are not members of the project or workspace will break Data Manager
Expand All @@ -13,10 +17,11 @@
Demo video:
https://www.youtube.com/watch?v=IeqrsCYYQ8k
"""
import time

import math
import label_studio_sdk
import time

import label_studio_sdk
from label_studio_sdk.data_manager import Filters, Column, Operator, Type


Expand Down
11 changes: 10 additions & 1 deletion examples/label_studio_enterprise/assignment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"This tutorial describes the basics of assigning users to projects, workspaces, and specific tasks in Label Studio Enterprise using the Python SDK."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).\n",
"The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify\n",
"[`label_studio_sdk._legacy`](../../README.md) in your script."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -125,7 +134,7 @@
"metadata": {},
"outputs": [],
"source": [
"from label_studio_sdk.users import UserRole\n",
"from label_studio_sdk._legacy.users import UserRole\n",
"\n",
"user.set_role(UserRole.REVIEWER)\n",
"print(user)"
Expand Down
8 changes: 6 additions & 2 deletions examples/label_studio_enterprise/user_management.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This tutorial describes the basics of managing users in Label Studio Enterprise using the Python SDK."
"This tutorial describes the basics of managing users in Label Studio Enterprise using the Python SDK.\n",
"\n",
"**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).\n",
"The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify\n",
"[`label_studio_sdk._legacy`](../../README.md) in your script."
]
},
{
Expand Down Expand Up @@ -77,7 +81,7 @@
"metadata": {},
"outputs": [],
"source": [
"from label_studio_sdk.users import UserRole\n",
"from label_studio_sdk._legacy.users import UserRole\n",
"\n",
"user.set_role(UserRole.ANNOTATOR)"
]
Expand Down
8 changes: 6 additions & 2 deletions examples/migrate_ls_to_ls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ Each new run of this script will generate new projects on the destination instan

**Note:** Create a new workspace and get its ID for projects to be mgiratated.

**SDK v0.0.34**
**SDK v1.0 or higher**

```
pip install label-studio-sdk==0.0.34
pip install -U label-studio-sdk
```

**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../../README.md) in your script.

# How it works?

1. Get all projects from source LS (or specific projects)
Expand Down
6 changes: 5 additions & 1 deletion examples/migrate_ls_to_ls/migrate-ls-to-ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Usage:
> python3 migrate-ls-to-ls.py --src-url src-ls.com --src-key <src-token> --dst-url dst-ls.com --dst-key <dst-token> --project-ids=123,456
**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../../README.md) in your script.
"""

import json
Expand All @@ -11,8 +15,8 @@
import time

from label_studio_sdk import Client
from label_studio_sdk._legacy.users import User
from label_studio_sdk.data_manager import Filters, Operator, Type, Column
from label_studio_sdk.users import User

logger = logging.getLogger("migration-ls-to-ls")
logger.setLevel(logging.DEBUG)
Expand Down
6 changes: 5 additions & 1 deletion examples/weak_supervision/weak_supervision.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
"source": [
"Perform weak supervision with Label Studio, using noisy labels on a large amount of training data to automatically build a useful training dataset for your supervised learning model. \n",
"\n",
"In this example, use the [Label Studio SDK](https://labelstud.io/sdk/index.html) to write a Python script that adds noisy labels to tasks, then adds those tasks to Label Studio for review and correction in a supervised learning setting. "
"In this example, use the [Label Studio SDK](https://labelstud.io/sdk/index.html) to write a Python script that adds noisy labels to tasks, then adds those tasks to Label Studio for review and correction in a supervised learning setting.\n",
"\n",
"**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).\n",
"The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify\n",
"[`label_studio_sdk._legacy`](../../README.md) in your script."
]
},
{
Expand Down
9 changes: 8 additions & 1 deletion examples/weak_supervision/weak_supervision.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
"""
**Note:** This code utilizes functions from an older version of the Label Studio SDK (v0.0.34).
The newer versions v1.0 and above still support the functionalities of the old version, but you will need to specify
[`label_studio_sdk._legacy`](../../README.md) in your script.
"""

import random
import re

from label_studio_sdk import Client
import pandas as pd

from label_studio_sdk import Client

ls = Client(
url="http://localhost:8080", api_key="d6f8a2622d39e9d89ff0dfef1a80ad877f4ee9e3"
)
Expand Down

0 comments on commit 34b9124

Please sign in to comment.