Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AGA-WebUI #89

Merged
merged 48 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a477afe
first version of WEB-UI, Can run the aga, have issues with session state
Sep 5, 2024
8dd44a6
Merge branch 'autogluon:main' into streamlit-ui
tianyuanzoe Sep 5, 2024
ee5a075
can upload competition.txt file now
Sep 5, 2024
1f26e83
Merge branch 'streamlit-ui' of https://github.com/tianyuanzoe/autoglu…
Sep 5, 2024
077da4e
fixing the issues of uploaded filename disappear when users navigate …
Sep 5, 2024
ba27c98
fix the issues of download button disappear, also the task_file.txt a…
Sep 6, 2024
c35426c
make the run_autogluon_assistant() async
Sep 8, 2024
cfdc8f9
change log container to st.status()
Sep 9, 2024
467bc5d
add cancel_task button
Sep 10, 2024
a974583
preserve the log and status container between multiple pages,running …
Sep 13, 2024
4a2a358
split the file uploader
Sep 17, 2024
9775988
change the layout of task and preview page
Sep 20, 2024
b9c4d5f
before change the layout and stying to the wireframe style
Sep 23, 2024
c611fdb
version before adding the cookie
Sep 24, 2024
7e5dd6f
One page navigation
Sep 25, 2024
80b6ee9
Merge branch 'autogluon:main' into streamlit-ui
tianyuanzoe Sep 25, 2024
1778885
Merge branch 'streamlit-ui' of https://github.com/tianyuanzoe/autoglu…
Sep 25, 2024
08bea41
Merge branch 'autogluon:main' into streamlit-ui
tianyuanzoe Oct 1, 2024
9ca05f0
allow multi session
Oct 1, 2024
3b235cf
add docstring and change the logic of file uploader
Oct 4, 2024
0c4c08a
Merge branch 'autogluon:main' into streamlit-ui
tianyuanzoe Oct 14, 2024
4c52a55
Merge branch 'autogluon:main' into streamlit-ui
tianyuanzoe Oct 14, 2024
c37ab38
Merge branch 'autogluon:main' into streamlit-ui
tianyuanzoe Nov 6, 2024
15310ec
Merge pull request #1 from tianyuanzoe/streamlit-ui
tianyuanzoe Nov 6, 2024
365728e
add Autogluon-Assistant WebUI
Nov 6, 2024
67dde11
add linter
Nov 6, 2024
ae1038a
move some css
Nov 6, 2024
8afd703
remove fstring
Nov 6, 2024
591a3b2
add linter
Nov 6, 2024
243e491
sort import
Nov 6, 2024
fe6a44d
remove dataset, adding constants, preset select
Nov 8, 2024
ffe62df
Merge branch 'autogluon:main' into main
tianyuanzoe Nov 8, 2024
6088cdf
remove video
Nov 8, 2024
ca344fb
merge README,gitignore,pyproject.toml,move some css
Nov 8, 2024
0754b0a
add toast
Nov 8, 2024
797c816
delete dockerfile, change demo video and sample_dataset
Nov 9, 2024
3288397
use linter: delete dockerfile, change demo video and sample_dataset
Nov 9, 2024
1a3c754
remove video
Nov 9, 2024
3f52b29
Merge branch 'autogluon:main' into main
tianyuanzoe Nov 9, 2024
05e79a4
change READEME, remove unwanted file
Nov 9, 2024
d59ae72
Merge branch 'main' of https://github.com/tianyuanzoe/AGA-UI
Nov 9, 2024
3b280bf
fixing bugs: The widget with key _time_limit was created with a defau…
Nov 9, 2024
e45259b
remove debugging tool
Nov 9, 2024
220a3b6
avoid hash in output filename
AnirudhDagar Nov 9, 2024
f375265
output.csv as final filename
AnirudhDagar Nov 9, 2024
ae507e3
remove 1sec sleep after each log statement
AnirudhDagar Nov 9, 2024
e969366
rename WebUI to ui
AnirudhDagar Nov 9, 2024
275166f
remove unused import
AnirudhDagar Nov 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.aim/
AutogluonModels/
data/
user_data/
results/
cookies.json
cdk.out/
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,29 @@ aga ./data ./config --output-filename my_output.csv --config-overrides "autogluo
```

`autogluon-assistant-tools` provides more functionality and utilities for benchmarking, wrapped around autogluon-assistant. Please check out the [repo](https://github.com/autogluon/autogluon-assistant-tools/) for more details.

## Autogluon Assistant Web UI
The Autogluon Assistant Web UI is a user-friendly application that allows users to leverage the capabilities of the Autogluon-Assistant library through an intuitive web interface.

The web UI enables users to upload datasets, configure Autogluon-Assistant runs with customized settings, preview data, monitor execution progress, view and download results, and supports secure, isolated sessions for concurrent users.

#### To run the Autogluon Assistant Web UI:
Navigate to the project directory and run the app:
````
cd src/autogluon_assistant/WebUI && streamlit run app.py
````
The Autogluon Assistant Web UI should now be accessible in your web browser at `http://localhost:8501`

