Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SpecForge Python SDK

The SpecForge python SDK is used for interacting with the SpecForge API, enabling formal specification monitoring, animation, export, and exemplification.

Installation

From Source

cd tools/python
pip install -e .

From the Wheel File

Locate the wheel file with the name specforge_sdk-x.x.x-py3-none-any.whl and install it using pip:

pip install path/to/specforge_sdk-0.5.0-py3-none-any.whl

Quick Start

from specforge_sdk import SpecForgeClient

# Initialize client
client = SpecForgeClient(base_url="http://localhost:8080")

# Check API health
if client.health_check():
    print("✓ Connected to SpecForge API")
    print(f"API Version: {client.version()}")
else:
    print("✗ Cannot connect to SpecForge API")

Core Features

The SDK provides access to core SpecForge capabilities:

  • Monitoring: Check specifications against data
  • Animation: Create visualizations over time
  • Export: Convert specifications to different formats
  • Exemplification: Generate example data that satisfies specifications

Documentation

See the comprehensive demo notebook at sample-project/demo.ipynb for:

  • Detailed usage examples
  • Jupyter notebook integration
  • Custom rendering features
  • Error handling patterns
  • Complete API reference

API Methods

  • monitor(spec_file, definition, data_file, ...) - Monitor specifications
  • animate(spec_file, data_file, svg_file, ...) - Create animations
  • export(spec_file, definition, export_type, ...) - Export specifications
  • exemplify(spec_file, definition, n_points, ...) - Generate examples
  • health_check() - Check API availability
  • version() - Get API version

File Format Support

  • Specifications: .lilo files
  • Data: .csv, .json, .jsonl files
  • Visualizations: .svg files

Requirements

  • Python 3.12+
  • requests>=2.25.0
  • urllib3>=1.26.0