A lightweight, extensible Python library for simulation, reporting, and web-based input/output. Includes automatic web UI, report generation, and support for custom simulators.
Project description
guilite
Et lettvekts Python-bibliotek for simulering, rapportgenerering og webbasert input/output.
Installasjon
Installer avhengigheter og biblioteket lokalt:
pip install .
Grunnleggende bruk
Definer dine egne simulator-klasser ved å arve fra SimulatorBase og implementere run og generate_report.
Eksempel (se også examples/mysimulator.py):
from typing import Type
from pydantic import BaseModel, Field
from reportgenerator.simulatorbase import SimulatorBase
from reportgenerator.engine import Engine
class MyInput(BaseModel):
x: float = Field(1.0, title="X-verdi")
y: float = Field(2.0, title="Y-verdi")
class MyResult(BaseModel):
sum: float = Field(..., title="Sum")
class MySimulator(SimulatorBase):
input_model = MyInput
result_model = MyResult
name = "Addisjon"
@staticmethod
def run(input_data: BaseModel) -> BaseModel:
data = input_data if isinstance(input_data, MyInput) else MyInput(**input_data.model_dump())
return MyResult(sum=data.x + data.y)
@staticmethod
def generate_report(input_data: BaseModel, result_data: BaseModel) -> str:
eng = Engine()
eng.write_header("Addisjon", level=2)
eng.write_model(input_data)
eng.write_model(result_data)
return eng.get_html()
Starte web-app med egne simulatorer
Se examples/run_simulator_app.py:
from reportgenerator.simulatorapp import SimulatorApp
from examples.mysimulator import MySimulator1, MySimulator2
if __name__ == "__main__":
simulators = {
"add": MySimulator1,
"mult": MySimulator2,
}
app = SimulatorApp(simulators=simulators)
app.run(debug=True)
Kjør fra prosjektroten:
python -m examples.run_simulator_app
Funksjoner
- Automatisk webgrensesnitt for input og rapport
- Støtte for flere simulatorer
- Input/rapport kan lastes opp/ned som JSON
- Brukeren trenger ikke forholde seg til Flask eller templates
Demo og eksempler
Se examples/-mappen for komplette demoer.
Lisens
MIT License. Se LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guilite-0.1.0.tar.gz.
File metadata
- Download URL: guilite-0.1.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc16e75755989d2951f7b44cf89d25fd89de777c1d3aea59198e03db41a216ee
|
|
| MD5 |
eb44ce275ae20f2982d056817eb6ae1f
|
|
| BLAKE2b-256 |
9cc75267ef01d65d66bde3dd5ff0755f202fe4b343f404da4966d0ff91c5fc3e
|
File details
Details for the file guilite-0.1.0-py3-none-any.whl.
File metadata
- Download URL: guilite-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d9202e2d83de52f69df6f3a4e9e2e57810dec7a1462851591fa4214316d52db
|
|
| MD5 |
bf4bd4b585e4052ce8d3fe45d6b42c44
|
|
| BLAKE2b-256 |
b4bf237670380f3f388549a92495dd4bd0e9edfd33a23f9e1d0e0d049350be42
|