Skip to content

Commit 0a3ea53

Browse files
authored
Merge branch 'staging' into master
2 parents 953240e + 4ae2abe commit 0a3ea53

File tree

17 files changed

+493
-262
lines changed

17 files changed

+493
-262
lines changed

.github/workflows/docker_release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ jobs:
2424
uses: sigstore/cosign-installer@v3
2525

2626
- name: Log in to Docker Hub
27-
uses: docker/login-action@v2
27+
uses: docker/login-action@v3
2828
with:
2929
registry: docker.io
3030
username: ${{ secrets.DOCKERHUB_USERNAME }}
3131
password: ${{ secrets.DOCKERHUB_TOKEN }}
3232

3333
- name: Set up Docker Buildx
34-
uses: docker/setup-buildx-action@v2
34+
uses: docker/setup-buildx-action@v3
3535

3636
- name: Build and push Docker image
37-
uses: docker/build-push-action@v4
37+
uses: docker/build-push-action@v6
3838
with:
3939
context: .
4040
push: true

bittensor/core/async_subtensor.py

Lines changed: 136 additions & 85 deletions
Large diffs are not rendered by default.

bittensor/core/extrinsics/asyncex/unstaking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ async def unstake_multiple_extrinsic(
291291
for idx, (hotkey_ss58, amount, old_stake, netuid) in enumerate(
292292
zip(hotkey_ss58s, amounts, old_stakes, netuids)
293293
):
294-
# Covert to bittensor.Balance
294+
# Convert to bittensor.Balance
295295
if amount is None:
296296
# Unstake it all.
297297
unstaking_balance = old_stake

bittensor/core/extrinsics/unstaking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def unstake_multiple_extrinsic(
281281
for idx, (hotkey_ss58, amount, old_stake, netuid) in enumerate(
282282
zip(hotkey_ss58s, amounts, old_stakes, netuids)
283283
):
284-
# Covert to bittensor.Balance
284+
# Convert to bittensor.Balance
285285
if amount is None:
286286
# Unstake it all.
287287
unstaking_balance = old_stake

bittensor/core/settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@
126126
"_mock": False,
127127
},
128128
"wallet": {
129-
"name": "default",
130-
"hotkey": "default",
131-
"path": str(WALLETS_DIR),
129+
"name": os.getenv("BT_WALLET_NAME") or "default",
130+
"hotkey": os.getenv("BT_WALLET_HOTKEY") or "default",
131+
"path": os.getenv("BT_WALLET_PATH") or str(WALLETS_DIR),
132132
},
133133
}
134134
)

bittensor/core/subtensor.py

Lines changed: 127 additions & 85 deletions
Large diffs are not rendered by default.

bittensor/core/subtensor_api/subnets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def __init__(self, subtensor: Union["_Subtensor", "_AsyncSubtensor"]):
1414
self.bonds = subtensor.bonds
1515
self.difficulty = subtensor.difficulty
1616
self.get_all_subnets_info = subtensor.get_all_subnets_info
17+
self.get_parents = subtensor.get_parents
1718
self.get_children = subtensor.get_children
1819
self.get_children_pending = subtensor.get_children_pending
1920
self.get_current_weight_commit_info = subtensor.get_current_weight_commit_info

bittensor/core/subtensor_api/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def add_legacy_methods(subtensor: "SubtensorApi"):
3636
subtensor.get_balance = subtensor._subtensor.get_balance
3737
subtensor.get_balances = subtensor._subtensor.get_balances
3838
subtensor.get_block_hash = subtensor._subtensor.get_block_hash
39+
subtensor.get_parents = subtensor._subtensor.get_parents
3940
subtensor.get_children = subtensor._subtensor.get_children
4041
subtensor.get_children_pending = subtensor._subtensor.get_children_pending
4142
subtensor.get_commitment = subtensor._subtensor.get_commitment

scripts/install.sh

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
#!/bin/bash
32
set -u
43

5-
# enable command completion
4+
# enable command completion
65
set -o history -o histexpand
76

