S-Dreamer commited on
Commit
8ebb3ac
ยท
verified ยท
1 Parent(s): 031caeb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -61
app.py CHANGED
@@ -1,91 +1,92 @@
1
 
2
  import streamlit as st
3
- # Import the `set_page_config` and `display_sidebar` functions from the `utils` module.
4
- # These functions are responsible for setting up the Streamlit app's page configuration and displaying the sidebar, respectively.
5
  from utils import set_page_config, display_sidebar
6
  import os
7
 
8
- # Set the page configuration for the Streamlit app.
9
- # This function sets the app's title, icon, layout, and other parameters.
10
  set_page_config()
11
 
12
- # Display the main title of the Streamlit app.
13
  st.title("CodeGen Hub")
14
 
15
- # Display the description of the Streamlit app using Markdown formatting.
16
- # This provides a more formatted and readable way to present the app's purpose and features.
17
  st.markdown("""
18
  Welcome to CodeGen Hub - A platform for training and using code generation models with Hugging Face integration.
19
 
20
  ### Core Features:
21
- - Upload and preprocess Python code datasets for model training
22
- - Configure and train models with customizable parameters
23
- - Generate code predictions using trained models through an interactive interface
24
- - Monitor training progress with visualizations and detailed logs
25
- - Seamless integration with Hugging Face Hub for model management
26
 
27
  Navigate through the different sections using the sidebar menu.
28
  """)
29
 
30
- # Display the sidebar for the Streamlit app.
31
- # The sidebar will contain navigation options and other functionality.
32
- display_sidebar()
33
 
34
- # Create session state variables to store information across app pages.
35
- # These variables will persist data between user interactions.
36
- if 'datasets' not in st.session_state:
37
- # Initialize the 'datasets' dictionary in the session state.
38
- # This dictionary will store information about the uploaded datasets.
39
- st.session_state.datasets = {}
 
 
40
 
41
- if 'trained_models' not in st.session_state:
42
- # Initialize the 'trained_models' dictionary in the session state.
43
- # This dictionary will store information about the trained models.
44
- st.session_state.trained_models = {}
45
 
46
- if 'training_logs' not in st.session_state:
47
- # Initialize the 'training_logs' list in the session state.
48
- # This list will store the training logs for the models.
49
- st.session_state.training_logs = []
 
 
 
 
 
50
 
51
- if 'training_progress' not in st.session_state:
52
- # Initialize the 'training_progress' dictionary in the session state.
53
- # This dictionary will store the progress information for the training jobs.
54
- st.session_state.training_progress = {}
 
 
 
 
 
 
 
 
 
55
 
56
- # Display a "Getting Started" section with instructions for the user.
57
- st.subheader("Getting Started")
58
- col1, col2 = st.columns(2)
 
 
59
 
60
- with col1:
61
- # Display the first set of instructions in the left column.
62
- st.info("""
63
- 1. ๐Ÿ“Š Start by uploading or selecting a Python code dataset in the **Dataset Management** section.
64
- 2. ๐Ÿ› ๏ธ Configure and train your model in the **Model Training** section.
65
- """)
66
-
67
- with col2:
68
- # Display the second set of instructions in the right column.
69
- st.info("""
70
- 3. ๐Ÿ’ก Generate code predictions using your trained models in the **Code Generation** section.
71
- 4. ๐Ÿ”„ Access your models on Hugging Face Hub for broader use.
72
- """)
73
 
74
- # Display platform statistics if available.
75
  st.subheader("Platform Statistics")
76
  col1, col2, col3 = st.columns(3)
77
 
78
  with col1:
79
- # Display the number of datasets available.
80
- st.metric("Datasets Available", len(st.session_state.datasets))
81
-
82
  with col2:
83
- # Display the number of trained models.
84
- st.metric("Trained Models", len(st.session_state.trained_models))
85
-
86
  with col3:
87
- # Calculate the number of active training jobs.
88
- active_jobs = sum(1 for progress in st.session_state.training_progress.values()
89
- if progress.get('status') == 'running')
90
- # Display the number of active training jobs.
91
- st.metric("Active Training Jobs", active_jobs)
 
