Skip to main content

ivcap-service: Python SDK for Building IVCAP Batch Services

Coverity Scan Build Status

A Python library for building batch services on the IVCAP platform.

This SDK simplifies development of long-running, queue-based worker services that integrate with the IVCAP data and compute platform: typed Pydantic request/result models, automatic error handling, artifact upload/download, service composition, progress reporting, and export of logs/metrics/traces to observability platforms.

📖 Full documentation: ivcap-works.github.io/ivcap-service-sdk-python 🤖 Agent/LLM quick-reference: AGENTS.md

Table of Contents

Quick Start

pip install ivcap_service
from pydantic import BaseModel, Field
from ivcap_service import (
    Service, ServiceContact, ServiceLicense,
    JobContext, start_batch_service, getLogger, logging_init, with_schema,
)

logging_init()
logger = getLogger("app")

service = Service(
    name="My Batch Service",
    contact=ServiceContact(name="Your Name", email="you@example.com"),
    license=ServiceLicense(name="MIT", url="https://opensource.org/license/MIT"),
)

@with_schema("urn:sd:schema:my_service.request.1")
class Request(BaseModel):
    input_data: str = Field(description="The data to process")

@with_schema("urn:sd:schema:my_service.1")
class Result(BaseModel):
    output_data: str = Field(description="The processed result")

def process_job(req: Request, ctxt: JobContext) -> Result:
    """
    Process a job.

    This comprehensive description helps others understand what your service does.
    """
    with ctxt.report.step("processing", message="Starting work") as step:
        result = req.input_data.upper()  # Your logic here
        step.finished(message="Processing complete")

    return Result(output_data=result)

if __name__ == "__main__":
    start_batch_service(service, process_job)
# Test locally (job must be wrapped in the id/in-content-type/in-content envelope,
# see the Quick Start guide linked below)
python my_service.py --test-file test_job.json

# Print service metadata
python my_service.py --print-service-description

# Run the service (will wait for jobs)
python my_service.py

For everything else — JobContext, artifact management, service composition, error handling, observability/OpenTelemetry/OpenObserve, deployment, and best practices — see the full documentation:

Examples

This repository includes example services:

  • examples/test-batch/ - A complete batch service example with CPU load testing, error handling, and progress reporting. Start here to understand the patterns.
  • examples/test-api/ - Example service showing artifact interaction patterns.

Run the examples to see how they work:

cd examples/test-batch
python batch_service.py --print-service-description
python batch_service.py --test-file tests/req_1.json

Template Repository

Get started quickly with the community template:

git clone https://github.com/ivcap-works/ivcap-python-ai-tool-template.git
cd ivcap-python-ai-tool-template
# Follow the template's README

Maintenance & Development Guide

This section is for maintainers and developers working on the SDK itself.

Setup Development Environment

# Install the SDK and all development dependencies
make setup

# Or manually with Poetry
poetry config virtualenvs.in-project true --local
poetry install

Testing

Run the test suite:

# Run all tests with coverage
make test

# Or with Poetry directly
poetry run pytest tests/ --cov=ivcap_service --cov-report=xml

Code Quality

Maintain code quality standards:

# Run linting checks
make lint

# Run type checking
make typecheck

# Format code
make fmt

# Or run all checks together
make check    # Runs: lint + typecheck + test

Building

Build distribution packages:

# Build wheel and source distribution
make build

# Publish to PyPI (requires credentials configured in Poetry)
make publish

Documentation

The SDK includes comprehensive documentation built with MkDocs:

# Serve documentation locally (http://localhost:8000)
make docs-serve

# Build documentation static site
make docs

# Clean generated documentation
make docs-clean

Documentation Structure:

  • docs/docs/ - Source Markdown files organized by topic
  • docs/mkdocs.yml - MkDocs configuration
  • docs/site/ - Generated HTML (created when building)

Documentation includes:

  • Getting Started guides
  • Comprehensive feature guides
  • API reference
  • Working examples
  • Best practices and patterns
  • Environment variable reference

See docs/docs/community/contributing.md for documentation contribution guidelines.

Common Maintenance Tasks

Make targets for quick access:

make setup           # Initial setup
make check           # Validate code (lint + typecheck + test)
make fmt             # Format code
make docs-serve      # Preview documentation
make clean           # Remove build artifacts

Poetry tasks (via poethepoet):

poetry run poe lint        # Run ruff linting
poetry run poe format      # Run ruff formatting
poetry run poe typecheck   # Run pyright type checking
poetry run poe docs        # Build documentation
poetry run poe docs-serve  # Serve documentation
poetry run poe docs-clean  # Clean documentation

Release Process

  1. Update version in pyproject.toml
  2. Run make check to verify all tests pass
  3. Build: make build
  4. Publish: make publish (requires PyPI credentials)
  5. Update documentation if needed: make docs

Contributing

We welcome contributions! Please check CONTRIBUTING.md for guidelines.

License

See LICENSE and CONDUCT.md for details.

Metadata

Release files for ivcap_service 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ivcap_service 0.7.2
File Size Uploaded
ivcap_service-0.7.2.tar.gz 61.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ivcap_service 0.7.2
File Interpreter ABI Platform
ivcap_service-0.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 125.3 kB

Release files / ivcap_service-0.7.2.tar.gz

Download URL ivcap_service-0.7.2.tar.gz
Size 61.6 kB
Tags Source
SHA-256 checksum
How to use checksums
401cab526ff78af61b3b1342b4044c93f6ceca6036d0366d4557e2472482a5de
BLAKE2b-256 checksum
How to use checksums
c693dd277fc5ab69f1bf890f97f415b0641185082a85755516d15d340cae158a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.5 Darwin/24.6.0

Release files / ivcap_service-0.7.2-py3-none-any.whl

Download URL ivcap_service-0.7.2-py3-none-any.whl
Size 63.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7cc611d8237b728711119691b13fbb10afe09c5e101a2e8d91d00046b0de4818
BLAKE2b-256 checksum
How to use checksums
63d54dbc3fafa309ce72e25da614a26b2a1cf0f68f3634447f3c8ba560fa4397
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.5 Darwin/24.6.0

Release history Release notifications | RSS feed

This release

0.7.2 This release

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.24

2 release files

0.6.23

2 release files

0.6.22

2 release files

0.6.21

2 release files

0.6.20

2 release files

0.6.19

2 release files

0.6.18

2 release files

0.6.17

2 release files

0.6.12

2 release files

0.6.11

2 release files

0.6.8

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page