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

Kjøre eksempler

Du kan kjøre eksemplene på flere måter:

1. Fra prosjektroten (anbefalt):

python -m guilite.examples.run_webapp

2. Med CLI-kommando (hvis satt opp):

guilite-demo

3. Kopier eksempelfilen til ønsket katalog: Kopier f.eks. guilite/examples/run_webapp.py til din egen mappe og juster imports til å bruke guilite.-stien.

Se README og dokumentasjon for flere detaljer.

guilite

Et lettvekts Python-bibliotek for simulering, rapportgenerering og webbasert input/output.

Installasjon

Installer fra PyPI:

pip install guilite

Eller for lokal utvikling:

pip install .

Grunnleggende bruk

Definer dine egne simulator-klasser ved å arve fra guilite.reportgenerator.SimulatorBase og implementere run og generate_report.

Eksempel (se også guilite/examples/mysimulator.py):

from pydantic import BaseModel, Field
from guilite.reportgenerator.simulatorbase import SimulatorBase
from guilite.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 guilite/examples/run_webapp.py:

from guilite.reportgenerator.simulatorapp import SimulatorApp
from guilite.examples.add_and_multiply_simulators 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 guilite.examples.run_webapp

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.

PyPI

https://pypi.org/project/guilite/

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.2.tar.gz (16.5 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.2-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: guilite-0.1.2.tar.gz
  • Upload date:
  • Size: 16.5 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.2.tar.gz
Algorithm Hash digest
SHA256 fa855dcd0baf69dbbf2b668e4cc1d2f8d1fb5d6a777d42d5a410d086a27e279e
MD5 71c61f52d3d34a7eaac17599d6e39a2d
BLAKE2b-256 37aeae91e7245996bbd69c654d5e233f459553726800060353987be3cb6b8a9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: guilite-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 20.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4e8b6f48779325a4e4516604f457444d49a1d003a2244c1a2f9ac74ad5a44400
MD5 d099bf4c085d9c7a567265861bce8698
BLAKE2b-256 f3c2e705221900e4f8679d38bc2a8ac9210f94b0d29fbd7c1d47b74e83cb6ea7

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