#### Add GPT4 Model to the LLM Option:
If you’d like to add additional GPT4 model to the language model (LLM) dropdown:

1. Navigate to src/autogluon_assistant/WebUI/constants.py

2. Locate the `LLM_OPTIONS` variable, which looks like this:
````
LLM_OPTIONS = ["Claude 3.5 with bedrock"]
````
3. Add "GPT 4" to the list
````
LLM_OPTIONS = ["Claude 3.5 with bedrock", "GPT 4"]
````
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ dependencies = [
"sentence-transformers>=3.1.0",
"tenacity>=8.2.2,<10.0",
"gensim>=4.3",
"pandas>=2.2"
"pandas>=2.2",
"stqdm==0.0.5",
"streamlit==1.37.1",
"streamlit-aggrid==1.0.5",
"streamlit-extras==0.4.7",
"psutil>=5.9.8",
]

[project.optional-dependencies]
Expand Down
46 changes: 46 additions & 0 deletions src/autogluon_assistant/WebUI/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# git
**/.git

# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]

# C extensions
*.so

# Virtual environment
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
*env/

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

user_data/
local/
results/
AutogluonModels/
.metaflow/

.mypy_cache
.pytest_cache
.ruff_cache
.logs
10 changes: 10 additions & 0 deletions src/autogluon_assistant/WebUI/.streamlit/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[server]
maxUploadSize = 4096
enableStaticServing = true
[theme]
primaryColor="#4C7DE7"
backgroundColor="#FFFFFF"
secondaryBackgroundColor="#fbfcfc"
textColor="#404040"
[client]
showSidebarNavigation = false
21 changes: 21 additions & 0 deletions src/autogluon_assistant/WebUI/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.10-slim

WORKDIR /app


RUN pip install -U pip \
&& pip install -U setuptools wheel

RUN apt-get -y update && \
apt-get install -y git

COPY . /app

RUN pip install .


EXPOSE 8501

WORKDIR /app/src

CMD ["streamlit", "run", "app.py"]
82 changes: 82 additions & 0 deletions src/autogluon_assistant/WebUI/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from copy import deepcopy

import streamlit as st
import streamlit.components.v1 as components
from constants import DEFAULT_SESSION_VALUES
from pages.demo import main as demo
from pages.feature import main as feature
from pages.nav_bar import nav_bar
from pages.preview import main as preview
from pages.task import main as run
from pages.tutorial import main as tutorial

st.set_page_config(
page_title="AutoGluon Assistant",
page_icon="https://pbs.twimg.com/profile_images/1373809646046040067/wTG6A_Ct_400x400.png",
layout="wide",
initial_sidebar_state="collapsed",
)

# fontawesome
st.markdown(
"""
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
""",
unsafe_allow_html=True,
)

# Bootstrap 4.1.3
st.markdown(
"""
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
""",
unsafe_allow_html=True,
)
with open("style.css") as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)


reload_warning = """
<script>
window.onbeforeunload = function () {

return "Are you sure want to LOGOUT the session ?";
};
</script>
"""

components.html(reload_warning, height=0)


def initial_session_state():
"""
Initial Session State
"""
for key, default_value in DEFAULT_SESSION_VALUES.items():
if key not in st.session_state:
st.session_state[key] = (
deepcopy(default_value) if isinstance(default_value, (dict, list)) else default_value
)


def main():
initial_session_state()
nav_bar()
tutorial()
demo()
feature()
run()
preview()

st.markdown(
"""
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
""",
unsafe_allow_html=True,
)


if __name__ == "__main__":
main()
95 changes: 95 additions & 0 deletions src/autogluon_assistant/WebUI/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from copy import deepcopy

BASE_DATA_DIR = "./user_data"


