How humansignal/label-studio-sdk works
Project Type and Purpose
• This is a client-SDK for Label Studio: a Python library that provides synchronous and asynchronous wrappers around the Label Studio REST API.
• Purpose: Allow Python applications to interact programmatically with Label Studio (create projects, import/export data, manage users, trigger ML backends, etc.).
File Structure
• Top-level directories:
• src/label_studio_sdk/ – the heart of the library
• examples/ – code samples showing how to use the SDK
• tests/ – extensive unit/integration tests
• .mock/ – API definitions and sample OpenAPI spec (used for code generation via Fern)
• .github/ – CI/CD, release and workflow definitions
• Key subpackages under src/label_studio_sdk/:
• core/ – HTTP client wrapper, pagination, serialization utilities
• client.py, base_client.py – entry points for LabelStudio and AsyncLabelStudio
• Domain-specific clients: projects/, tasks/, annotations/, comments/, import_storage/, export_storage/, files/, prompts/, webhooks/, workspaces/, ml/, etc.
• converter/ – transforms between Label Studio’s JSON schema and common annotation formats (COCO, YOLO, CSV…)
• label_interface/ – helpers to build label configuration XML/JSON
• _extensions/ – advanced tooling for ETL or custom evaluation extensions
• Build & Release Files: pyproject.toml, GitHub workflows under .github/workflows/
README for Additional Insights
• Confirms the two entry points (LabelStudio, AsyncLabelStudio)
• Shows usage patterns: instantiation with base_url + api_key, then .projects.create(), .tasks.list(), etc.
• Mentions advanced customization of HTTP client and timeouts
Main Components
a. User Application
• Your Python code or notebook that imports label_studio_sdk and calls methods
b. SDK Entry Points
• Sync client (LabelStudio)
• Async client (AsyncLabelStudio)
c. Core HTTP Layer
• httpx or custom HTTP client injected by the user
• Wrappers in core/http_client.py, core/client_wrapper.py
d. Domain Clients & Utilities
• Modules under projects/, tasks/, annotations/, etc.
• Shared utilities: pagination, serialization, error handling in core/
• converter/ for import/export transformations
• label_interface/ for label config construction
e. Code-Generation Artifacts
• .mock/definition/* and openapi/openapi.yaml (source of truth for API schemas)
f. External Dependencies
• External storage services: S3, GCS, Azure Blob, local disk, Redis (via import/export modules)
• Optional ML backends (triggered via ml/ client)
g. CI/CD & Testing
• GitHub Actions workflows
• Unit & integration tests under tests/
h. Examples & Tutorials
• Code samples showing real-world usage
Relationships and Interactions
• Flow: User App → SDK Entry Point → Core HTTP Layer → Label Studio REST API → Server
• Import/Export: Domain client calls converter modules → writes/reads from storage clients (S3, GCS, etc.)
• Extensions: Optional pipelines via _extensions/label_studio_tools or _extensions/eval
• Custom HTTP Client: User-supplied client plugs into the core HTTP layer
Architectural Patterns & Design Principles
• Modular: Each domain has its own subpackage (Separation of Concerns)
• Client-Server: SDK on client side; Label Studio on server side
• Adapter/Wrapper: The SDK adapts raw REST calls into Pythonic methods
• Code-Generation Driven: API schemas under .mock/ drive generation of types and clients
• Sync vs Async: Two parallel entry points sharing most of the same internal layers
Final Checklist
• Break the system into these main layers:
1. User Application
2. SDK Entry Points (Sync / Async)
3. Core HTTP & Utilities
4. Domain Clients (projects, tasks, annotations, etc.)
5. Converter & Label Interface
6. External Services (REST API, Storage, ML backends)