Streamlit-react-jsonschema
Streamlit component, building form by react-jsonschema-form.
This library is experimental for GhostOS yet.
Installation
install streamlit-react-jsonschema with pip
pip install streamlit_react_jsonschema
Example
see baseline example
from typing import Union, List, Dict
import streamlit as st
import streamlit_react_jsonschema as srj
import inspect
from pydantic import BaseModel, Field
class Student(BaseModel):
name: str = Field(description="name of the student")
level: int = Field(description="level of the student")
class SomeClass(BaseModel):
"""
test class of pydantic model Foo
"""
name: Union[str, None] = Field(None, description="filed with optional[str]")
age: int = Field(0, description="bar value")
some_float: float = Field(description="test about float value")
students: List[Student] = Field(default_factory=list, description="list of students")
students_dict: Dict[str, Student] = Field(default_factory=dict, description="dict of students")
st.title("Streamlit-react-jsonschema Example")
with st.expander("source code of the example pydantic class", expanded=True):
codes = inspect.getsource(SomeClass)
st.code(codes)
value, submitted = srj.pydantic_form(model=SomeClass)
st.subheader("result:")
st.write(f"submitted: {submitted}")
st.write(f"type of the result: {type(value)}")
st.write(value)
if isinstance(value, BaseModel):
st.write("model dump value")
st.write(value.model_dump(exclude_defaults=False))
How to run this example? Check streamlit first~
Dependencies
- Streamlit
- React-jsonschema-form: render the form from json schema
- Material UI : use
@rjsf/muitheme from thereact-jsonschema-form - pydantic : generate json schema
Metadata
Release files for streamlit_react_jsonschema 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| streamlit_react_jsonschema-0.1.6.tar.gz | 1.6 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| streamlit_react_jsonschema-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.1 MB
Release files / streamlit_react_jsonschema-0.1.6.tar.gz
| Download URL | streamlit_react_jsonschema-0.1.6.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d898501dbf1b9a0081b288ce03af3e398ce2ef6ec52e908aeff55dc3e935d8b3
|
|
BLAKE2b-256 checksum How to use checksums |
1d3906f39ba92c10a1e3ea8f9b81e4653f44a35e7ba3f33afcd26349235c01cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.6 Darwin/23.6.0
|
Release files / streamlit_react_jsonschema-0.1.6-py3-none-any.whl
| Download URL | streamlit_react_jsonschema-0.1.6-py3-none-any.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c585fea463620d7dfe259da7915c3d255d06d9379828e0ff16623797d2cd1c7
|
|
BLAKE2b-256 checksum How to use checksums |
e209b69a475b3660e750a484f965ebc6ddbe3d3edca37474ed3f94bb55793da0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.6 Darwin/23.6.0
|