1
 
2
  import streamlit as st
 
 
3
  from utils import set_page_config, display_sidebar
4
  import os
5
 
6
+ # Set the Streamlit page configuration
 
7
  set_page_config()
8
 
9
+ # Display main app title
10
  st.title("CodeGen Hub")
11
 
12
+ # App description with markdown formatting
 
13
  st.markdown("""
14
  Welcome to CodeGen Hub - A platform for training and using code generation models with Hugging Face integration.
15
 
16
  ### Core Features:
17
+ - ๐Ÿ“‚ Upload and preprocess Python code datasets for model training
18
+ - ๐ŸŽ›๏ธ Configure and train models with customizable parameters
19
+ - ๐Ÿค– Generate code predictions using trained models through an interactive interface
20
+ - ๐Ÿ“Š Monitor training progress with visualizations and detailed logs
21
+ - ๐Ÿ”— Seamless integration with Hugging Face Hub for model management
22
 
23
  Navigate through the different sections using the sidebar menu.
24
  """)
25
 
26
+ # Sidebar navigation using session state
27
+ def navigate(page):
28
+ st.session_state["current_page"] = page
29
 
30
+ # Initialize session state variables using a loop
31
+ session_defaults = {
32
+ "datasets": {}, # Stores uploaded datasets
33
+ "trained_models": {}, # Stores trained model details
34
+ "training_logs": [], # Stores training logs
35
+ "training_progress": {}, # Tracks active training jobs
36
+ "current_page": "home" # Default landing page
37
+ }
38
 
39
+ for key, value in session_defaults.items():
40
+ if key not in st.session_state:
41
+ st.session_state[key] = value
 
42
 
43
+ # Display sidebar with navigation buttons
44
+ with st.sidebar:
45
+ st.header("Navigation")
46
+ if st.button("๐Ÿ—๏ธ Dataset Management"):
47
+ navigate("dataset_management")
48
+ if st.button("๐ŸŽฏ Model Training"):
49
+ navigate("model_training")
50
+ if st.button("๐Ÿ”ฎ Code Generation"):
51
+ navigate("code_generation")
52
 
53
+ # Render content dynamically based on session state
54
+ if st.session_state["current_page"] == "dataset_management":
55
+ st.subheader("Dataset Management")
56
+ st.write("Upload and manage your datasets here.")
57
+ elif st.session_state["current_page"] == "model_training":
58
+ st.subheader("Model Training")
59
+ st.write("Configure and train your models.")
60
+ elif st.session_state["current_page"] == "code_generation":
61
+ st.subheader("Code Generation")
62
+ st.write("Generate predictions using your trained models.")
63
+ else:
64
+ st.subheader("Getting Started")
65
+ col1, col2 = st.columns(2)
66
 
67
+ with col1:
68
+ st.info("""
69
+ 1. ๐Ÿ“Š Start by uploading or selecting a Python code dataset in the **Dataset Management** section.
70
+ 2. ๐Ÿ› ๏ธ Configure and train your model in the **Model Training** section.
71
+ """)
72
 
73
+ with col2:
74
+ st.info("""
75
+ 3. ๐Ÿ’ก Generate code predictions using your trained models in the **Code Generation** section.
76
+ 4. ๐Ÿ”„ Access your models on Hugging Face Hub for broader use.
77
+ """)
 
 
 
 
 
 
 
 
78
 
79
+ # Display platform statistics dynamically
80
  st.subheader("Platform Statistics")
81
  col1, col2, col3 = st.columns(3)
82
 
83
  with col1:
84
+ st.metric("๐Ÿ“‚ Datasets Available", len(st.session_state.get("datasets", {})))
85
+
 
86
  with col2:
87
+ st.metric("๐Ÿ“ฆ Trained Models", len(st.session_state.get("trained_models", {})))
88
+
 
89
  with col3:
90
+ active_jobs = sum(1 for progress in st.session_state["training_progress"].values()
91
+ if progress.get("status") == "running")
92
+ st.metric("๐Ÿš€ Active Training Jobs", active_jobs)