-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·136 lines (112 loc) · 4.45 KB
/
install.sh
File metadata and controls
executable file
·136 lines (112 loc) · 4.45 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# Model-FP Installation Script (using uv and venv)
# Installs the model-fp package with CLI tool using uv and venv
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Logging functions
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Helper functions
check_command() {
command -v "$1" >/dev/null 2>&1
}
# Print banner
echo -e "${BLUE}"
echo "╔═══════════════════════════════════════════╗"
echo "║ 🔍 Model-FP Installation 🔍 ║"
echo "║ Installing model-fp package and CLI ║"
echo "╚═══════════════════════════════════════════╝"
echo -e "${NC}"
# Check if we're in the right directory
if [ ! -f "pyproject.toml" ]; then
log_error "pyproject.toml not found. Please run this script from the project root directory."
exit 1
fi
# Check Python version
log_info "Checking Python version..."
python_version=$(python3 --version 2>/dev/null | cut -d' ' -f2 || echo "")
if [ -z "$python_version" ]; then
log_error "Python 3 is not installed or not in PATH."
exit 1
fi
major=$(echo $python_version | cut -d'.' -f1)
minor=$(echo $python_version | cut -d'.' -f2)
if [ "$major" -lt 3 ] || ([ "$major" -eq 3 ] && [ "$minor" -lt 8 ]); then
log_error "Python 3.8 or higher is required. Found: $python_version"
exit 1
fi
log_success "Python $python_version detected ✓"
# Check for uv
log_info "Checking for uv..."
if ! check_command uv; then
log_error "uv is not installed. Please install uv first:"
log_error " curl -LsSf https://astral.sh/uv/install.sh | sh"
log_error " or"
log_error " pip install uv"
exit 1
fi
log_success "uv detected ✓"
# Remove existing virtual environment to ensure fresh install
if [ -d ".venv" ]; then
log_info "Removing existing virtual environment..."
rm -rf .venv
fi
# Create virtual environment and install dependencies with uv
log_info "Creating virtual environment and installing dependencies with uv..."
uv sync
# Install the model-fp package (this creates the model-fp entry point)
log_info "Installing model-fp package..."
uv pip install -e .
log_success "Virtual environment created and dependencies installed ✓"
# Verify installation
log_info "Verifying installation..."
# Check if model-fp command is available and working in the virtual environment
if .venv/bin/model-fp --help >/dev/null 2>&1; then
log_success "model-fp command installed and working ✓"
else
log_error "model-fp command not found or not working in virtual environment."
log_warning "Checking if package was installed correctly..."
# Check if the package is installed
if .venv/bin/pip show model-fp >/dev/null 2>&1; then
log_success "model-fp package is installed ✓"
log_warning "model-fp command may need to be reinstalled or virtual environment may need to be recreated."
else
log_error "model-fp package is not installed."
fi
fi
echo
log_success "🎉 Model-FP installation completed!"
echo
echo -e "${BLUE}═══════════════════ QUICKSTART ════════════════════${NC}"
echo
echo -e "${GREEN}1. Activate Virtual Environment:${NC}"
echo -e " ${YELLOW}source .venv/bin/activate${NC}"
echo -e " or, less conveniently, run model-fp with ${YELLOW}.venv/bin/model-fp${NC}"
echo
echo -e "${GREEN}2. CLI Quick Start:${NC}"
echo -e " ${YELLOW}model-fp --help${NC} Show main help"
echo -e " ${YELLOW}model-fp explain model.onnx${NC} Explain a model"
echo -e " ${YELLOW}model-fp compare a.onnx b.onnx${NC} Compare two models"
echo -e " ${YELLOW}model-fp analyze model.onnx${NC} Analyze model weights"
echo
echo -e "${GREEN}3. Examples:${NC}"
echo -e " ${YELLOW}model-fp explain path/to/model.onnx${NC}"
echo -e " ${YELLOW}model-fp compare model1.onnx model2.onnx --equiv${NC}"
echo -e " ${YELLOW}model-fp analyze model.onnx --top 10${NC}"
echo
echo -e "${BLUE}═══════════════════════════════════════════════════${NC}"