Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove labelbox client arg from labelbox integration functions #3031

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions deeplake/integrations/labelbox/labelbox_.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

def converter_for_video_project_with_id(
project_id,
client,
deeplake_ds_loader,
lb_api_key,
group_mapping=None,
Expand All @@ -26,7 +25,6 @@

Args:
project_id (str): The unique identifier for the Labelbox project to convert.
client (LabelboxClient): An authenticated Labelbox client instance for API access.
deeplake_ds_loader (callable): A function that creates/loads a Deeplake dataset given a name.
lb_api_key (str): Labelbox API key for authentication.
group_mapping (dict, optional): A dictionary mapping annotation kinds (labelbox_kind) to the desired tensor group name (tensor_name). This mapping determines whether annotations of the same kind should be grouped into the same tensor or kept separate.
Expand All @@ -45,10 +43,8 @@
Exception: If project data validation fails.

Example:
>>> client = LabelboxClient(api_key='your_api_key')
>>> converter = converter_for_video_project_with_id(
... '<project_id>',
... client,
... lambda name: deeplake.load(name),
... 'your_api_key',
... group_mapping={"raster-segmentation": "mask"}
Expand All @@ -61,6 +57,9 @@
- Supports Video ontology from labelbox.
- The function first validates the project data before setting up converters.
"""
import labelbox as lb # type: ignore

Check warning on line 60 in deeplake/integrations/labelbox/labelbox_.py

View check run for this annotation

Codecov / codecov/patch

deeplake/integrations/labelbox/labelbox_.py#L60

Added line #L60 was not covered by tests

client = lb.Client(api_key=lb_api_key)

Check warning on line 62 in deeplake/integrations/labelbox/labelbox_.py

View check run for this annotation

Codecov / codecov/patch

deeplake/integrations/labelbox/labelbox_.py#L62

Added line #L62 was not covered by tests
if project_json is None:
project_json = labelbox_get_project_json_with_id_(
client, project_id, fail_on_labelbox_project_export_error
Expand Down Expand Up @@ -181,7 +180,7 @@
video_paths,
lb_dataset_name,
lb_project_name,
lb_client,
lb_api_key,
lb_ontology=None,
lb_batch_priority=5,
data_upload_strategy="fail",
Expand All @@ -194,14 +193,17 @@
video_paths (List[str]): List of paths to video files to be processed can be either all local or all pre-signed remote.
lb_dataset_name (str): Name for Labelbox dataset.
lb_project_name (str): Name for Labelbox project.
lb_client (LabelboxClient): Authenticated Labelbox client instance
lb_api_key (str): Labelbox API key for authentication.
lb_ontology (Ontology, optional): Labelbox ontology to connect to project. Defaults to None
lb_batch_priority (int, optional): Priority for Labelbox batches. Defaults to 5
data_upload_strategy (str, optional): Strategy for uploading data to Labelbox. Can be 'fail', 'skip', or 'all'. Defaults to 'fail'
lb_batches_name (str, optional): Name for Labelbox batches. Defaults to None. If None, will use lb_dataset_name + '_batch-'
"""

import labelbox as lb # type: ignore

lb_client = lb.Client(api_key=lb_api_key)

Check warning on line 205 in deeplake/integrations/labelbox/labelbox_.py

View check run for this annotation

Codecov / codecov/patch

deeplake/integrations/labelbox/labelbox_.py#L205

Added line #L205 was not covered by tests

video_paths = filter_video_paths_(video_paths, data_upload_strategy)

assets = video_paths
Expand Down Expand Up @@ -270,7 +272,6 @@
def create_dataset_from_video_annotation_project_with_custom_data_filler(
deeplake_ds_path,
project_id,
lb_client,
lb_api_key,
data_filler,
deeplake_creds=None,
Expand All @@ -291,7 +292,6 @@
deeplake_ds_path (str): Path where the Deeplake dataset will be created/stored.
Can be local path or cloud path (e.g. 'hub://org/dataset')
project_id (str): Labelbox project ID to import data from
lb_client (LabelboxClient): Authenticated Labelbox client instance
lb_api_key (str): Labelbox API key for accessing video frames
data_filler (dict): Dictionary containing two functions:
- 'create_tensors': callable(ds) -> None
Expand All @@ -316,6 +316,11 @@
Notes:
- The function does not fetch the annotations from Labelbox, only the video frames. After creating the dataset, use the converter to apply annotations.
"""

import labelbox as lb # type: ignore

Check warning on line 320 in deeplake/integrations/labelbox/labelbox_.py

View check run for this annotation

Codecov / codecov/patch

deeplake/integrations/labelbox/labelbox_.py#L320

Added line #L320 was not covered by tests

lb_client = lb.Client(api_key=lb_api_key)

Check warning on line 322 in deeplake/integrations/labelbox/labelbox_.py

View check run for this annotation

Codecov / codecov/patch

deeplake/integrations/labelbox/labelbox_.py#L322

Added line #L322 was not covered by tests

wrapped_dataset = dataset_wrapper.create(
deeplake_ds_path,
token=deeplake_token,
Expand Down Expand Up @@ -376,7 +381,6 @@
def create_dataset_from_video_annotation_project(
deeplake_ds_path,
project_id,
lb_client,
lb_api_key,
deeplake_creds=None,
deeplake_org_id=None,
Expand All @@ -398,7 +402,6 @@
return create_dataset_from_video_annotation_project_with_custom_data_filler(
deeplake_ds_path,
project_id,
lb_client,
lb_api_key,
data_filler={
"create_tensors": create_tensors_default_,
Expand Down
4 changes: 0 additions & 4 deletions deeplake/integrations/tests/test_labelbox.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import labelbox as lb # type: ignore
import os
import numpy as np
import pytest
Expand Down Expand Up @@ -264,7 +263,6 @@ def test_connect_to_labelbox():
ds_path = "mem://labelbox_connect_test"

API_KEY = os.environ["LABELBOX_TOKEN"]
client = lb.Client(api_key=API_KEY)

project_id = "cm4hts5gf0109072nbpl390xc"

Expand All @@ -280,7 +278,6 @@ def url_presigner(url):
ds, project_json = create_dataset_from_video_annotation_project(
ds_path,
project_id,
client,
API_KEY,
url_presigner=url_presigner,
)
Expand All @@ -298,7 +295,6 @@ def ds_provider(p):

converter = converter_for_video_project_with_id(
project_id,
client,
ds_provider,
API_KEY,
group_mapping={"raster-segmentation": "mask"},
Expand Down
Loading