Let It Shine! Creating Shiny Dashboards from simple Python functions
Project description
Let It Shine!
Shiny Dashboards from Simple Python Mathematical Functions
letitshine is a Python Module and command line utility that creates an interactive Shiny from a function in a Python module. It tries to use sensible outputs based on the function definition and to be minimal so that the produced Python code can be used as a boilerplate. With the use of Shinilive for Python it can be further deployed to an interactive static app which is run entirely on the client (no server configuration necessary). It is aimed at users with a basic knowledge of Python but who are users of mathematical and computing libraries in Python and want to share their applications in teaching and research. It does not aim to replace Shiny but to encourage its use lowering the entry barrier.
There are many different possible outputs and inputs a Python can take. In letitshinewe focus on data types which are common in mathematical and data analysis functions. Presently letitshinesupports an arbitrary number of input arguments of the following types
Input types
- Boolean: produces a switch.
- Numeric (
int,float): generates input prompts or sliders. - Strings: generates input boxes and text areas.
and supports any of the following outputs
- String or Numerical output
- Strings with TeX support using KaTex.
- Pyplot plot
- Pandas Dataframes
The dependencies of the pure Python packageletitshine are minimal. It can be installed as a Pypi package
pip install letitshine
prefereably using a Python virtual environment. I you are only interested in the use of letitshine as a standalone app, consider
pipx install letitshine
To check the usage of letitshine take a simple hello world! example written in the the file text_output.py
def hello_world(your_name):
return f'Hello {your_name}, how are you?\n'
To create your Shiny app call
letitshine -type text -i text_output.hello_world --create_app
and this will create an app_hello_world.py file which can be rendered with Shiny (assuming Shiny is installed):
shiny run app_hello_world.py
and gives a simple Shiny interactive app
This file can be further custimized according to your needs and knowledge of Shiny. The idea of letitshineis to use sensible (opinonated) choices on outputs and inputs which are common in simple mathematical, computing and data apps and which can help beginners share and showcase their computations.
For instance, if we improve the previous simple function with types and docs, such as the say_hello function found in the examples:
def say_hello(your_name:str='Agnesi', say_today:bool=True):
r"""
What is your name?
In this simple app We simply print your name.
:param your_name: Name to be printed
:type your_name: str
:param say_today: Say today in the sentence?
:type say_today: bool
:return: Printed message
:rtype: str
Examples
===========
>>> say_hello('Descartes')
'Hello Descartes, how are you today?\n'
"""
message= f'Hello {your_name}, how are you today?\n' if say_today else f'Hello {your_name}, how are you?\n'
return message
and running the
letitshine -type txt,doc -i text_output.say_hello --create_app
we obtain,app_say_hello.py an interactive function for Shiny whose inputs are better suited
Authors
Joaquim Puig
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 letitshine-1.1.2.tar.gz.
File metadata
- Download URL: letitshine-1.1.2.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31336ae8c91ec7ad192028c73822b2e5a69538e6dd80653f5f5f77993147392e
|
|
| MD5 |
9ee1ecbbaff2bf8ad53d2ad4bf6eb2c0
|
|
| BLAKE2b-256 |
ed0534eba175efbb727a35fc70de83fe1b003d62a310a980e40f2b7c2d323b3e
|
File details
Details for the file letitshine-1.1.2-py3-none-any.whl.
File metadata
- Download URL: letitshine-1.1.2-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f044947e20b23b21bafb4b021c929c5a12a60362821a1e9bd082db3efbd60917
|
|
| MD5 |
b4c06ac423c41a34a2bb8f200ddd8172
|
|
| BLAKE2b-256 |
3a83c61744b885133383f326f3f09389b1f1e25f90aaa199025aee8a2fb8c9de
|