Skip to main content

Python SDK for Superb AI On-premise

Project description

Superb AI On-premise SDK

Python SDK for Superb AI's On-premise solution. This SDK provides a simple interface to interact with your on-premise Superb AI installation.

Installation

pip install superb-ai-onprem

Quick Start

from spb_onprem import DatasetService, DataService
from spb_onprem.data.enums import DataType

# Initialize services
dataset_service = DatasetService()
data_service = DataService()

# Create a dataset
dataset = dataset_service.create_dataset(
    name="my-dataset",
    description="My first dataset"
)

# Upload an image with annotation
with open("image.jpg", "rb") as f:
    image_data = BytesIO(f.read())

data = data_service.create_image_data(
    dataset_id=dataset.id,
    key="image_1",
    image_content=image_data,
    annotation={
        "labels": ["car", "person"],
        "boxes": [
            {"x": 100, "y": 100, "width": 200, "height": 200}
        ]
    }
)

Features

  • Dataset Management
    • Create, update, and delete datasets
    • List and filter datasets
  • Data Management
    • Upload images with annotations
    • Update annotations
    • Add/remove data from slices
    • Manage metadata
  • Slice Management
    • Create and manage data slices
    • Filter and organize your data

Usage Examples

Dataset Operations

from spb_onprem import DatasetService
from spb_onprem import DatasetsFilter, DatasetsFilterOptions

# Initialize service
dataset_service = DatasetService()

# Create a dataset
dataset = dataset_service.create_dataset(
    name="my-dataset",
    description="Dataset description"
)

# List datasets with filtering
filter = DatasetsFilter(
    must_filter=DatasetsFilterOptions(
        name_contains="test"
    )
)
datasets = dataset_service.get_datasets(filter=filter)

Data Operations

from spb_onprem import DataService
from spb_onprem import DataListFilter, DataFilterOptions

# Initialize service
data_service = DataService()

# List data with filtering
filter = DataListFilter(
    must_filter=DataFilterOptions(
        key_contains="image_",
        annotation_exists=True
    )
)
data_list = data_service.get_data_list(
    dataset_id="your-dataset-id",
    filter=filter
)

# Update annotation
data_service.update_annotation(
    dataset_id="your-dataset-id",
    data_id="your-data-id",
    annotation={
        "labels": ["updated_label"],
        "boxes": [...]
    }
)

Slice Operations

from spb_onprem import SliceService

# Initialize service
slice_service = SliceService()

# Create a slice
slice = slice_service.create_slice(
    dataset_id="your-dataset-id",
    name="validation-set",
    description="Validation data slice"
)

# Add data to slice
data_service.add_data_to_slice(
    dataset_id="your-dataset-id",
    data_id="your-data-id",
    slice_id=slice.id
)

Error Handling

The SDK provides specific error types for different scenarios:

from spb_onprem.exceptions import (
    BadParameterError,
    NotFoundError,
    UnknownError
)

try:
    dataset = dataset_service.get_dataset(dataset_id="non-existent-id")
except NotFoundError:
    print("Dataset not found")
except BadParameterError as e:
    print(f"Invalid parameter: {e}")
except UnknownError as e:
    print(f"An unexpected error occurred: {e}")

Configuration

The SDK supports two authentication methods:

1. Config File Authentication (Default)

Create a config file at ~/.spb/onprem-config:

[default]
host=https://your-onprem-host
access_key=your-access-key
access_key_secret=your-access-key-secret

This is the default authentication method when SUPERB_SYSTEM_SDK=false or not set.

2. Environment Variables (for Airflow DAGs)

When running in an Airflow DAG or other system environments, you can use environment variables for authentication. This method is activated by setting SUPERB_SYSTEM_SDK=true.

Required environment variables:

# Enable system SDK mode
export SUPERB_SYSTEM_SDK=true

# Set the host URL (either one is required)
export SUPERB_SYSTEM_SDK_HOST=https://your-superb-ai-host
# or
export SUNRISE_SERVER_URL=https://your-superb-ai-host

# Set the user email
export SUPERB_SYSTEM_SDK_USER_EMAIL=user@example.com

You can set these environment variables:

  • Directly in your shell
  • In your Airflow DAG configuration
  • Through your deployment environment
  • Using a .env file with your preferred method of loading environment variables

Note:

  • When SUPERB_SYSTEM_SDK=true, the SDK will ignore the config file (~/.spb/onprem-config) and use environment variables exclusively.
  • When SUPERB_SYSTEM_SDK=false or not set, the SDK will look for authentication credentials in ~/.spb/onprem-config.

Requirements

  • Python >= 3.7
  • requests >= 2.22.0
  • urllib3 >= 1.21.1
  • pydantic >= 1.8.0

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support or feature requests, please contact the Superb AI team or create an issue in this repository.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

superb_ai_onprem-0.5.20.tar.gz (71.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

superb_ai_onprem-0.5.20-py3-none-any.whl (103.5 kB view details)

Uploaded Python 3

File details

Details for the file superb_ai_onprem-0.5.20.tar.gz.

File metadata

  • Download URL: superb_ai_onprem-0.5.20.tar.gz
  • Upload date:
  • Size: 71.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for superb_ai_onprem-0.5.20.tar.gz
Algorithm Hash digest
SHA256 e4d8ce2b44282b77a5bfc440214891c68246b7fbbb82fa1d3c43fd92d5be1735
MD5 4f9adcd3d2f934ea1557501045f23255
BLAKE2b-256 b9a904aa9f862fa3d31a90d6d7e11e13034347577bcfe37bb65394ef602d35d0

See more details on using hashes here.

File details

Details for the file superb_ai_onprem-0.5.20-py3-none-any.whl.

File metadata

File hashes

Hashes for superb_ai_onprem-0.5.20-py3-none-any.whl
Algorithm Hash digest
SHA256 70e72f9e9ee928505a0e1400eacdc3feb9cc6bdf0df586b0ad1f4ae75a5fea01
MD5 ab90c65a34d8074dde3417427aac0dec
BLAKE2b-256 3cc97c955550e0ac1fc8c056617b5ffd443dd2bd85d9fe69683f10278b9f7a75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page