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

git clone https://codeberg.org/joaquimpuig/python-letitshine.git 
pip install -e letitshine

prefereably using a Python virtual environment. It will soon be available as a Python package through Pypi.

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.0.tar.gz (22.5 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.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: letitshine-1.1.0.tar.gz
  • Upload date:
  • Size: 22.5 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.0.tar.gz
Algorithm Hash digest
SHA256 74c805f33868e0144b8b034687c9b244aedfba5b81a5d6e09d19afd44544655e
MD5 3ec9e5829b02223e209d59bacb57abd8
BLAKE2b-256 f182aed2bccbfde72c7efc87f8468330c267cc93e81620430b5f2b1f4da95626

See more details on using hashes here.

File details

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

File metadata

  • Download URL: letitshine-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc27b69084b2cd37d2315b4763118a7d6ce706d5251bbdd1e6add6b809dfecec
MD5 d261cf02b4bfc5a97de027fc5b4f7334
BLAKE2b-256 d271691099afa5e039220f7330cf5c572ba53d88540f642c5c97e54929fd860a

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