Skip to main content

Let It Shine! Creating Shiny Dashboards from simple Python functions

Project description

license CodeBerg

Let It Shine!

Shiny Dashboards from Simple Python Mathematical Functions

Creating Simple Shiny apps

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

Simple Hello world screenshot

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

Say Hello screenshot

Authors

Joaquim Puig

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

letitshine-1.1.1.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

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

letitshine-1.1.1-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file letitshine-1.1.1.tar.gz.

File metadata

  • Download URL: letitshine-1.1.1.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

Hashes for letitshine-1.1.1.tar.gz
Algorithm Hash digest
SHA256 5b4203b2f35113e93e452a82836e95c5d54eedf724ac84b4d6199bff6e453e68
MD5 61cb4c69aa0376d6932ef0ee27e0025a
BLAKE2b-256 5d53fb689590413cc3e2853a127caabe192b3e1c35ff8956874b2f0a2cf03596

See more details on using hashes here.

File details

Details for the file letitshine-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: letitshine-1.1.1-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

Hashes for letitshine-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 063af432d2bcf976ecc127bd1ed698c927f452e2cc746f703e9c697af000ef6c
MD5 21dbd704209d684f45c3341d9d3f3222
BLAKE2b-256 707a123b8e18e9f68541423d361666aa85c313afb212d08f88fd657e91b9b229

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