[email protected] commited on
Commit
51b84b9
Β·
1 Parent(s): 60e5fc6

πŸ“ Reorganize project structure: Move UI files to dedicated directory

Browse files

- Move app.py, config_page.py, optimization_results.py to ui/ directory
- Create proper UI package structure with pages/ and components/ subdirectories
- Update all import paths to reflect new structure
- Add main.py as new project entry point
- Update README.md with new project structure documentation
- Preserve Git history using git mv for all file moves
- Maintain separation of concerns: UI logic in ui/, business logic in src/
- Improve project maintainability and scalability

README.md CHANGED
@@ -5,10 +5,85 @@ colorFrom: blue
5
  colorTo: green
6
  sdk: streamlit
7
  sdk_version: "1.28.0"
8
- app_file: app.py
9
  pinned: false
10
  ---
11
 
12
  # Supply Roster Optimization
13
 
14
- This is a Streamlit application for optimizing supply roster management with improved code readability.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  colorTo: green
6
  sdk: streamlit
7
  sdk_version: "1.28.0"
8
+ app_file: ui/app.py
9
  pinned: false
10
  ---
11
 
12
  # Supply Roster Optimization
13
 
14
+ A comprehensive Streamlit application for optimizing supply roster management using OR-Tools with improved code organization and readability.
15
+
16
+ ## πŸš€ Quick Start
17
+
18
+ ### Option 1: Using Main Entry Point (Recommended)
19
+ ```bash
20
+ python main.py
21
+ ```
22
+
23
+ ### Option 2: Direct Streamlit Command
24
+ ```bash
25
+ streamlit run ui/app.py
26
+ ```
27
+
28
+ ## πŸ“ Project Structure
29
+
30
+ ```
31
+ SD_roster_real/
32
+ β”œβ”€β”€ main.py # Main entry point
33
+ β”œβ”€β”€ README.md
34
+ β”œβ”€β”€ requirements.txt
35
+ β”œβ”€β”€ docker-compose.yaml
36
+ β”œβ”€β”€ setup.py
37
+ β”‚
38
+ β”œβ”€β”€ src/ # Core business logic
39
+ β”‚ β”œβ”€β”€ config/ # Configuration management
40
+ β”‚ β”‚ β”œβ”€β”€ constants.py
41
+ β”‚ β”‚ β”œβ”€β”€ optimization_config.py
42
+ β”‚ β”‚ └── paths.yaml
43
+ β”‚ β”œβ”€β”€ models/ # Optimization models
44
+ β”‚ β”‚ └── optimizer_real.py
45
+ β”‚ β”œβ”€β”€ preprocess/ # Data preprocessing
46
+ β”‚ β”‚ β”œβ”€β”€ data_preprocess.py
47
+ β”‚ β”‚ β”œβ”€β”€ extract.py
48
+ β”‚ β”‚ β”œβ”€β”€ transform.py
49
+ β”‚ β”‚ └── ...
50
+ β”‚ └── visualization/ # Chart generation
51
+ β”‚ β”œβ”€β”€ hierarchy_dashboard.py
52
+ β”‚ └── kit_relationships.py
53
+ β”‚
54
+ β”œβ”€β”€ ui/ # Streamlit UI components
55
+ β”‚ β”œβ”€β”€ app.py # Main Streamlit app
56
+ β”‚ β”œβ”€β”€ pages/ # Page components
57
+ β”‚ β”‚ β”œβ”€β”€ config_page.py # Settings page
58
+ β”‚ β”‚ β”œβ”€β”€ optimization_results.py # Results page
59
+ β”‚ β”‚ └── __init__.py
60
+ β”‚ β”œβ”€β”€ components/ # Reusable UI components
61
+ β”‚ β”‚ └── __init__.py
62
+ β”‚ └── __init__.py
63
+ β”‚
64
+ β”œβ”€β”€ data/ # Data files
65
+ β”œβ”€β”€ notebook/ # Jupyter notebooks
66
+ └── venv/ # Virtual environment
67
+ ```
68
+
69
+ ## πŸ”§ Features
70
+
71
+ - **Multi-page Interface**: Clean separation of settings, results, and validation
72
+ - **Real-time Optimization**: OR-Tools powered workforce scheduling
73
+ - **Data Validation**: Comprehensive demand data validation and visualization
74
+ - **Cost Analysis**: Detailed cost breakdown and analysis
75
+ - **Hierarchy Management**: Kit dependency tracking and visualization
76
+ - **Flexible Configuration**: Extensive parameter customization
77
+
78
+ ## πŸ“Š Usage
79
+
80
+ 1. **Settings Page**: Configure optimization parameters, workforce limits, and cost rates
81
+ 2. **Optimization Results**: View detailed results with charts and analysis
82
+ 3. **Demand Validation**: Validate input data and identify potential issues
83
+
84
+ ## πŸ› οΈ Development
85
+
86
+ The project follows a clean architecture with:
87
+ - **Separation of Concerns**: UI logic separated from business logic
88
+ - **Modular Design**: Reusable components and clear interfaces
89
+ - **Git-friendly**: Proper file organization with preserved Git history
main.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Supply Roster Optimization Tool - Main Entry Point
4
+ Run this file to start the Streamlit application
5
+ """
6
+
7
+ import sys
8
+ import os
9
+ import subprocess
10
+
11
+ def main():
12
+ """Main entry point for the Supply Roster Optimization Tool"""
13
+
14
+ # Get the directory where this script is located
15
+ project_root = os.path.dirname(os.path.abspath(__file__))
16
+
17
+ # Add project root to Python path
18
+ sys.path.insert(0, project_root)
19
+
20
+ # Path to the Streamlit app
21
+ app_path = os.path.join(project_root, 'ui', 'app.py')
22
+
23
+ # Check if the app file exists
24
+ if not os.path.exists(app_path):
25
+ print(f"❌ Error: Could not find app.py at {app_path}")
26
+ print("Please ensure the project structure is correct.")
27
+ sys.exit(1)
28
+
29
+ print("πŸš€ Starting Supply Roster Optimization Tool...")
30
+ print(f"πŸ“ Project root: {project_root}")
31
+ print(f"🎯 App path: {app_path}")
32
+ print("🌐 Opening in browser...")
33
+
34
+ # Run Streamlit
35
+ try:
36
+ subprocess.run([
37
+ sys.executable, '-m', 'streamlit', 'run', app_path,
38
+ '--server.headless', 'false',
39
+ '--server.address', 'localhost',
40
+ '--server.port', '8501'
41
+ ], cwd=project_root)
42
+ except KeyboardInterrupt:
43
+ print("\nπŸ‘‹ Application stopped by user")
44
+ except Exception as e:
45
+ print(f"❌ Error starting application: {e}")
46
+ sys.exit(1)
47
+
48
+ if __name__ == "__main__":
49
+ main()
ui/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ """
2
+ UI Package for Supply Roster Optimization Tool
3
+ Contains all Streamlit interface components
4
+ """
app.py β†’ ui/app.py RENAMED
@@ -6,9 +6,11 @@ Simplified version with configuration and optimization results
6
  import streamlit as st
7
  import sys
8
  import os
9
-
 
 
10
  # Add src directory to path for imports
11
- sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
12
 
13
  # Set page config
14
  st.set_page_config(
@@ -32,16 +34,13 @@ page = st.sidebar.selectbox(
32
  # Main app content
33
  if page == "βš™οΈ Settings":
34
  # Import and render the config page
35
- from config_page import render_config_page
36
-
37
  st.title("πŸ“¦ Supply Roster Optimization Tool")
38
  st.markdown("---")
39
-
40
  render_config_page()
41
 
42
  elif page == "πŸ“Š Optimization Results":
43
  # Import and render the optimization results page
44
- from optimization_results import display_optimization_results
45
 
46
  # Check if we have results in session state
47
  if 'optimization_results' in st.session_state and st.session_state.optimization_results:
@@ -64,7 +63,7 @@ elif page == "πŸ“Š Optimization Results":
64
  elif page == "πŸ“‹ Demand Validation":
65
  # Import and render the demand validation page
66
  try:
67
- from src.demand_validation_viz import display_demand_validation
68
 
69
  st.title("πŸ“‹ Demand Data Validation")
70
  st.markdown("---")
 
6
  import streamlit as st
7
  import sys
8
  import os
9
+ from ui.pages.config_page import render_config_page
10
+ from ui.pages.optimization_results import display_optimization_results
11
+ from src.demand_validation_viz import display_demand_validation
12
  # Add src directory to path for imports
13
+ sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))
14
 
15
  # Set page config
16
  st.set_page_config(
 
34
  # Main app content
35
  if page == "βš™οΈ Settings":
36
  # Import and render the config page
 
 
37
  st.title("πŸ“¦ Supply Roster Optimization Tool")
38
  st.markdown("---")
 
39
  render_config_page()
40
 
41
  elif page == "πŸ“Š Optimization Results":
42
  # Import and render the optimization results page
43
+
44
 
45
  # Check if we have results in session state
46
  if 'optimization_results' in st.session_state and st.session_state.optimization_results:
 
63
  elif page == "πŸ“‹ Demand Validation":
64
  # Import and render the demand validation page
65
  try:
66
+
67
 
68
  st.title("πŸ“‹ Demand Data Validation")
69
  st.markdown("---")
ui/components/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ """
2
+ UI Components Package
3
+ Contains reusable UI components for the Streamlit app
4
+ """
ui/pages/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ """
2
+ UI Pages Package
3
+ Contains individual page components for the Streamlit app
4
+ """
config_page.py β†’ ui/pages/config_page.py RENAMED
@@ -11,7 +11,7 @@ from src.config import optimization_config
11
  from src.config.constants import ShiftType, LineType
12
 
13
  # Add src directory to path for imports
14
- sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))
15
 
16
  def render_config_page():
17
  """Render the configuration page with all user input controls"""
@@ -1174,5 +1174,5 @@ def check_critical_data_issues():
1174
 
1175
  def display_optimization_results(results):
1176
  """Import and display optimization results"""
1177
- from optimization_results import display_optimization_results as display_results
1178
  display_results(results)
 
11
  from src.config.constants import ShiftType, LineType
12
 
13
  # Add src directory to path for imports
14
+ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'src'))
15
 
16
  def render_config_page():
17
  """Render the configuration page with all user input controls"""
 
1174
 
1175
  def display_optimization_results(results):
1176
  """Import and display optimization results"""
1177
+ from ui.pages.optimization_results import display_optimization_results as display_results
1178
  display_results(results)
optimization_results.py β†’ ui/pages/optimization_results.py RENAMED
File without changes