-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.py
105 lines (90 loc) · 3.25 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""
AI Model Training & Deployment Web Application
This application provides a web interface for managing AI model training pipelines,
including dataset management, model training, optimization, and deployment.
Key Features:
- Authentication and user management
- Project management
- Dataset handling
- Model training and management
- Model optimization
- Experiment tracking
- Model deployment
- System monitoring
- Dashboard visualization
Dependencies:
- Flask: Web framework for the application
- PyTorch Lightning: For deep learning model training
- TensorBoard: For training visualization
- PyYAML: For configuration management
"""
import os
import importlib
import yaml
import time
import logging
import pytorch_lightning as pl
from torch.utils.data import DataLoader
from pytorch_lightning.loggers import TensorBoardLogger
from pytorch_lightning.strategies import DDPStrategy
from flask import Flask, session, render_template, request, redirect, url_for, send_from_directory
from auth import auth, login_required
from project import project
from dashboard import dashboard
# from tasks import tasks
from models import models
from runs import runs
from datasets import dataset
from optimize import optimizations
from monitor import monitor_bp
from deploy import deploy_bp
# Initialize Flask application
app = Flask(__name__, static_url_path='/static')
# Register blueprints for different modules
app.register_blueprint(auth, url_prefix='/auth') # Authentication routes
app.register_blueprint(project, url_prefix='/project') # Project management
app.register_blueprint(dataset, url_prefix='/datasets') # Dataset management
app.register_blueprint(models, url_prefix='/models') # Model management
app.register_blueprint(optimizations, url_prefix='/optimizations') # Model optimization
app.register_blueprint(runs, url_prefix='/runs') # Experiment tracking
app.register_blueprint(monitor_bp, url_prefix='/monitor') # System monitoring
app.register_blueprint(dashboard, url_prefix='/dashboard') # Dashboard visualization
app.register_blueprint(deploy_bp, url_prefix='/deploy') # Model deployment
# Application configuration
app.secret_key = 'SECRET_KEY_!!!'
app.config['SECRET_KEY'] = app.secret_key # for debugging tool
@app.route('/')
@login_required
def root():
"""Root endpoint that redirects to dashboard.
Returns:
redirect: Redirects to the dashboard root page
"""
return redirect(url_for('dashboard.root'))
@app.route('/<path:path>')
def static_proxy(path):
"""Serve static files.
Args:
path (str): Path to the static file
Returns:
file: The requested static file
"""
return app.send_static_file(path)
@app.route('/favicon.ico')
def favicon():
"""Serve favicon.ico file.
Returns:
file: The favicon.ico file
str: Empty string with 204 status if favicon not found
"""
try:
return send_from_directory(
os.path.join(app.root_path, 'static', 'images'),
'favicon.ico',
mimetype='image/vnd.microsoft.icon'
)
except Exception as e:
app.logger.error(f"Error serving favicon: {str(e)}")
return '', 204
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5001)