# Preset configurations
PRESET_DEFAULT_CONFIG = {
"Best Quality": {"time_limit": "4 hrs", "feature_generation": True},
"High Quality": {"time_limit": "1 hr", "feature_generation": False},
"Medium Quality": {"time_limit": "10 mins", "feature_generation": False},
}
DEFAULT_PRESET = "Best Quality"

PRESET_MAPPING = {
"Best Quality": "best_quality",
"High Quality": "high_quality",
"Medium Quality": "medium_quality",
}
PRESET_OPTIONS = ["Best Quality", "High Quality", "Medium Quality"]

# Time limit configurations (in seconds)
TIME_LIMIT_MAPPING = {
"1 min": 60,
"10 mins": 600,
"30 mins": 1800,
"1 hr": 3600,
"2 hrs": 7200,
"4 hrs": 14400,
}

DEFAULT_TIME_LIMIT = "4 hrs"

TIME_LIMIT_OPTIONS = ["1 min", "10 mins", "30 mins", "1 hr", "2 hrs", "4 hrs"]

# LLM configurations
LLM_MAPPING = {
"Claude 3.5 with bedrock": "anthropic.claude-3-5-sonnet-20241022-v2:0",
"GPT 4": "gpt-4o-mini-2024-07-18",
}

LLM_OPTIONS = ["Claude 3.5 with bedrock"]

# Provider configuration
PROVIDER_MAPPING = {"Claude 3.5 with bedrock": "bedrock", "GPT 4": "openai"}


API_KEY_LOCATION = {"Claude 3.5 with bedrock": "BEDROCK_API_KEY", "GPT 4": "OPENAI_API_KEY"}

INITIAL_STAGE = {
"Task Understanding": [],
"Feature Generation": [],
"Model Training": [],
"Prediction": [],
}
# Initial Session state
DEFAULT_SESSION_VALUES = {
"config_overrides": [],
"preset": DEFAULT_PRESET,
"time_limit": DEFAULT_TIME_LIMIT,
"llm": None,
"pid": None,
"logs": "",
"process": None,
"clicked": False,
"task_running": False,
"output_file": None,
"output_filename": None,
"task_description": "",
"sample_description": "",
"return_code": None,
"task_canceled": False,
"uploaded_files": {},
"sample_files": {},
"selected_dataset": None,
"sample_dataset_dir": None,
"description_uploader_key": 0,
"sample_dataset_selector": None,
"current_stage": None,
"feature_generation": True,
"stage_status": {},
"show_remaining_time": False,
"model_path": None,
"increment_time": 0,
"progress_bar": None,
"increment": 2,
"zip_path": None,
"stage_container": deepcopy(INITIAL_STAGE),
}


# DataSet Options
DATASET_OPTIONS = ["Sample Dataset", "Upload Dataset"]

# Captions under DataSet Options
CAPTIONS = ["Run with sample dataset", "Upload Train, Test and Output (Optional) Dataset"]
57 changes: 57 additions & 0 deletions src/autogluon_assistant/WebUI/file_uploader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os

import pandas as pd
import streamlit as st
from utils import get_user_data_dir


def save_description_file(description):
"""
Save the task description to a file in the user's data directory.

Args:
description (str): The task description to save.
"""
try:
user_data_dir = get_user_data_dir()
description_file = os.path.join(user_data_dir, "description.txt")
with open(description_file, "w") as f:
f.write(description)
except Exception as e:
print(f"Error saving file: {str(e)}")


def description_file_uploader():
"""
Handle Description file uploads
"""
uploaded_file = st.file_uploader(
"Upload task description file",
type="txt",
key=st.session_state.description_uploader_key,
help="Accepted file format: .txt",
label_visibility="collapsed",
)
if uploaded_file:
task_description = uploaded_file.read().decode("utf-8")
st.session_state.task_description = task_description
save_description_file(st.session_state.task_description)
st.session_state.description_uploader_key += 1
st.rerun()


def file_uploader():
"""
Handle file uploads
"""
st.markdown("#### Upload Dataset")
uploaded_files = st.file_uploader(
"Select the dataset", accept_multiple_files=True, label_visibility="collapsed", type=["csv", "xlsx"]
)
st.session_state.uploaded_files = {}
for file in uploaded_files:
if file.name.endswith(".csv"):
df = pd.read_csv(file)
elif file.name.endswith(".xlsx"):
df = pd.read_excel(file)
st.session_state.uploaded_files[file.name] = {"file": file, "df": df}
Loading
Loading