Skip to content

Instantly share code, notes, and snippets.

View asehmi's full-sized avatar

Arvindra Sehmi asehmi

View GitHub Profile
@asehmi
asehmi / multithreaded_processing_of_queued_data.py
Created November 27, 2023 19:14
Streamlit multi-threaded task execution, with queues
import time
import random
from queue import Queue
import threading
import streamlit as st
from streamlit.runtime.scriptrunner import add_script_run_ctx
pre_msgs = []
result_msgs = []
post_msgs = []
@asehmi
asehmi / session_state_callback_demos.py
Last active July 18, 2024 10:57
Streamlit widget session state and callbacks mini-tutorial
#
# This seems to be a common issue amongst new Streamlit users, so I wrote a mini-tutorial app to explain how widgets
# are used with initialized values and how to make them stick using session state and callbacks.
#
# There are three ways:
#
# (1) The most basic where the initial value is not given but the widget is always reset,
# (2) Where it’s initialized but there are issues getting the return value to stick, and finally
# (3) Overcoming all issues with session state and callbacks.
#
@asehmi
asehmi / streamlit_debug.py
Last active July 9, 2024 08:51
Handy script I made to help streamline Streamlit debugging
# How to use:
#
# [1] Ensure you have `debugpy` installed:
#
# > pip install debugpy
#
# [2] In your main streamlit app:
#
# import streamlit_debug
# streamlit_debug.set(flag=True, wait_for_client=True, host='localhost', port=8765)
@asehmi
asehmi / st_fixed_container.py
Created April 1, 2024 16:19 — forked from toolittlecakes/st_fixed_container.py
Sticky/fixed container for streamlit apps. Supports dynamic width change as well as dynamic color updates. Both top/bottom positions are available.
from typing import Literal
import streamlit as st
from streamlit.components.v1 import html
FIXED_CONTAINER_CSS = """
div[data-testid="stVerticalBlockBorderWrapper"]:has(div.fixed-container-{id}):not(:has(div.not-fixed-container)) {{
position: {mode};
width: inherit;
@asehmi
asehmi / stqdm-demo.py
Last active March 25, 2024 18:44
STqdm: A tqdm-like progress bar for Streamlit
# UPDATED: 5-MAY-2023
from multiprocessing import Pool, freeze_support
from time import sleep
import streamlit as st
# https://discuss.streamlit.io/t/stqdm-a-tqdm-like-progress-bar-for-streamlit/10097
# pip install stqdm
from stqdm import stqdm
@asehmi
asehmi / df_flexi_query.py
Last active February 13, 2024 16:49
Flexible data filtering UI with declarative query builder [Streamlit, Pandas]
import streamlit as st
import pandas as pd
st.header('Flexible Data Filtering UI')
data = [
{
'name':'name1',
'nickname':'nickname1',
'date':2010,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@asehmi
asehmi / topic-models-v4.ipynb
Created January 23, 2024 07:45 — forked from pszemraj/topic-models-v4.ipynb
Topic Models - v4.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@asehmi
asehmi / v-diffusion-art.ipynb
Created January 23, 2024 07:44 — forked from pszemraj/v-diffusion-art.ipynb
v-diffusion-art
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.