87
python="python3"
@@ -34,7 +33,6 @@ wait_for_user() {
3433
echo
3534
echo "Press RETURN to continue or any other key to abort"
3635
getc c
37-
# we test for \r and \n because some stuff does \r instead
3836
if ! [[ "$c" == $'\r' || "$c" == $'\n' ]]; then
3937
exit 1
4038
fi
@@ -67,12 +65,8 @@ ohai() {
6765
printf "${tty_blue}==>${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")"
6866
}
6967

70-
# Things can fail later if `pwd` doesn't exist.
71-
# Also sudo prints a warning message for no good reason
72-
cd "/usr" || exit 1
73-
7468
linux_install_pre() {
75-
sudo apt-get update
69+
sudo apt-get update
7670
sudo apt-get install --no-install-recommends --no-install-suggests -y apt-utils curl git cmake build-essential
7771
exit_on_error $?
7872
}
@@ -86,41 +80,48 @@ linux_install_python() {
8680
ohai "Updating python"
8781
sudo apt-get install --only-upgrade $python
8882
fi
89-
exit_on_error $?
83+
exit_on_error $?
9084
ohai "Installing python tools"
91-
sudo apt-get install --no-install-recommends --no-install-suggests -y $python-pip $python-dev
92-
exit_on_error $?
85+
sudo apt-get install --no-install-recommends --no-install-suggests -y python3-pip python3-dev python3-venv
86+
exit_on_error $?
9387
}
9488

9589
linux_update_pip() {
96-
PYTHONPATH=$(which $python)
97-
ohai "You are using python@ $PYTHONPATH$"
98-
ohai "Installing python tools"
99-
$python -m pip install --upgrade pip
90+
ohai "Skipping pip upgrade in system Python (PEP 668). Will upgrade inside virtual environment."
10091
}
10192

93+
10294
linux_install_bittensor() {
10395
ohai "Cloning bittensor@master into ~/.bittensor/bittensor"
10496
mkdir -p ~/.bittensor/bittensor
105-
git clone https://github.com/opentensor/bittensor.git ~/.bittensor/bittensor/ 2> /dev/null || (cd ~/.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard ; git clean -xdf)
97+
git clone https://github.com/opentensor/bittensor.git ~/.bittensor/bittensor/ 2> /dev/null || \
98+
(cd ~/.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard ; git clean -xdf)
99+
100+
ohai "Creating Python virtual environment"
101+
python3 -m venv ~/.bittensor/venv
102+
$HOME/.bittensor/venv/bin/python -m ensurepip --upgrade
103+
source ~/.bittensor/venv/bin/activate
104+
python="$HOME/.bittensor/venv/bin/python"
105+
106106
ohai "Installing bittensor"
107+
$python -m pip install --upgrade pip
107108
$python -m pip install -e ~/.bittensor/bittensor/
108109
$python -m pip install -U bittensor-cli
109-
exit_on_error $?
110+
exit_on_error $?
111+
deactivate
110112
}
111113

112114
linux_increase_ulimit(){
113115
ohai "Increasing ulimit to 1,000,000"
114116
prlimit --pid=$PPID --nofile=1000000
115117
}
116118

117-
118119
mac_install_xcode() {
119120
which -s xcode-select
120121
if [[ $? != 0 ]] ; then
121122
ohai "Installing xcode:"
122123
xcode-select --install
123-
exit_on_error $?
124+
exit_on_error $?
124125
fi
125126
}
126127

@@ -133,7 +134,7 @@ mac_install_brew() {
133134
ohai "Updating brew:"
134135
brew update --verbose
135136
fi
136-
exit_on_error $?
137+
exit_on_error $?
137138
}
138139

