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 specificationsanimate(spec_file, data_file, svg_file, ...)- Create animationsexport(spec_file, definition, export_type, ...)- Export specificationsexemplify(spec_file, definition, n_points, ...)- Generate exampleshealth_check()- Check API availabilityversion()- Get API version
File Format Support
- Specifications:
.lilofiles - Data:
.csv,.json,.jsonlfiles - Visualizations:
.svgfiles
Requirements
- Python 3.12+
requests>=2.25.0urllib3>=1.26.0