Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 1.1.8 / 2023-08-12

## What's Changed
- Make sure to serve axon first by @camfairchild in 14921d35c


**Full Changelog**: https://github.com/opentensor/validators/compare/v1.1.7...v1.1.8


## 1.1.7 / 2023-08-11
### What’s Changed
- Hotfix cutoff limit by @Eugene-hu in #126
Expand Down
2 changes: 1 addition & 1 deletion openvalidators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
from . import weights
from . import event

__version__ = "1.1.7"
__version__ = "1.1.8"
version_split = __version__.split(".")
__spec_version__ = (1000 * int(version_split[0])) + (10 * int(version_split[1])) + (1 * int(version_split[2]))
10 changes: 10 additions & 0 deletions openvalidators/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ def add_args(cls, parser):
default=4096,
)

parser.add_argument(
"--neuron.axon_off",
"--axon_off",
action="store_true",
# Note: the validator needs to serve an Axon with their IP or they may
# be blacklisted by the firewall of serving peers on the network.
help="Set this flag to not attempt to serve an Axon.",
default=False,
)

parser.add_argument("--wandb.off", action="store_true", help="Turn off wandb.", default=False)
parser.add_argument(
"--wandb.project_name",
Expand Down
29 changes: 24 additions & 5 deletions openvalidators/neuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,31 @@ def __init__(self):
self.gating_model = GatingModel(metagraph=self.metagraph, config=self.config).to(self.device)
bt.logging.debug(str(self.gating_model))

bt.logging.debug('serving ip to chain...')
axon = bt.axon(
wallet=self.wallet, metagraph=self.metagraph, config=self.config
)
if not self.config.neuron.axon_off:
bt.logging.debug('serving ip to chain...')
try:
axon = bt.axon(
wallet=self.wallet, metagraph=self.metagraph, config=self.config
)

try:
self.subtensor.serve_axon(
netuid=self.config.netuid,
axon=axon,
use_upnpc=False,
wait_for_finalization=True,
)
except Exception as e:
bt.logging.error(f'Failed to serve Axon with exception: {e}')
pass

del axon
except Exception as e:
bt.logging.error(f'Failed to create Axon initialize with exception: {e}')
pass

del axon
else:
bt.logging.debug('axon off, not serving ip to chain.')

# Dendrite pool for querying the network during training.
bt.logging.debug("loading", "dendrite_pool")
Expand Down
2 changes: 1 addition & 1 deletion openvalidators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def init_wandb(self, reinit=False):
reinit=reinit,
project=self.config.wandb.project_name,
entity=self.config.wandb.entity,
config=self.config,
config={key: self.config.get(key, None) for key in ('neuron', 'reward')},
mode="offline" if self.config.wandb.offline else "online",
dir=self.config.neuron.full_path,
tags=tags,
Expand Down
59 changes: 59 additions & 0 deletions scripts/release/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Release Script(s) Usage

## Versioning

This script needs:
- An existing `openvalidators/__init__.py` file
- An existing `__version__` variable in that file
- An existing version for that variable

This process will generate:
- A modified version in `__version__` for the update type specified

### Example Usage
`./scripts/release/versioning.sh -U patch -A`

Where:
* `-U` (major|minor|patch) the type of update
* `-A` is to apply the script changes


## Add Notes Changelog

This script needs:
- An existing `CHANGELOG.md` file with at least three lines
- An existing git tag for the previous version

This process will generate:
- A new entry in `CHANGELOG.md`

##### *Note: This will only list merge commits into the release branch since the last tag*

### Example Usage
`./scripts/release/add_notes_changelog.sh -P 1.1.7 -V 1.1.8 -B hotfix/serve-val-axon -T $GIT -A`

Where:
* `-P` is the old version
* `-V` is the new version
* `-B` is the release branch name (default: `release/vX.X.X`)
* `-T` is the GIT API token
* `-A` is to apply the script changes

## Release

This script needs:
- An existing `__version__` variable in the `openvalidators/__init__.py` file
- Version in the `__version__` variable is not a git tag already

This process will generate:
- Tag in Github repo: https://github.com/opentensor/validators/tags
- Release in Github: https://github.com/opentensor/validators/releases


### Example Usage
`./scripts/release/release.sh -T $GIT -A`

Where:
* `-T` is the GIT API token
* `-A` is to apply the script changes

106 changes: 106 additions & 0 deletions scripts/release/add_notes_changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/bash

####
# Utils
####
source ${BASH_SOURCE%/*}/utils.sh
source ${BASH_SOURCE%/*}/github_utils.sh
###

# 1. Get options

## Defaults
APPLY="false"

while [[ $# -gt 0 ]]; do
case $1 in
-A|--apply)
APPLY="true"
shift # past argument
;;
-P|--previous-version-tag)
PREV_TAG_VERSION="$2"
shift # past argument
shift # past value
;;
-V|--version)
VERSION="$2"
shift # past argument
shift # past value
;;
-T|--github-token)
GITHUB_TOKEN="$2"
shift # past argument
shift # past value
;;
-B|--release-branch)
RELEASE_BRANCH="$2"
shift # past argument
shift # past value
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done

if [[ -z $GITHUB_TOKEN && $APPLY == "true" ]]; then
echo_error "Github token required (-T, --github-token)"
exit 1
fi

if [[ -z $PREV_TAG_VERSION ]]; then
echo_error "Previous version tag required (-P, --previous-version-tag)"
exit 1
fi

if [[ -z $VERSION ]]; then
echo_error "Version to release required (-V, --version)"
exit 1
fi

if [[ -z $RELEASE_BRANCH ]]; then
echo_warning "Release branch not specified with (-B, --release-branch) assuming: release/$VERSION"
RELEASE_BRANCH=release/$VERSION
fi

DATE=$(date +"%Y-%m-%d")
RELEASE_NAME="$VERSION / $DATE"
TAG_NAME=v$VERSION
PREV_TAG_NAME=v$PREV_TAG_VERSION

# 2.2. Generate release notes
if [[ $APPLY == "true" ]]; then
echo_info "Generating Github release notes"
RESPONSE=$(generate_github_release_notes_for_changelog $GITHUB_TOKEN)
DESCRIPTION=$(echo $RESPONSE | jq '.body' | tail -1 | sed "s/\"//g")

if [ $(echo $RESPONSE | jq '.body' | wc -l) -eq 1 ]; then
if [ $(echo $RESPONSE | jq '.' | grep 'documentation_url' | wc -l) -gt 0 ]; then
echo_error "Something went wrong generating Github release notes"
echo $RESPONSE | jq --slurp '.[0]'
exit 1
fi

if [ $(echo $RESPONSE | jq '.type' | grep 'error' | wc -l) -gt 0 ]; then
echo_error "Something went wrong generating Github release notes"
echo $RESPONSE | jq --slurp '.[1]'
exit 1
fi
fi
else
echo_warning "Dry run execution. Not generating Github release notes"
fi

if [[ $APPLY == "true" ]]; then
echo_info "Adding release notes to CHANGELOG.md"
sed -i "2 i\\\n## $RELEASE_NAME" CHANGELOG.md
sed -i "4 i\\\n$DESCRIPTION\n" CHANGELOG.md
else
echo_warning "Dry run execution. Not adding release notes to CHANGELOG.md"
fi
105 changes: 105 additions & 0 deletions scripts/release/github_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

####
# Utils
####
source ${BASH_SOURCE%/*}/utils.sh
source ${BASH_SOURCE%/*}/github_utils.sh
###

# 1. Get options

## Defaults
APPLY="false"

while [[ $# -gt 0 ]]; do
case $1 in
-A|--apply)
APPLY="true"
shift # past argument
;;
-P|--previous-version-tag)
PREV_TAG_VERSION="$2"
shift # past argument
shift # past value
;;
-V|--version)
VERSION="$2"
shift # past argument
shift # past value
;;
-T|--github-token)
GITHUB_TOKEN="$2"
shift # past argument
shift # past value
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done

if [[ -z $GITHUB_TOKEN && apply == "true" ]]; then
echo_error "Github token required (-T, --github-token)"
exit 1
fi

if [[ -z $PREV_TAG_VERSION ]]; then
echo_error "Previous version tag required (-P, --previous-version-tag)"
exit 1
fi

if [[ -z $VERSION ]]; then
echo_error "Version to release required (-V, --version)"
exit 1
fi

# 2. Github
DATE=$(date +"%Y-%m-%d")
RELEASE_NAME="$VERSION / $DATE"
PREV_TAG_NAME=$PREV_TAG_VERSION
TAG_NAME=v$VERSION

# 2.1 Create Git tag for the repository
if [[ $APPLY == "true" ]]; then
echo_info "Tagging repository"
tag_repository $TAG_NAME
else
echo_warning "Dry run execution. Not tagging Github repo"
fi

# 2.2. Generate release notes
if [[ $APPLY == "true" ]]; then
echo_info "Generating Github release notes"
RESPONSE=$(generate_github_release_notes $GITHUB_TOKEN)
DESCRIPTION=$(echo $RESPONSE | jq '.body' | tail -1 | sed "s/\"//g")

if [ $(echo $RESPONSE | jq '.body' | wc -l) -eq 1 ]; then
if [ $(echo $RESPONSE | jq '.' | grep 'documentation_url' | wc -l) -gt 0 ]; then
echo_error "Something went wrong generating Github release notes"
echo $RESPONSE | jq --slurp '.[0]'
exit 1
fi

if [ $(echo $RESPONSE | jq '.type' | grep 'error' | wc -l) -gt 0 ]; then
echo_error "Something went wrong generating Github release notes"
echo $RESPONSE | jq --slurp '.[1]'
exit 1
fi
fi
else
echo_warning "Dry run execution. Not generating Github release notes"
fi

# 2.3 Create Github release
if [[ $APPLY == "true" ]]; then
echo_info "Generating Github release"
create_github_release $GITHUB_TOKEN
else
echo_warning "Dry run execution. Not creating Github release"
fi
Loading