import os
import typing

import streamlit as st

from kiara import Kiara
from kiara_modules.playground.markus.streamlit import (
    find_all_aliases_of_type,
    init_session,
    onboard_file,
)

# we'll use a pipeline description here, instead of a Python kiara module name
pipeline_file = os.path.join(os.path.dirname(__file__), "..", "..",
                             "pipelines", "create_graph_from_tables.json")
kiara_obj, workflow = init_session(st, module_type=pipeline_file)

st.title("Kiara/streamlit experiment - create a network graph")


def table_mgmt(kiara: Kiara):

    fp = st.sidebar.file_uploader("Import table(s) from csv file(s)",
                                  type=["csv"],
                                  accept_multiple_files=True)
    if fp:
        onboard_file(kiara=kiara, st=st, uploaded_file=fp)

    st.sidebar.write("## All your tables:")
    all_table_aliases = find_all_aliases_of_type(kiara, value_type="table")
    if not all_table_aliases:
st.title("Kiara/streamlit experiment - Topic modelling")

# This is the workflow we are going to use, check out the json file for details.
workflow_file = os.path.join(os.path.dirname(__file__), "..", "..",
                             "pipelines", "topic_modeling_end_to_end.json")
# this is a preparation step that:
#  - creates the kiara session
#  - creates a workflow from our json file
#  - saves the workflow object in the streamlit session state object
#
# The last step is useful, because a kiara workflow handles the workflow state itself (e.g. keeping already processed
# results in memory, only re-compute certain steps if relevant inputs have changed, etc.
# This means that we don't need (or want) streamlit to get in the way with its own caching (although in some cases we'll
# take advantage of that too.
kiara, workflow = init_session(st, module_type=workflow_file)

# the variable that holds the user input that points to the folder that contains the txt files/corpus.
path = None
with st.form(key="create_graph"):
    path = st.text_input("Path to corpus")
    load_path = st.form_submit_button(label="Load corpus")

# setting up some input controls on the sidebar
# compute coherence and num_topic are not used at the moment because of some bug with spacy (or gensim -- not sure)
languages = st.sidebar.multiselect("Languages",
                                   ["german", "italian", "english"])
# compute_coherence = st.sidebar.checkbox("Compute coherence", value=False)
# num_topics = st.sidebar.slider("Num topic", min_value=1, value=7, max_value=20)

# if no path was specified, it makes no sense to continue
Exemplo n.º 3
0

import streamlit as st

from kiara_modules.playground.markus.streamlit import (
    find_all_aliases_of_type,
    init_session,
    onboard_file,
    set_workflow_input,
)

st.title("Kiara/streamlit experiment: simple sql query")

# initialize kiar workflow and store it in the streamlit session state
module_type = "table.query.sql"
kiara, workflow = init_session(st, module_type=module_type)

# add a file import widget, so users can import files if their kiara data store is empty
fp = st.file_uploader(
    label="Onboard table data (.csv)", type=["csv"], accept_multiple_files=True
)
if fp:
    onboard_file(kiara=kiara, st=st, uploaded_file=fp)

selected_alias = st.selectbox(
    "Select dataset", find_all_aliases_of_type(kiara, value_type="table")
)

if not selected_alias:
    st.stop()