Repository navigation
Expand file tree
/
Copy pathfixed_setup.sh
More file actions
executable file
Β·212 lines (177 loc) Β· 6.05 KB
/
Copy pathfixed_setup.sh
File metadata and controls
executable file
Β·212 lines (177 loc) Β· 6.05 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/bin/bash
# Fixed Setup Script for TensorFlix SN89 Validator
# Execute these commands to integrate follower analysis framework
echo "π¦ Starting TensorFlix Validator Setup (Fixed Version)..."
# 1. Find current working directory and setup
echo "π Current location: $(pwd)"
echo "π€ Current user: $(whoami)"
# 2. Clone the repository with SSH (better than HTTPS)
echo "π₯ Cloning codebase..."
if [ ! -d "valitesting89" ]; then
# Try SSH first, fallback to HTTPS
git clone git@github.com:DeltaCompute24/valitesting89.git || \
git clone https://github.com/DeltaCompute24/valitesting89.git
fi
cd valitesting89 || {
echo "β Failed to enter valitesting89 directory"
exit 1
}
echo "β
Successfully cloned and entered repository"
# 3. Setup Python environment
echo "π§ Setting up Python environment..."
python3 -m venv .venv
source .venv/bin/activate
# Install basic requirements first
echo "π¦ Installing basic Python packages..."
pip install --upgrade pip
# Install the project requirements
echo "π¦ Installing project requirements..."
pip install -r requirements.txt
# Install additional dependencies needed for the validator
echo "π¦ Installing additional dependencies..."
pip install uvicorn fastapi motor pymongo loguru httpx asyncio-motor tabulate numpy
# Install bittensor
echo "π¦ Installing bittensor..."
pip install bittensor
# 4. Install PM2 if not available
echo "π¦ Checking PM2 installation..."
if ! command -v pm2 &> /dev/null; then
echo "Installing PM2..."
if command -v npm &> /dev/null; then
npm install -g pm2
else
echo "β οΈ PM2 not installed and npm not available"
echo " You'll need to run services manually or install PM2"
fi
else
echo "β
PM2 already installed"
fi
# 5. Create environment file template
echo "βοΈ Creating environment configuration..."
cat > .env << 'EOF'
# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017/
# Service URLs
SERVICE_PLATFORM_TRACKER_URL=http://localhost:12001
SERVICE_AI_DETECTOR_URL=http://localhost:12002
# Bittensor Configuration
SUBTENSOR_NETWORK=finney
NETUID=89
# Follower Analysis Configuration
BOT_DETECTION_ENABLED=true
BOT_THRESHOLD=0.7
CONFIDENCE_THRESHOLD=0.5
EOF
echo "β
Created .env file - please review and update as needed"
# 6. Test the follower analysis framework
echo "π§ͺ Testing follower analysis framework..."
python examples/basic_usage.py
# 7. Test validator patch
echo "π§ͺ Testing validator integration..."
python src/validator_patch.py
# 8. Create service scripts
echo "π Creating service scripts..."
# AI Detector Service
cat > start_ai_detector.sh << 'EOF'
#!/bin/bash
cd "$(dirname "$0")"
source .venv/bin/activate
export $(cat .env | xargs)
python -m uvicorn tensorflix.services.ai_detector.app:app --host 0.0.0.0 --port 12002
EOF
chmod +x start_ai_detector.sh
# Platform Tracker Service
cat > start_tracker.sh << 'EOF'
#!/bin/bash
cd "$(dirname "$0")"
source .venv/bin/activate
export $(cat .env | xargs)
python -m uvicorn tensorflix.services.platform_tracker.app:app --host 0.0.0.0 --port 12001
EOF
chmod +x start_tracker.sh
# Validator Service with Bot Detection
cat > start_validator.sh << 'EOF'
#!/bin/bash
cd "$(dirname "$0")"
source .venv/bin/activate
export $(cat .env | xargs)
# Add the follower analysis path to Python path
export PYTHONPATH="${PYTHONPATH}:$(pwd)/src"
python -m neurons.validating \
--netuid 89 \
--wallet.hotkey default \
--wallet.name subnet89_owner \
--wallet.path ~/.bittensor/wallets/ \
--subtensor.network finney \
--logging.debug
EOF
chmod +x start_validator.sh
# 9. Test services individually (if dependencies are available)
echo "π§ͺ Testing services..."
if python -c "import uvicorn" 2>/dev/null; then
echo "β
uvicorn available, testing services..."
# Test AI detector
echo "Testing AI detector..."
timeout 5s ./start_ai_detector.sh &
sleep 3
if curl -s http://localhost:12002/health >/dev/null 2>&1; then
echo "β
AI Detector OK"
else
echo "β οΈ AI Detector not responding (may need dependencies)"
fi
pkill -f "uvicorn.*ai_detector" 2>/dev/null || true
# Test platform tracker
echo "Testing platform tracker..."
timeout 5s ./start_tracker.sh &
sleep 3
if curl -s http://localhost:12001/health >/dev/null 2>&1; then
echo "β
Platform Tracker OK"
else
echo "β οΈ Platform Tracker not responding (may need dependencies)"
fi
pkill -f "uvicorn.*platform_tracker" 2>/dev/null || true
else
echo "β οΈ uvicorn not available, skipping service tests"
fi
# 10. Setup PM2 services (if PM2 is available)
if command -v pm2 &> /dev/null; then
echo "π Setting up PM2 services..."
# Stop any existing services
pm2 delete tensorflix-ai-detector tensorflix-tracker tensorflix-validator 2>/dev/null || true
# Start new services
pm2 start ./start_ai_detector.sh --name tensorflix-ai-detector
pm2 start ./start_tracker.sh --name tensorflix-tracker
pm2 start ./start_validator.sh --name tensorflix-validator
pm2 save
pm2 list
echo "π Services started with PM2"
else
echo "β οΈ PM2 not available - you can run services manually:"
echo " ./start_ai_detector.sh &"
echo " ./start_tracker.sh &"
echo " ./start_validator.sh"
fi
# 11. Final status
echo ""
echo "π Setup complete!"
echo ""
echo "π Repository location: $(pwd)"
echo "π Python environment: $(which python)"
echo "π Follower Analysis: Ready"
echo ""
echo "π§ Next steps:"
echo "1. Review and update .env file with your configuration"
echo "2. Ensure MongoDB is running (connection: $MONGODB_URI)"
echo "3. Set up your Bittensor wallet if not already done"
echo "4. Start services:"
if command -v pm2 &> /dev/null; then
echo " pm2 start tensorflix-validator"
echo " pm2 logs tensorflix-validator"
else
echo " ./start_validator.sh"
fi
echo ""
echo "π Monitor logs for follower analysis activity:"
echo " Look for messages like 'π€ Bot penalty applied' in validator logs"
echo ""
echo "π Integration guide: VALIDATOR_INTEGRATION.md"