YAML2ST automates streamlit input widgets from an uploaded YAML or JSON file. All key value pairs will be displayed as streamlit input widgets. You can then export the data changes via YAML or share a URL that contains the YAML file.
pip install YAML2ST
In a Python File
import streamlit as st
import YAML2ST as y2s
To Display YAML/JSON as Input Widgets
Use an UploadedFile type, e.g. a file from st.file_uploader()
, and the Streamlit instance in the location you would like the input widgets displayed, e.g. st.sidebar
, with the YAML2ST build()
method:
df = y2s.build(uploadedFile, st.sidebar)
build() will return a pandas DataFrame in which you can capture and display all input widget changes.
YAML2ST Dynamics
The Streamlit input widgets are dynamically manifested using a conditional order.
YAML & YAML2ST #FORCE
Should you wish to display the value of the parameter with a specific input widget, we have made that easy with the use of #FORCE:
next to the YAML parameter in the YAML file. You may also separate each #FORCE: option with |
(including the space before and after the pipe). This capability extends to all of the Streamlit input widget options as your options are taken literally if not recognized by YAML2ST.
Feature: Share With Link Feature
You may share a YAML file as a URL. During export() a special URL will be encoded. The domain of the URL, in the code, may need to be updated. YAML2URL uses a single URL parameter dubbed ‘YAML2URL’ to share all contents of a YAML, including comments and the Y2S #FORCE feature.
Consult GitHub for updated and further documentation.