Skip to content

Conversation

midhun-pm
Copy link

@midhun-pm midhun-pm commented Sep 30, 2025

Description

Alignerr Project Management - High-Level Changes

Overview

This PR introduces a comprehensive new module for Alignerr project management within the Labelbox Python SDK. The changes add a complete project creation and management system with support for project rates, domains, enhanced resource tags, and project ownership.

Code Organization Changes

1. New Module Structure

The PR introduces a new alignerr module under libs/labelbox/src/labelbox/alignerr/ with the following structure:

alignerr/
├── __init__.py                    # Exports AlignerrWorkspace
├── alignerr_project.py           # Core AlignerrProject class
├── alignerr_project_builder.py   # Builder pattern for project creation
├── alignerr_project_factory.py   # Factory pattern for YAML-based creation
└── schema/                       # Data models and GraphQL schemas
    ├── __init__.py
    ├── project_rate.py           # Project rate management
    ├── project_domain.py         # Project domain management
    ├── project_boost_workforce.py # Project ownership management
    └── enchanced_resource_tags.py # Enhanced resource tagging

2. Design Patterns Implemented

Builder Pattern (AlignerrProjectBuilder)

  • Purpose: Programmatic project creation with method chaining
  • Features:
    • Fluent API for setting project properties
    • Validation of required fields
    • Support for selective validation skipping
    • Comprehensive error handling

Factory Pattern (AlignerrProjectFactory)

  • Purpose: YAML-based project creation from configuration files
  • Features:
    • Declarative project configuration
    • YAML schema validation
    • Support for complex nested configurations
    • Template-based project creation

Workspace Pattern (AlignerrWorkspace)

  • Purpose: Entry point for Alignerr functionality
  • Features:
    • Clean API surface
    • Access to both builder and factory patterns
    • Integration with existing Client architecture

3. Schema Organization

The new schema module provides structured data models for:

  • Project Rates: Billing rates for different roles (Labeler, Reviewer) and customer rates
  • Project Domains: Categorization system for projects
  • Enhanced Resource Tags: Advanced tagging system with types (Default, Billing, System)
  • Project Ownership: Workforce management and project ownership assignment

4. Client Integration

The changes integrate seamlessly with the existing Labelbox Client:

# New API surface
client = Client(api_key="...")
workspace = client.alignerr_workspace()

# Builder pattern
project = (workspace.project_builder()
    .set_name("My Project")
    .set_media_type(MediaType.Image)
    .set_alignerr_role_rate(role_name=AlignerrRole.Labeler, rate=15.0, ...)
    .create())

# Factory pattern
project = workspace.project_prototype().create("config.yaml")

Key Features Added

1. Project Rate Management

  • Support for multiple billing modes (BY_TASK, BY_HOUR, BY_TASK_PER_TURN, BY_ACCEPTED_TASK)
  • Role-based rate configuration (Labeler, Reviewer, Admin)
  • Customer billing rate management
  • Effective date ranges for rates

2. Project Domain System

  • Domain creation and management
  • Project-domain associations
  • Search and pagination support
  • Domain-based project categorization

3. Enhanced Resource Tagging

  • Type-based tag organization (Default, Billing, System)
  • Tag creation and management
  • Project-tag associations
  • Search functionality

4. Project Ownership Management

  • Project owner assignment
  • User lookup by email
  • Organization-based user validation
  • Workforce management integration

5. Validation System

  • Comprehensive validation of required fields
  • Selective validation skipping
  • Type checking and format validation
  • Clear error messages and debugging information

Testing Infrastructure

The PR includes comprehensive test coverage:

  • Integration Tests: Full end-to-end testing of all features
  • Unit Tests: Individual component testing
  • YAML Configuration Tests: Factory pattern validation
  • Error Handling Tests: Validation and error scenario coverage

Test files added:

  • test_alignerr_project.py
  • test_alignerr_project_builder.py
  • test_alignerr_project_factory.py
  • test_enhanced_resource_tags.py
  • test_project_domain.py
  • test_project_rate.py

API Design Principles

1. Fluent Interface

The builder pattern provides a fluent, chainable API:

project = (builder
    .set_name("Project")
    .set_media_type(MediaType.Image)
    .set_domains(["Domain1", "Domain2"])
    .create())

2. Declarative Configuration

The factory pattern supports YAML-based configuration:

name: "My Project"
media_type: "Image"
rates:
  LABELER:
    rate: 15.0
    billing_mode: "BY_HOUR"
    effective_since: "2024-01-01T00:00:00"

3. Backward Compatibility

All changes are additive and don't break existing functionality.

4. Type Safety

Comprehensive type hints and Pydantic models ensure type safety throughout the API.

Integration Points

1. Existing Schema Integration

  • Extends existing Project schema
  • Integrates with User and Role systems
  • Uses existing pagination and query patterns

2. GraphQL Integration

  • New GraphQL operations for all Alignerr features
  • Proper error handling and response parsing
  • Support for complex nested queries

3. Client Architecture

  • Follows existing client patterns
  • Maintains consistency with other SDK modules
  • Proper resource management and cleanup

Migration and Adoption

For Existing Users

  • No breaking changes to existing APIs
  • New functionality is opt-in via client.alignerr_workspace()
  • Existing project creation methods remain unchanged

For New Users

  • Clean, intuitive API for project management
  • Comprehensive documentation and examples
  • Multiple creation patterns (programmatic vs. declarative)

Future Extensibility

The architecture is designed for future extensions:

  • Modular Schema System: Easy to add new data models
  • Plugin Architecture: Builder and factory patterns can be extended
  • Validation Framework: Flexible validation system for new requirements
  • Configuration System: YAML-based configuration can be extended for new features

Summary

This PR represents a significant enhancement to the Labelbox Python SDK, introducing a complete project management system for Alignerr workflows. The changes follow established design patterns, maintain backward compatibility, and provide a solid foundation for future enhancements. The code organization is clean, well-tested, and follows Python best practices throughout.
Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Document change (fix typo or modifying any markdown files, code comments or anything in the examples folder only)

All Submissions

  • Have you followed the guidelines in our Contributing document?
  • Have you provided a description?
  • Are your changes properly formatted?

New Feature Submissions

  • Does your submission pass tests?
  • Have you added thorough tests for your new feature?
  • Have you commented your code, particularly in hard-to-understand areas?
  • Have you added a Docstring?

Changes to Core Features

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you updated any code comments, as applicable?

from labelbox.alignerr.schema.project_domain import ProjectDomain


class AlignerrRole(Enum):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this role QQ we have other custom roles right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants