SpecForge SDK Sample Project
This is a complete example demonstrating the SpecForge Python SDK capabilities.
Files
temperature_monitoring.lilo- Sample specification for temperature monitoringsensor_data.csv- Sample sensor data (31 data points with temperature and humidity)demo.ipynb- Jupyter notebook demonstrating all SDK featurestemperature_config.json- Configuration file (parameters) for the temperature monitoring exampleutil.lilo- Utility functions for the example
Setup
[!NOTE] Hereafter, we recommend users to open
sample_projectfolder with VSCode.
1. Create and Activate a Virtual Environment
It is generally recommended (but not mandatory) to do this in a virtual environment. To do so, follow these instructions:
# Navigate to the sample project directory
cd sample_project
# Create a virtual environment
python -m venv .venv
# Activate the virtual environment
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activate
2. Install Dependencies
# Install the SpecForge SDK Wheel
pip install ../specforge_sdk-xxx.whl
# Install additional dependencies for the sample project
pip install jupyter pandas matplotlib numpy
3. Verify Installation
# Check that the SDK is installed correctly
python -c "from specforge_sdk import SpecForgeClient; print('✓ SDK installed successfully')"
Running the Examples
Prerequisites
- Ensure SpecForge API server is running on
http://localhost:8080/health - Activate your virtual environment (if not already active):
# On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
Run the Examples
To check that the extension is working, execute the cells in demo.ipynb. The output of the monitoring commands should have a visualization.
You may need to make sure your notebook is connected to the correct Pyhton kernel. Often, it is .venv (Python3.X.X) or ipykernel. It can be configured from the VSCode notebook interface.
Sample Data Overview
The included sensor_data.csv contains:
- 31 time points (0.0 to 30.0)
- Temperature readings (20.8°C to 25.0°C)
- Humidity readings (40.9% to 51.5%)
This data is designed to test various specifications including temperature bounds, stability, and humidity correlation.
Deactivating the Environment
When you're done working with the sample project:
deactivate
Troubleshooting
Common Issues
- "Module not found" errors: Ensure the virtual environment is activated and the SDK is installed with
pip install ../specforge_sdk-xxx.whl - Connection refused: Make sure the SpecForge API server is running on
http://localhost:8080/health - Jupyter not found: Install it with
pip install jupyterin your activated virtual environment - Missing sample files: Ensure you're in the
sample_projectdirectory
Verify Setup
# Check Python environment
which python
pip list | grep specforge
# Test API connection
python -c "from specforge_sdk import SpecForgeClient; client = SpecForgeClient(); print('Health check:', client.health_check())"