Skip to content

Commit 0f7c18d

Browse files
authored
Merge pull request #133 from opentensor/staging
1.1.8 release
2 parents 3b80a44 + 8267b2e commit 0f7c18d

12 files changed

+725
-7
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 1.1.8 / 2023-08-12
4+
5+
## What's Changed
6+
- Make sure to serve axon first by @camfairchild in 14921d35c
7+
8+
9+
**Full Changelog**: https://github.com/opentensor/validators/compare/v1.1.7...v1.1.8
10+
11+
312
## 1.1.7 / 2023-08-11
413
### What’s Changed
514
- Hotfix cutoff limit by @Eugene-hu in #126

openvalidators/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
from . import weights
2929
from . import event
3030

31-
__version__ = "1.1.7"
31+
__version__ = "1.1.8"
3232
version_split = __version__.split(".")
3333
__spec_version__ = (1000 * int(version_split[0])) + (10 * int(version_split[1])) + (1 * int(version_split[2]))

openvalidators/config.py

+10
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ def add_args(cls, parser):
166166
default=4096,
167167
)
168168

169+
parser.add_argument(
170+
"--neuron.axon_off",
171+
"--axon_off",
172+
action="store_true",
173+
# Note: the validator needs to serve an Axon with their IP or they may
174+
# be blacklisted by the firewall of serving peers on the network.
175+
help="Set this flag to not attempt to serve an Axon.",
176+
default=False,
177+
)
178+
169179
parser.add_argument("--wandb.off", action="store_true", help="Turn off wandb.", default=False)
170180
parser.add_argument(
171181
"--wandb.project_name",

openvalidators/neuron.py

+24-5
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,31 @@ def __init__(self):
127127
self.gating_model = GatingModel(metagraph=self.metagraph, config=self.config).to(self.device)
128128
bt.logging.debug(str(self.gating_model))
129129

130-
bt.logging.debug('serving ip to chain...')
131-
axon = bt.axon(
132-
wallet=self.wallet, metagraph=self.metagraph, config=self.config
133-
)
130+
if not self.config.neuron.axon_off:
131+
bt.logging.debug('serving ip to chain...')
132+
try:
133+
axon = bt.axon(
134+
wallet=self.wallet, metagraph=self.metagraph, config=self.config
135+
)
136+
137+
try:
138+
self.subtensor.serve_axon(
139+
netuid=self.config.netuid,
140+
axon=axon,
141+
use_upnpc=False,
142+
wait_for_finalization=True,
143+
)
144+
except Exception as e:
145+
bt.logging.error(f'Failed to serve Axon with exception: {e}')
146+
pass
147+
148+
del axon
149+
except Exception as e:
150+
bt.logging.error(f'Failed to create Axon initialize with exception: {e}')
151+
pass
134152

135-
del axon
153+
else:
154+
bt.logging.debug('axon off, not serving ip to chain.')
136155

137156
# Dendrite pool for querying the network during training.
138157
bt.logging.debug("loading", "dendrite_pool")

openvalidators/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def init_wandb(self, reinit=False):
5454
reinit=reinit,
5555
project=self.config.wandb.project_name,
5656
entity=self.config.wandb.entity,
57-
config=self.config,
57+
config={key: self.config.get(key, None) for key in ('neuron', 'reward')},
5858
mode="offline" if self.config.wandb.offline else "online",
5959
dir=self.config.neuron.full_path,
6060
tags=tags,

scripts/release/README.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Release Script(s) Usage
2+
3+
## Versioning
4+
5+
This script needs:
6+
- An existing `openvalidators/__init__.py` file
7+
- An existing `__version__` variable in that file
8+
- An existing version for that variable
9+
10+
This process will generate:
11+
- A modified version in `__version__` for the update type specified
12+
13+
### Example Usage
14+
`./scripts/release/versioning.sh -U patch -A`
15+
16+
Where:
17+
* `-U` (major|minor|patch) the type of update
18+
* `-A` is to apply the script changes
19+
20+
21+
## Add Notes Changelog
22+
23+
This script needs:
24+
- An existing `CHANGELOG.md` file with at least three lines
25+
- An existing git tag for the previous version
26+
27+
This process will generate:
28+
- A new entry in `CHANGELOG.md`
29+
30+
##### *Note: This will only list merge commits into the release branch since the last tag*
31+
32+
### Example Usage
33+
`./scripts/release/add_notes_changelog.sh -P 1.1.7 -V 1.1.8 -B hotfix/serve-val-axon -T $GIT -A`
34+
35+
Where:
36+
* `-P` is the old version
37+
* `-V` is the new version
38+
* `-B` is the release branch name (default: `release/vX.X.X`)
39+
* `-T` is the GIT API token
40+
* `-A` is to apply the script changes
41+
42+
## Release
43+
44+
This script needs:
45+
- An existing `__version__` variable in the `openvalidators/__init__.py` file
46+
- Version in the `__version__` variable is not a git tag already
47+
48+
This process will generate:
49+
- Tag in Github repo: https://github.com/opentensor/validators/tags
50+
- Release in Github: https://github.com/opentensor/validators/releases
51+
52+
53+
### Example Usage
54+
`./scripts/release/release.sh -T $GIT -A`
55+
56+
Where:
57+
* `-T` is the GIT API token
58+
* `-A` is to apply the script changes
59+
+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash
2+
3+
####
4+
# Utils
5+
####
6+
source ${BASH_SOURCE%/*}/utils.sh
7+
source ${BASH_SOURCE%/*}/github_utils.sh
8+
###
9+
10+
# 1. Get options
11+
12+
## Defaults
13+
APPLY="false"
14+
15+
while [[ $# -gt 0 ]]; do
16+
case $1 in
17+
-A|--apply)
18+
APPLY="true"
19+
shift # past argument
20+
;;
21+
-P|--previous-version-tag)
22+
PREV_TAG_VERSION="$2"
23+
shift # past argument
24+
shift # past value
25+
;;
26+
-V|--version)
27+
VERSION="$2"
28+
shift # past argument
29+
shift # past value
30+
;;
31+
-T|--github-token)
32+
GITHUB_TOKEN="$2"
33+
shift # past argument
34+
shift # past value
35+
;;
36+
-B|--release-branch)
37+
RELEASE_BRANCH="$2"
38+
shift # past argument
39+
shift # past value
40+
;;
41+
-*|--*)
42+
echo "Unknown option $1"
43+
exit 1
44+
;;
45+
*)
46+
POSITIONAL_ARGS+=("$1") # save positional arg
47+
shift # past argument
48+
;;
49+
esac
50+
done
51+
52+
if [[ -z $GITHUB_TOKEN && $APPLY == "true" ]]; then
53+
echo_error "Github token required (-T, --github-token)"
54+
exit 1
55+
fi
56+
57+
if [[ -z $PREV_TAG_VERSION ]]; then
58+
echo_error "Previous version tag required (-P, --previous-version-tag)"
59+
exit 1
60+
fi
61+
62+
if [[ -z $VERSION ]]; then
63+
echo_error "Version to release required (-V, --version)"
64+
exit 1
65+
fi
66+
67+
if [[ -z $RELEASE_BRANCH ]]; then
68+
echo_warning "Release branch not specified with (-B, --release-branch) assuming: release/$VERSION"
69+
RELEASE_BRANCH=release/$VERSION
70+
fi
71+
72+
DATE=$(date +"%Y-%m-%d")
73+
RELEASE_NAME="$VERSION / $DATE"
74+
TAG_NAME=v$VERSION
75+
PREV_TAG_NAME=v$PREV_TAG_VERSION
76+
77+
# 2.2. Generate release notes
78+
if [[ $APPLY == "true" ]]; then
79+
echo_info "Generating Github release notes"
80+
RESPONSE=$(generate_github_release_notes_for_changelog $GITHUB_TOKEN)
81+
DESCRIPTION=$(echo $RESPONSE | jq '.body' | tail -1 | sed "s/\"//g")
82+
83+
if [ $(echo $RESPONSE | jq '.body' | wc -l) -eq 1 ]; then
84+
if [ $(echo $RESPONSE | jq '.' | grep 'documentation_url' | wc -l) -gt 0 ]; then
85+
echo_error "Something went wrong generating Github release notes"
86+
echo $RESPONSE | jq --slurp '.[0]'
87+
exit 1
88+
fi
89+
90+
if [ $(echo $RESPONSE | jq '.type' | grep 'error' | wc -l) -gt 0 ]; then
91+
echo_error "Something went wrong generating Github release notes"
92+
echo $RESPONSE | jq --slurp '.[1]'
93+
exit 1
94+
fi
95+
fi
96+
else
97+
echo_warning "Dry run execution. Not generating Github release notes"
98+
fi
99+
100+
if [[ $APPLY == "true" ]]; then
101+
echo_info "Adding release notes to CHANGELOG.md"
102+
sed -i "2 i\\\n## $RELEASE_NAME" CHANGELOG.md
103+
sed -i "4 i\\\n$DESCRIPTION\n" CHANGELOG.md
104+
else
105+
echo_warning "Dry run execution. Not adding release notes to CHANGELOG.md"
106+
fi

scripts/release/github_release.sh

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
3+
####
4+
# Utils
5+
####
6+
source ${BASH_SOURCE%/*}/utils.sh
7+
source ${BASH_SOURCE%/*}/github_utils.sh
8+
###
9+
10+
# 1. Get options
11+
12+
## Defaults
13+
APPLY="false"
14+
15+
while [[ $# -gt 0 ]]; do
16+
case $1 in
17+
-A|--apply)
18+
APPLY="true"
19+
shift # past argument
20+
;;
21+
-P|--previous-version-tag)
22+
PREV_TAG_VERSION="$2"
23+
shift # past argument
24+
shift # past value
25+
;;
26+
-V|--version)
27+
VERSION="$2"
28+
shift # past argument
29+
shift # past value
30+
;;
31+
-T|--github-token)
32+
GITHUB_TOKEN="$2"
33+
shift # past argument
34+
shift # past value
35+
;;
36+
-*|--*)
37+
echo "Unknown option $1"
38+
exit 1
39+
;;
40+
*)
41+
POSITIONAL_ARGS+=("$1") # save positional arg
42+
shift # past argument
43+
;;
44+
esac
45+
done
46+
47+
if [[ -z $GITHUB_TOKEN && apply == "true" ]]; then
48+
echo_error "Github token required (-T, --github-token)"
49+
exit 1
50+
fi
51+
52+
if [[ -z $PREV_TAG_VERSION ]]; then
53+
echo_error "Previous version tag required (-P, --previous-version-tag)"
54+
exit 1
55+
fi
56+
57+
if [[ -z $VERSION ]]; then
58+
echo_error "Version to release required (-V, --version)"
59+
exit 1
60+
fi
61+
62+
# 2. Github
63+
DATE=$(date +"%Y-%m-%d")
64+
RELEASE_NAME="$VERSION / $DATE"
65+
PREV_TAG_NAME=$PREV_TAG_VERSION
66+
TAG_NAME=v$VERSION
67+
68+
# 2.1 Create Git tag for the repository
69+
if [[ $APPLY == "true" ]]; then
70+
echo_info "Tagging repository"
71+
tag_repository $TAG_NAME
72+
else
73+
echo_warning "Dry run execution. Not tagging Github repo"
74+
fi
75+
76+
# 2.2. Generate release notes
77+
if [[ $APPLY == "true" ]]; then
78+
echo_info "Generating Github release notes"
79+
RESPONSE=$(generate_github_release_notes $GITHUB_TOKEN)
80+
DESCRIPTION=$(echo $RESPONSE | jq '.body' | tail -1 | sed "s/\"//g")
81+
82+
if [ $(echo $RESPONSE | jq '.body' | wc -l) -eq 1 ]; then
83+
if [ $(echo $RESPONSE | jq '.' | grep 'documentation_url' | wc -l) -gt 0 ]; then
84+
echo_error "Something went wrong generating Github release notes"
85+
echo $RESPONSE | jq --slurp '.[0]'
86+
exit 1
87+
fi
88+
89+
if [ $(echo $RESPONSE | jq '.type' | grep 'error' | wc -l) -gt 0 ]; then
90+
echo_error "Something went wrong generating Github release notes"
91+
echo $RESPONSE | jq --slurp '.[1]'
92+
exit 1
93+
fi
94+
fi
95+
else
96+
echo_warning "Dry run execution. Not generating Github release notes"
97+
fi
98+
99+
# 2.3 Create Github release
100+
if [[ $APPLY == "true" ]]; then
101+
echo_info "Generating Github release"
102+
create_github_release $GITHUB_TOKEN
103+
else
104+
echo_warning "Dry run execution. Not creating Github release"
105+
fi

0 commit comments

Comments
 (0)