Skip to content

Commit

Permalink
merge with target branch
Browse files Browse the repository at this point in the history
  • Loading branch information
open-junius committed Jun 7, 2024
2 parents 1e0b1b2 + 8a73421 commit 28abbf3
Show file tree
Hide file tree
Showing 62 changed files with 1,057 additions and 700 deletions.
55 changes: 28 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ orbs:
# coveralls: coveralls/[email protected]

jobs:
black:
ruff:
resource_class: small
parameters:
python-version:
Expand All @@ -18,29 +18,29 @@ jobs:
- checkout

- restore_cache:
name: Restore cached black venv
name: Restore cached ruff venv
keys:
- v2-pypi-py-black-<< parameters.python-version >>
- v2-pypi-py-ruff-<< parameters.python-version >>

- run:
name: Update & Activate black venv
name: Update & Activate ruff venv
command: |
python -m venv env/
. env/bin/activate
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
pip install black==23.7.0
pip install ruff -c requirements/dev.txt
- save_cache:
name: Save cached black venv
name: Save cached ruff venv
paths:
- "env/"
key: v2-pypi-py-black-<< parameters.python-version >>
- ".venv/"
key: v2-pypi-py-ruff-<< parameters.python-version >>

- run:
name: Black format check
name: Ruff format check
command: |
. env/bin/activate
python -m black --exclude '(env|venv|.eggs)' --check .
. .venv/bin/activate
ruff format --diff .
check_compatibility:
parameters:
Expand Down Expand Up @@ -85,8 +85,8 @@ jobs:
- run:
name: Update & Activate venv
command: |
python -m venv env/
. env/bin/activate
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install '.[dev]'
Expand All @@ -99,20 +99,20 @@ jobs:
- run:
name: Install Bittensor
command: |
. env/bin/activate
. .venv/bin/activate
pip install -e '.[dev]'
- run:
name: Instantiate Mock Wallet
command: |
. env/bin/activate
. .venv/bin/activate
./scripts/create_wallet.sh
# TODO: Update test durations on different runs
- run:
name: Unit Tests
no_output_timeout: 20m
command: |
. env/bin/activate
. .venv/bin/activate
export PYTHONUNBUFFERED=1
pytest -n2 --reruns 3 --durations=0 --verbose --junitxml=test-results/unit_tests.xml \
--cov=. --cov-append --cov-config .coveragerc \
Expand All @@ -122,8 +122,9 @@ jobs:
- run:
name: Integration Tests
no_output_timeout: 30m
command: |
. env/bin/activate
. .venv/bin/activate
export PYTHONUNBUFFERED=1
pytest -n2 --reruns 3 --reruns-delay 15 --durations=0 --verbose --junitxml=test-results/integration_tests.xml \
--cov=. --cov-append --cov-config .coveragerc \
Expand All @@ -143,7 +144,7 @@ jobs:
#- run:
#name: Upload Coverage
#command: |
#. env/bin/activate && coveralls
#. .venv/bin/activate && coveralls
#env:
#CI_NAME: circleci
#CI_BUILD_NUMBER: $CIRCLE_BUILD_NUM
Expand Down Expand Up @@ -173,8 +174,8 @@ jobs:
- run:
name: Update & Activate venv
command: |
python -m venv env/
. env/bin/activate
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install '.[dev]'
pip install flake8
Expand All @@ -188,19 +189,19 @@ jobs:
- run:
name: Install Bittensor
command: |
. env/bin/activate
. .venv/bin/activate
pip install -e '.[dev]'
- run:
name: Lint with flake8
command: |
. env/bin/activate
. .venv/bin/activate
python -m flake8 bittensor/ --count
- run:
name: Type check with mypy
command: |
. env/bin/activate
. .venv/bin/activate
python -m mypy --ignore-missing-imports bittensor/
unit-tests-all-python-versions:
Expand Down Expand Up @@ -290,7 +291,7 @@ workflows:

pr-requirements:
jobs:
- black:
- ruff:
python-version: "3.9.13"
- build-and-test:
matrix:
Expand Down
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: ""
file: "requirements/prod.txt"
schedule:
interval: "daily"
open-pull-requests-limit: 0 # Only security updates will be opened as PRs
84 changes: 84 additions & 0 deletions .github/workflows/e2e-subtensor-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: E2E Subtensor Tests

concurrency:
group: e2e-subtensor-${{ github.ref }}
cancel-in-progress: true

