Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

guilite-0.1.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

guilite-0.1.1-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file guilite-0.1.1.tar.gz.

File metadata

  • Download URL: guilite-0.1.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for guilite-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cca5f77b640622b5227af127dfd632d3b7cc903b6af2bc6bf6a3dee62bc68d9b
MD5 eae802c39bc2663e206992393d467224
BLAKE2b-256 15a6e1a207dbcdf83686e6a970e4c0b7c243c8a37257be7c10dfa9e367156a72

See more details on using hashes here.

File details

Details for the file guilite-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: guilite-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for guilite-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 77222bb28faf2f8495c76a90778e9870eaef3834601efe792e0d2f27a5ec9c58
MD5 5d774be2788e79bc96a6697d6be6b6a0
BLAKE2b-256 6ce8649ad37fd2180012145963a97392ff047a0c82af99e9c8fa865389a294dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page