Skip to content

Commit

Permalink
Merge pull request #536 from Labelbox/develop
Browse files Browse the repository at this point in the history
3.18.0
  • Loading branch information
jtsodapop authored Apr 7, 2022
2 parents 7a80776 + 34bdb2c commit 45efbe5
Show file tree
Hide file tree
Showing 26 changed files with 1,821 additions and 1,627 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ jobs:

LABELBOX_TEST_API_KEY_STAGING: ${{ secrets[matrix.staging-key] }}
run: |
tox -e py -- -svvx
tox -e py -- -svv --reruns 5 --reruns-delay 10
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

# Version 3.18.0 (2022-04-07)
## Added
* Added beta support for exporting labels from model_runs
* LBV1Converter now supports data_split key
* Classification objects now include `scope` key

## Fix
* Updated notebooks

# Version 3.17.2 (2022-03-28)
## Fix
* Project.upsert_instructions now works properly for new projects.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.7

RUN pip install pytest pytest-cases
RUN pip install pytest pytest-cases pytest-rerunfailures
RUN apt-get -y update
RUN apt install -y libsm6 \
libxext6 \
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ test-local: build
docker run -it -v ${PWD}:/usr/src -w /usr/src \
-e LABELBOX_TEST_ENVIRON="local" \
-e LABELBOX_TEST_API_KEY_LOCAL=${LABELBOX_TEST_API_KEY_LOCAL} \
local/labelbox-python:test pytest $(PATH_TO_TEST) -svvx
local/labelbox-python:test pytest $(PATH_TO_TEST)

test-staging: build
docker run -it -v ${PWD}:/usr/src -w /usr/src \
-e LABELBOX_TEST_ENVIRON="staging" \
-e LABELBOX_TEST_API_KEY_STAGING=${LABELBOX_TEST_API_KEY_STAGING} \
local/labelbox-python:test pytest $(PATH_TO_TEST) -svvx
local/labelbox-python:test pytest $(PATH_TO_TEST)

