Skip to main content

the official Python SDK for sorter.social's seamless data labeling solutions for any AI/ML workflow.

Project description

sorterpy

PyPI version Build and Release Status Documentation Status

The official Python SDK for sorter.social's seamless data labeling solutions for any AI/ML workflow.

Created by @zudsniper for sorter.

Installation

pip install sorterpy

API Compatibility

This SDK is compatible with the following sorter.social API versions:

  • 2.x
  • 2.1.x
  • 2.1.1

Basic Usage

from sorterpy import Sorter

# Initialize the client with options
sorter = Sorter(
    api_key="your-api-key",
    base_url="http://localhost:3000",
    options={
        "vote_magnitude": "equal",  # Use -50 to 50 scale (default)
        "verbose": False,           # Disable detailed logging (default)
        "quiet": False,             # Don't suppress logs (default)
        "compatibility_warnings": True  # Show API version compatibility warnings (default)
        "debug_http_full": False    # Truncate long http bodies when debug printing them (default)
    }
)

# Create a tag
tag = sorter.tag("My Tag", description="A tag for testing")

# Add items to the tag
item1 = tag.item("Item 1", description="First item")
item2 = tag.item("Item 2", description="Second item")

# Vote on items (flexible parameter ordering)
tag.vote(item1, item2, 25)  # Prefer item1 over item2 with magnitude 25
# OR
tag.vote(item1, 25, item2)  # Same result, different parameter order

# Get tag rankings
rankings = tag.rankings()

# Get sorted and unsorted items
sorted_items = rankings.sorted()
unsorted_items = rankings.unsorted()

# Get a voting pair
left_item, right_item = rankings.pair()

Client Options

The Sorter client accepts the following options:

  • vote_magnitude: Determines the scale for vote magnitudes
    • "equal" (default): Uses a scale from -50 to 50, where 0 is neutral
    • "positive": Uses a scale from 0 to 100, where 50 is neutral
  • verbose: Enables detailed logging including HTTP requests and responses
    • False (default): Normal logging (INFO level)
    • True: Detailed logging (DEBUG level)
  • quiet: Reduces logging to only warnings and errors
    • False (default): Normal logging (INFO level)
    • True: Reduced logging (WARNING level)
  • compatibility_warnings: Show API version compatibility warnings
    • True (default): Show warnings when API version might not be fully compatible
    • False: Suppress compatibility warnings
  • debug_http_full: Display the entire body of HTTP request / response objects.
    • False (default): Truncate long HTTP req/resp payloads.
    • True: Print full HTTP req/resp payloads. (will result in very long sysout)

Note: If both verbose and quiet are set to True, quiet takes precedence.

Features

  • Authenticate Sorter Client with API Key
  • Create & Manage Tags
  • Create & Utilize Items
  • Vote on Pairs (of Items) within Tags
  • Get Live Links to Tags or Items
  • Retrieve Rankings on Tags (Elo, Sorted Items, Unsorted Items)
  • Work with Multiple Attributes for Voting
  • Flexible Vote Magnitude Scales[^1]
  • Comprehensive Logging System
  • API Version Compatibility Checking

Working with Attributes

# Create an attribute
quality_attr = sorter.create_attribute("quality", "Quality of the item")

# Get an attribute by title
attr = sorter.get_attribute("quality")

# List all attributes
attributes = sorter.list_attributes()

# Vote with an attribute
tag.vote(item1, item2, 25, attribute=quality_attr.id)

# Get sorted items by attribute
sorted_by_quality = tag.sorted(attribute="quality")

Working with Rankings

# Get tag rankings
rankings = tag.rankings()

# Get sorted items
sorted_items = rankings.sorted()

# Get unsorted items
unsorted_items = rankings.unsorted()

# Get a voting pair
left_item, right_item = rankings.pair()

# Get skipped items
skipped_items = rankings.skipped()

# Get votes
votes = rankings.votes()

# Get users who voted
users = rankings.users_who_voted()

Logging

The SDK uses loguru for logging with a customized format:

12:34:56 | INFO     | sorterpy:__init__:42 - Sorter SDK initialized with base URL: https://sorter.social

The format includes:

  • Time (HH:MM:SS)
  • Log level
  • Abbreviated module name, function, and line number
  • Message

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

[^1]: This will be removed soon.

Project details


Download files

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

Source Distribution

sorterpy-0.2.5.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

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

sorterpy-0.2.5-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file sorterpy-0.2.5.tar.gz.

File metadata

  • Download URL: sorterpy-0.2.5.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for sorterpy-0.2.5.tar.gz
Algorithm Hash digest
SHA256 df8ec31f1062b5a3207b35dfd2bd805eee23cb41213edd5bf82f9baae5a998f9
MD5 6530e3545c6e1a56b9ec29dfd0080d09
BLAKE2b-256 2d387cf37bbe25d17de2c7929b9e74e061c08791bcaf56d2655490e47038040d

See more details on using hashes here.

File details

Details for the file sorterpy-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: sorterpy-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for sorterpy-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 97610df23307c9f5e1b39eff82bcd2ca3f2fc212ab685a9f0e91ecc752fdfbe0
MD5 28b4b4631623e35df9d9b8f122903cc2
BLAKE2b-256 4c3c330297efae2c3d56a37da0b9952b4a7aae16141937d711302a0090bc7115

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