on:
## Run automatically for all PRs against main, regardless of what the changes are
## to be safe and so we can more easily force re-run the CI when github is being
## weird by using a blank commit
push:
branches: [main, development, staging]

##
# Run automatically for PRs against default/main branch if Rust files change
pull_request:
branches: [main, development, staging]

## Allow running workflow manually from the Actions tab
workflow_dispatch:
inputs:
verbose:
description: "Output more information when triggered manually"
required: false
default: ""

env:
CARGO_TERM_COLOR: always
VERBOSE: ${{ github.events.input.verbose }}

jobs:
run:
runs-on: SubtensorCI
strategy:
matrix:
rust-branch:
- nightly-2024-03-05
rust-target:
- x86_64-unknown-linux-gnu
# - x86_64-apple-darwin
os:
- ubuntu-latest
# - macos-latest
include:
- os: ubuntu-latest
# - os: macos-latest
env:
RELEASE_NAME: development
RUSTV: ${{ matrix.rust-branch }}
RUST_BACKTRACE: full
RUST_BIN_DIR: target/${{ matrix.rust-target }}
TARGET: ${{ matrix.rust-target }}
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
- name: Install Rust ${{ matrix.rust-branch }}
uses: actions-rs/[email protected]
with:
toolchain: ${{ matrix.rust-branch }}
components: rustfmt
profile: minimal

- name: Add wasm32-unknown-unknown target
run: |
rustup target add wasm32-unknown-unknown --toolchain stable-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain stable-x86_64-unknown-linux-gnu
- name: Clone subtensor repo
run: git clone https://github.com/opentensor/subtensor.git

- name: Setup subtensor repo
working-directory: ${{ github.workspace }}/subtensor
run: git checkout testnet

- name: Run tests
run: |
python3 -m pip install -e .[dev] pytest
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" pytest tests/e2e_tests/ -s
21 changes: 17 additions & 4 deletions bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,28 @@
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
import os
import warnings

from rich.console import Console
from rich.traceback import install

# Install and apply nest asyncio to allow the async functions
# to run in a .ipynb
import nest_asyncio

nest_asyncio.apply()
if (NEST_ASYNCIO_ENV := os.getenv("NEST_ASYNCIO")) in ("1", None):
if NEST_ASYNCIO_ENV is None:
warnings.warn(
"NEST_ASYNCIO implicitly set to '1'. In the future, the default value will be '0'."
"If you use `nest_asyncio` make sure to add it explicitly to your project dependencies,"
"as it will be removed from `bittensor` package dependencies in the future."
"To silence this warning, explicitly set the environment variable, e.g. `export NEST_ASYNCIO=0`.",
DeprecationWarning,
)
# Install and apply nest asyncio to allow the async functions
# to run in a .ipynb
import nest_asyncio

nest_asyncio.apply()


# Bittensor code and protocol version.
__version__ = "7.0.0"
Expand Down
12 changes: 7 additions & 5 deletions bittensor/axon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" Create and initialize Axon, which services the forward and backward requests from other neurons.
"""
"""Create and initialize Axon, which services the forward and backward requests from other neurons."""

# The MIT License (MIT)
# Copyright © 2021 Yuma Rao
Expand Down Expand Up @@ -57,6 +56,7 @@
SynapseException,
)
from bittensor.threadpool import PriorityThreadPoolExecutor
from bittensor.utils import networking


class FastAPIThreadedServer(uvicorn.Server):
Expand Down Expand Up @@ -393,7 +393,7 @@ def info(self) -> "bittensor.AxonInfo":
return bittensor.AxonInfo(
version=bittensor.__version_as_int__,
ip=self.external_ip,
ip_type=4,
ip_type=networking.ip_version(self.external_ip),
port=self.external_port,
hotkey=self.wallet.hotkey.ss58_address,
coldkey=self.wallet.coldkeypub.ss58_address,
Expand Down Expand Up @@ -942,8 +942,10 @@ def log_and_handle_error(
):
if isinstance(exception, SynapseException):
synapse = exception.synapse or synapse
# Display the traceback for user clarity.
bittensor.logging.trace(f"Forward exception: {traceback.format_exc()}")

bittensor.logging.trace(f"Forward handled exception: {exception}")
else:
bittensor.logging.trace(f"Forward exception: {traceback.format_exc()}")

if synapse.axon is None:
synapse.axon = bittensor.TerminalInfo()
Expand Down
Loading

0 comments on commit 28abbf3

Please sign in to comment.