139140
mac_install_cmake() {
@@ -153,7 +154,7 @@ mac_install_python() {
153154
brew list python@3 &>/dev/null || brew install python@3;
154155
ohai "Updating python3"
155156
brew upgrade python@3
156-
exit_on_error $?
157+
exit_on_error $?
157158
}
158159

159160
mac_update_pip() {
@@ -165,11 +166,20 @@ mac_update_pip() {
165166

166167
mac_install_bittensor() {
167168
ohai "Cloning bittensor into ~/.bittensor/bittensor"
168-
git clone https://github.com/opentensor/bittensor.git ~/.bittensor/bittensor/ 2> /dev/null || (cd ~/.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard; git clean -xdf)
169+
git clone https://github.com/opentensor/bittensor.git ~/.bittensor/bittensor/ 2> /dev/null || \
170+
(cd ~/.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard; git clean -xdf)
171+
172+
ohai "Creating Python virtual environment"
173+
python3 -m venv ~/.bittensor/venv
174+
$HOME/.bittensor/venv/bin/python -m ensurepip --upgrade
175+
source ~/.bittensor/venv/bin/activate
176+
python="$HOME/.bittensor/venv/bin/python"
177+
169178
ohai "Installing bittensor"
179+
$python -m pip install --upgrade pip
170180
$python -m pip install -e ~/.bittensor/bittensor/
171181
$python -m pip install -U bittensor-cli
172-
exit_on_error $?
182+
exit_on_error $?
173183
deactivate
174184
}
175185

@@ -178,11 +188,12 @@ OS="$(uname)"
178188
if [[ "$OS" == "Linux" ]]; then
179189

180190
which -s apt-get
181-
if [[ $? == 0 ]] ; then
191+
if [[ $? != 0 ]] ; then
182192
abort "This linux based install requires apt-get. To run with other distros (centos, arch, etc), you will need to manually install the requirements"
183193
fi
194+
184195
echo """
185-
196+
186197
██████╗░██╗████████╗████████╗███████╗███╗░░██╗░██████╗░█████╗░██████╗░
187198
██╔══██╗██║╚══██╔══╝╚══██╔══╝██╔════╝████╗░██║██╔════╝██╔══██╗██╔══██╗
188199
██████╦╝██║░░░██║░░░░░░██║░░░█████╗░░██╔██╗██║╚█████╗░██║░░██║██████╔╝
@@ -260,7 +271,7 @@ fi
260271

261272
# Use the shell's audible bell.
262273
if [[ -t 1 ]]; then
263-
printf "\a"
274+
printf "\a"
264275
fi
265276

266277
echo ""
@@ -289,12 +300,12 @@ echo " $ btcli w new_hotkey"
289300
echo " $ btcli w list"
290301
echo " $ btcli s register"
291302
echo ""
303+
echo "- Check Bittensor SDK version"
304+
echo " $ python -m bittensor"
305+
echo ""
292306
echo "- Use the Python API"
293307
echo " $ python3"echo " >> import bittensor"
294308
echo ""
295-
echo "- Join the discussion: "
309+
echo "- Join the discussion:"
296310
echo " ${tty_underline}https://discord.gg/3rUr6EcvbB${tty_reset}"
297311
echo ""
298-
299-
300-

tests/e2e_tests/conftest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,21 @@ def docker_runner(params):
129129
"""Starts a Docker container before tests and gracefully terminates it after."""
130130

131131
def is_docker_running():
132-
"""Check if Docker has been run."""
132+
"""Check if Docker is running and optionally skip pulling the image."""
133133
try:
134134
subprocess.run(
135135
["docker", "info"],
136136
stdout=subprocess.DEVNULL,
137137
stderr=subprocess.DEVNULL,
138138
check=True,
139139
)
140-
subprocess.run(["docker", "pull", LOCALNET_IMAGE_NAME], check=True)
140+
141+
skip_pull = os.getenv("SKIP_PULL", "0") == "1"
142+
if not skip_pull:
143+
subprocess.run(["docker", "pull", LOCALNET_IMAGE_NAME], check=True)
144+
else:
145+
print(f"[SKIP_PULL=1] Skipping 'docker pull {LOCALNET_IMAGE_NAME}'")
146+
141147
return True
142148
except subprocess.CalledProcessError:
143149
return False

0 commit comments

Comments
 (0)