test-prod: build
docker run -it -v ${PWD}:/usr/src -w /usr/src \
-e LABELBOX_TEST_ENVIRON="prod" \
-e LABELBOX_TEST_API_KEY_PROD=${LABELBOX_TEST_API_KEY_PROD} \
local/labelbox-python:test pytest $(PATH_TO_TEST) -svvx
local/labelbox-python:test pytest $(PATH_TO_TEST)
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Sphinx==3.4.3
Sphinx==4.5.0
sphinxcontrib-napoleon==0.7
sphinx-rtd-theme==0.5.1
329 changes: 329 additions & 0 deletions examples/basics/batches.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,329 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "db768cda",
"metadata": {
"id": "db768cda"
},
"source": [
"<td>\n",
" <a target=\"_blank\" href=\"https://labelbox.com\" ><img src=\"https://labelbox.com/blog/content/images/2021/02/logo-v4.svg\" width=256/></a>\n",
"</td>"
]
},
{
"cell_type": "markdown",
"id": "cb5611d0",
"metadata": {
"id": "cb5611d0"
},
"source": [
"<td>\n",
"<a href=\"https://colab.research.google.com/github/Labelbox/labelbox-python/blob/develop/examples/basics/data_rows.ipynb\" target=\"_blank\"><img\n",
"src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"></a>\n",
"</td>\n",
"\n",
"<td>\n",
"<a href=\"https://github.com/Labelbox/labelbox-python/tree/develop/examples/basics/data_rows.ipynb\" target=\"_blank\"><img\n",
"src=\"https://img.shields.io/badge/GitHub-100000?logo=github&logoColor=white\" alt=\"GitHub\"></a>\n",
"</td>"
]
},
{
"cell_type": "markdown",
"source": [
"## Batches (*Currently in Public Beta*)"
],
"metadata": {
"id": "Lup2QNWjaxKg"
},
"id": "Lup2QNWjaxKg"
},
{
"cell_type": "markdown",
"source": [
"* A Batch is collection of datarows picked out of a Data Set.\n",
"* A Datarow cannot be part of more than one batch in a project.\n",
"* Batches work for all data types, but there should only be one data type per batch.\n",
"* Batches may not be shared between projects.\n",
"* Batches may have Datarows from multiple Datasets.\n",
"* Datarows can only be attached to a Project as part of a single Batch.\n",
"* You can set priority for each Batch."
],
"metadata": {
"id": "KONWmRQkadPf"
},
"id": "KONWmRQkadPf"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "HoW5ypnyzpqb"
},
"outputs": [],
"source": [
"!pip install labelbox[data]"
],
"id": "HoW5ypnyzpqb"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "6-Us9Gj1zpqc"
},
"outputs": [],
"source": [
"from labelbox import DataRow, Client\n",
"import random"
],
"id": "6-Us9Gj1zpqc"
},
{
"cell_type": "markdown",
"metadata": {
"id": "qQiozm-dzpqd"
},
"source": [
"Set the following cell with your data to run this notebook:"
],
"id": "qQiozm-dzpqd"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "84Zna5c0zpqd"
},
"outputs": [],
"source": [
"PROJECT_NAME = \"Batch Queue Demo\" #text project\n",
"DATASET_NAME = \"Batch Queue Demo Data\""
],
"id": "84Zna5c0zpqd"
},
{
"cell_type": "markdown",
"id": "b0b09aee",
"metadata": {
"id": "b0b09aee"
},
"source": [
"# API Key and Client\n",
"Provide a valid api key below in order to properly connect to the Labelbox Client."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Ge-dfNh-zpqe"
},
"outputs": [],
"source": [
"# Add your api key\n",
"API_KEY = None\n",
"client = Client(api_key=API_KEY)"
],
"id": "Ge-dfNh-zpqe"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "nMVtBYQmzpqe"
},
"outputs": [],
"source": [
"dataset = client.create_dataset(name=DATASET_NAME)\n",
"\n",
"uploads = []\n",
"for i in range(10):\n",
" uploads.append({\n",
" 'external_id': i,\n",
" 'row_data': 'https://picsum.photos/200/300'\n",
" })\n",
"dataset.create_data_rows(uploads)"
],
"id": "nMVtBYQmzpqe"
},
{
"cell_type": "markdown",
"source": [
"# Ensure project is in batch mode:"
],
"metadata": {
"id": "61CvCD3C7qv6"
},
"id": "61CvCD3C7qv6"
},
{
"cell_type": "code",
"source": [
"project = client.create_project(name=PROJECT_NAME)\n",
"project.update(queue_mode=project.QueueMode.Batch)"
],
"metadata": {
"id": "tqtT4q31787T"
},
"id": "tqtT4q31787T",
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"# Collect Datarow id's:"
],
"metadata": {
"id": "Xti9AoZWELrq"
},
"id": "Xti9AoZWELrq"
},
{
"cell_type": "markdown",
"source": [
"### Select All Data Rows from dataset."
],
"metadata": {
"id": "9JVLsXdevywS"
},
"id": "9JVLsXdevywS"
},
{
"cell_type": "code",
"source": [
"data_rows = [dr.uid for dr in list(dataset.export_data_rows())]"
],
"metadata": {
"id": "U4C1ZyJ2EgTS"
},
"id": "U4C1ZyJ2EgTS",
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"### Randomly sample\n",
"\n",
"Rather than selecting all of the data we sample 5 data rows at random"
],
"metadata": {
"id": "B0UqO_O1V8ei"
},
"id": "B0UqO_O1V8ei"
},
{
"cell_type": "code",
"source": [
"sample = random.sample(data_rows, 5)"
],
"metadata": {
"id": "WJAXBf1bV-td"
},
"id": "WJAXBf1bV-td",
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"# Batch Manipulation"
],
"metadata": {
"id": "UPdaTqkgYyvt"
},
"id": "UPdaTqkgYyvt"
},
{
"cell_type": "markdown",
"source": [
"### Create a Batch:"
],
"metadata": {
"id": "Al-K1lBBEjtb"
},
"id": "Al-K1lBBEjtb"
},
{
"cell_type": "code",
"source": [
"batch = project.create_batch(\n",
" \"first batch\", # Each batch in a project must have a unique name\n",
" sample, # A list of data rows or data row ids\n",
" 5 # priority between 1(Highest) - 5(lowest)\n",
")"
],
"metadata": {
"id": "resH3xqeErVv"
},
"id": "resH3xqeErVv",
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# number of data rows in the batch\n",
"batch.size"
],
"metadata": {
"id": "gFio7ONOWYdJ"
},
"id": "gFio7ONOWYdJ",
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "8Cj64Isxzpqe"
},
"source": [
"### List DataRows in a Batch (Not supported yet)\n",
"Note: You can view your batch through in the Data Row table of the project"
],
"id": "8Cj64Isxzpqe"
},
{
"cell_type": "markdown",
"metadata": {
"id": "rU7iddSQzpqg"
},
"source": [
"### Remove queued data rows by batch (Not supported yet)\n",
"Note: You can do this through the batch management pane on the data rows tab of the project"
],
"id": "rU7iddSQzpqg"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
},
"colab": {
"name": "Batches.ipynb",
"provenance": [],
"collapsed_sections": []
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 45efbe5

Please sign in to comment.