Skip to content

Commit 178925a

Browse files
Fixes post release 100 (#16)
* fix password issue * implement wandb tool * update doc * force root on scripts
1 parent 2352762 commit 178925a

27 files changed

Lines changed: 527 additions & 163 deletions

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- [Introduction](#introduction)
3333
- [Prerequisites](#prerequisites)
3434
- [How It Works](#how-it-works)
35+
- [Quick Setup](#quick-setup)
3536
- [Quick Start](#quick-start)
3637
- [Quick Stop](#quick-stop)
3738
- [Quick Upgrade](#quick-upgrade)
@@ -42,6 +43,8 @@
4243
- [Miner](#installation-miner)
4344
- [Validator](#installation-validator)
4445
- [Other](#installation-other)
46+
- [Tools](#tools)
47+
- [Wandb](#tool-wandb)
4548
- [Good to Know](#good-to-know)
4649
- [Troubleshooting](#troubleshooting)
4750
- [License](#license)
@@ -89,7 +92,7 @@ Here's a breakdown of the key variables:
8992
Set to `true` if you want the Auto Upgrader to apply both releases and pre-releases. Default is `false`.
9093

9194
- **SUBVORTEX_EXECUTION_METHOD**:
92-
Defines how the neuron and its componentswill be installed by the Auto Upgrader. Options are `process`, `service`, or `container`. Default is `service`.
95+
Defines how the neuron and its components will be installed by the Auto Upgrader. Options are `process`, `service`, or `container`. Default is `service`.
9396

9497
- **SUBVORTEX_PRERELEASE_TYPE**:
9598
Specifies a single prerelease identifier you want to be notified about. Options are `alpha` (**use ONLY in DEVNET**) or `rc` (**use ONLY in TESTNET**). Remove this variable to receive notifications from `latest` (**use in MAINNET**) prerelease types. Default is an empty string, which disables prerelease notifications.
@@ -120,7 +123,7 @@ Here's a breakdown of the key variables:
120123
- For miners, edit files matching `env.subvortex.miner.*`
121124
- For validators, edit files matching `env.subvortex.validator.*`
122125

123-
3. Update the templates inside the `subvortex/auto_upgrader/template` folder.
126+
3. Update the templates inside the `subvortex/auto_upgrader/template` folder. Recommended to keep as it is.
124127

125128
<br />
126129

@@ -137,6 +140,9 @@ In these modes, the Auto Upgrader checks GitHub every **SUBVORTEX_CHECK_INTERVAL
137140
3. Updates the symlink to point to the new version
138141
4. Cleans up the previous version
139142

143+
➡️ The execution directory for SubVortex will now be located under `$HOME/subvortex`, with each version in its own subdirectory and a symlink pointing to the current version.
144+
You no longer need to clone the SubVortex repository manually — and can safely remove any old local copies you previously cloned.
145+
140146
🐳 Docker Mode
141147

142148
Here, the Auto Upgrader also checks GitHub every **SUBVORTEX_CHECK_INTERVAL** seconds. When a new release is found:
@@ -167,6 +173,20 @@ Then, copy that token as value of `SUBVORTEX_GITHUB_TOKEN` in the main Auto Upgr
167173

168174
<br />
169175

176+
# 🚀 Quick Setup <a id="quick-setup"></a>
177+
178+
To setup the Auto Upgrader in a quick way, you can run
179+
180+
```bash
181+
./scripts/quick_setup.sh --neuron validator --release v3.0.1
182+
```
183+
184+
It will download and unzip the newuon's assets of the SubVortex for the requested version.
185+
186+
Use `-h` to see the options
187+
188+
<br />
189+
170190
# 🚀 Quick Start <a id="quick-start"></a>
171191

172192
To install the Auto Upgrader in a quick way, you can run
@@ -264,6 +284,22 @@ For each of them, the same structure applies:
264284

265285
<br />
266286

287+
# Tools <a id="tools"></a>
288+
289+
## Wandb <a id="tool-wandb"></a>
290+
291+
To login to wandb, run
292+
293+
```bash
294+
./scripts/wandb/wandb_login.sh --api-key <WANDB_API_KEY>
295+
```
296+
297+
To force relogin to wandb, run
298+
299+
```bash
300+
./scripts/wandb/wandb_login.sh --api-key <WANDB_API_KEY> --relogin
301+
```
302+
267303
# 💡 Good to Know <a id="good-to-know"></a>
268304

269305
After installing a version through the Auto Upgrader, you can directly run various management scripts for the Miner and/or Validator.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0
1+
1.0.1

scripts/cleaner/clean_workspace.sh

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,34 @@ show_help() {
2424
}
2525

2626
version_sort() {
27-
if command -v sort >/dev/null && sort -V </dev/null &>/dev/null; then
28-
sort -V
29-
elif command -v gsort >/dev/null; then
30-
gsort -V
31-
else
32-
echo "❌ Error: version sort (sort -V or gsort -V) not supported." >&2
33-
echo "👉 On macOS: brew install coreutils" >&2
34-
exit 1
35-
fi
27+
awk '
28+
{
29+
orig = $0
30+
gsub(/^subvortex-/, "", orig)
31+
32+
base = orig
33+
type = ""
34+
val = 0
35+
weight = 3
36+
37+
if (index(orig, "a") > 0) {
38+
split(orig, parts, "a")
39+
base = parts[1]
40+
val = parts[2] + 0
41+
weight = 1
42+
} else if (index(orig, "rc") > 0) {
43+
split(orig, parts, "rc")
44+
base = parts[1]
45+
val = parts[2] + 0
46+
weight = 2
47+
} else if (match(orig, /^[0-9]+\.[0-9]+\.[0-9]+$/)) {
48+
base = orig
49+
weight = 3
50+
}
51+
52+
printf "%s-%d-%02d %s\n", base, weight, val, $0
53+
}
54+
' | sort | awk '{print $2}'
3655
}
3756

3857
OPTIONS="v:rdhf"
@@ -77,7 +96,10 @@ echo "🔍 Loading environment variables from .env..."
7796
export $(grep -v '^#' subvortex/auto_upgrader/.env | xargs)
7897

7998
TARGET_BASE=${SUBVORTEX_WORKING_DIRECTORY:-/var/tmp/subvortex}
80-
SYMLINK_PATH="/root/subvortex"
99+
SYMLINK_PATH="$HOME/subvortex"
100+
101+
echo "📁 Target base directory: $TARGET_BASE"
102+
echo "🔗 Symlink path: $SYMLINK_PATH"
81103

82104
if [ ! -d "$TARGET_BASE" ]; then
83105
echo "❌ Directory '$TARGET_BASE' does not exist."
@@ -99,8 +121,11 @@ if [ "$FORCE_REINSTALL" = true ]; then
99121
fi
100122

101123
cd "$TARGET_BASE"
124+
echo "🔍 Searching for directories in $TARGET_BASE..."
102125
all_dirs=($(find . -maxdepth 1 -mindepth 1 -type d -exec basename {} \;))
103126

127+
echo "🔎 Found directories: ${all_dirs[*]}"
128+
104129
versioned_dirs=()
105130
non_versioned_dirs=()
106131

@@ -118,20 +143,33 @@ target_normalized=""
118143

119144
if [ -n "$VERSION" ]; then
120145
target_normalized="subvortex-$(normalize_version "$VERSION")"
146+
echo "🎯 Target version to remove: $target_normalized"
121147
else
122148
if [ ${#versioned_dirs[@]} -gt 0 ]; then
123149
latest_version=$(printf "%s\n" "${versioned_dirs[@]}" | version_sort | tail -n 1)
150+
echo "🏷️ Latest version detected: $latest_version"
124151
fi
125152
fi
126153

127154
# Get symlink target if it exists
155+
echo "🔗 Checking symlink at: $SYMLINK_PATH"
156+
128157
symlink_target=""
129-
if [ -L "$SYMLINK_PATH" ]; then
130-
symlink_target="$(readlink "$SYMLINK_PATH")"
131-
symlink_target="$(basename "$symlink_target")"
158+
if [ -e "$SYMLINK_PATH" ] && [ -h "$SYMLINK_PATH" ]; then
159+
resolved_target="$(readlink "$SYMLINK_PATH")"
160+
echo "📌 Resolved symlink target: $resolved_target"
161+
162+
if [[ "$resolved_target" != /* ]]; then
163+
resolved_target="$(cd "$(dirname "$SYMLINK_PATH")" && cd "$(dirname "$resolved_target")" && pwd)/$(basename "$resolved_target")"
164+
fi
165+
166+
symlink_target="$(basename "$resolved_target")"
167+
echo "🧭 Final resolved version dir: $symlink_target"
168+
else
169+
echo "⚠️ No valid symlink found at $SYMLINK_PATH"
132170
fi
133171

134-
echo "🧹 Cleaning up: $TARGET_BASE"
172+
echo "🧹 Starting cleanup in: $TARGET_BASE"
135173

136174
for dir in "${all_dirs[@]}"; do
137175
keep=false
@@ -161,7 +199,12 @@ for dir in "${all_dirs[@]}"; do
161199
for nvd in "${non_versioned_dirs[@]}"; do
162200
[ "$dir" == "$nvd" ] && keep=true && break
163201
done
164-
[ "$dir" == "$latest_version" ] && keep=true
202+
203+
if [ -n "$symlink_target" ]; then
204+
[ "$dir" == "$symlink_target" ] && keep=true
205+
else
206+
[ "$dir" == "$latest_version" ] && keep=true
207+
fi
165208
fi
166209

167210
if [ "$keep" = true ]; then
@@ -183,4 +226,4 @@ for dir in "${all_dirs[@]}"; do
183226
fi
184227
done
185228

186-
echo "✅ Cleanup workspace complete."
229+
echo "✅ Cleanup workspace complete."

scripts/miner/oneshot/miner_oneshot_installation.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
set -euo pipefail
44

5+
# Ensure script run as root
6+
if [[ "$EUID" -ne 0 ]]; then
7+
echo "🛑 This script must be run as root. Re-running with sudo..."
8+
exec sudo "$0" "$@"
9+
fi
10+
511
# 🧭 Navigate to project root
612
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
713
cd "$SCRIPT_DIR/../../.."
@@ -72,7 +78,7 @@ case "$val_mode" in
7278
1)
7379
read -rp "⚙️ Enter systemd service name: " val_svc
7480
echo "⛔ Stopping systemd service '$val_svc'..."
75-
sudo systemctl stop "$val_svc" || echo "⚠️ Failed to stop systemd service"
81+
systemctl stop "$val_svc" || echo "⚠️ Failed to stop systemd service"
7682
;;
7783
2)
7884
read -rp "⚙️ Enter PM2 process name: " val_proc

scripts/miner/oneshot/miner_oneshot_teardown.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
set -euo pipefail
44

5+
# Ensure script run as root
6+
if [[ "$EUID" -ne 0 ]]; then
7+
echo "🛑 This script must be run as root. Re-running with sudo..."
8+
exec sudo "$0" "$@"
9+
fi
10+
511
# 🧭 Navigate to project root
612
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
713
cd "$SCRIPT_DIR/../../.."
@@ -94,7 +100,7 @@ case "$val_mode" in
94100
1)
95101
read -rp "⚙️ Enter systemd service name: " val_svc
96102
echo "🔼 Starting systemd service '$val_svc'..."
97-
sudo systemctl start "$val_svc" || echo "⚠️ Failed to start systemd service"
103+
systemctl start "$val_svc" || echo "⚠️ Failed to start systemd service"
98104
;;
99105
2)
100106
read -rp "⚙️ Enter PM2 process name: " val_proc

0 commit comments

Comments
 (0)