Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
from utils import set_page_config, display_sidebar
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
# Set page configuration
|
|
|
|
| 6 |
set_page_config()
|
| 7 |
|
| 8 |
-
#
|
| 9 |
st.title("CodeGen Hub")
|
|
|
|
|
|
|
|
|
|
| 10 |
st.markdown("""
|
| 11 |
Welcome to CodeGen Hub - A platform for training and using code generation models with Hugging Face integration.
|
| 12 |
|
|
@@ -20,52 +27,66 @@ st.markdown("""
|
|
| 20 |
Navigate through the different sections using the sidebar menu.
|
| 21 |
""")
|
| 22 |
|
| 23 |
-
# Display sidebar
|
|
|
|
| 24 |
display_sidebar()
|
| 25 |
|
| 26 |
-
# Create
|
|
|
|
| 27 |
if 'datasets' not in st.session_state:
|
|
|
|
|
|
|
| 28 |
st.session_state.datasets = {}
|
| 29 |
|
| 30 |
if 'trained_models' not in st.session_state:
|
|
|
|
|
|
|
| 31 |
st.session_state.trained_models = {}
|
| 32 |
|
| 33 |
if 'training_logs' not in st.session_state:
|
|
|
|
|
|
|
| 34 |
st.session_state.training_logs = []
|
| 35 |
|
| 36 |
if 'training_progress' not in st.session_state:
|
|
|
|
|
|
|
| 37 |
st.session_state.training_progress = {}
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
# Display getting started card
|
| 42 |
st.subheader("Getting Started")
|
| 43 |
col1, col2 = st.columns(2)
|
| 44 |
|
| 45 |
with col1:
|
|
|
|
| 46 |
st.info("""
|
| 47 |
1. π Start by uploading or selecting a Python code dataset in the **Dataset Management** section.
|
| 48 |
2. π οΈ Configure and train your model in the **Model Training** section.
|
| 49 |
""")
|
| 50 |
|
| 51 |
with col2:
|
|
|
|
| 52 |
st.info("""
|
| 53 |
3. π‘ Generate code predictions using your trained models in the **Code Generation** section.
|
| 54 |
4. π Access your models on Hugging Face Hub for broader use.
|
| 55 |
""")
|
| 56 |
|
| 57 |
-
# Display platform statistics if available
|
| 58 |
st.subheader("Platform Statistics")
|
| 59 |
col1, col2, col3 = st.columns(3)
|
| 60 |
|
| 61 |
with col1:
|
|
|
|
| 62 |
st.metric("Datasets Available", len(st.session_state.datasets))
|
| 63 |
|
| 64 |
with col2:
|
|
|
|
| 65 |
st.metric("Trained Models", len(st.session_state.trained_models))
|
| 66 |
|
| 67 |
with col3:
|
| 68 |
-
# Calculate active training jobs
|
| 69 |
active_jobs = sum(1 for progress in st.session_state.training_progress.values()
|
| 70 |
if progress.get('status') == 'running')
|
|
|
|
| 71 |
st.metric("Active Training Jobs", active_jobs)
|
|
|
|
|
|
| 1 |
+
```python
|
| 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 |
|
|
|
|
| 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)
|
| 92 |
+
```
|