Skip to content

Commit

Permalink
Merge pull request #261 from neuralinternet/feature/CSN-505-Add-the-e…
Browse files Browse the repository at this point in the history
…nd-of-file-fixer

feat: add end-of-file-fixer hook
  • Loading branch information
IvanAnishchuk authored Feb 4, 2025
2 parents 62d7c74 + 1cec92d commit b5d8f58
Show file tree
Hide file tree
Showing 36 changed files with 258 additions and 232 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ workflows:
- check_compatibility:
python_version: "3.11"
name: check-compatibility-3.11

pr-requirements:
jobs:
- black:
Expand Down
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
d4662ec50280115abffc47b952cf99703bfcce6d
a6e5c05f21d2304f7ece2273b45f63ff6cde51a6
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
include:
- language: python
build-mode: none
# CodeQL supports the following values for 'language':
# CodeQL supports the following values for 'language':
# 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
Expand All @@ -51,7 +51,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Cache Python dependencies
uses: actions/cache@v3
with:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pre-commit

on:
pull_request:
push:
branches: ["dev", "main"]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,5 @@ cert/
# wandb
wandb/

# neural internet register api
# neural internet register api
neurons/register-api/
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ repos:
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.20.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-angular']
additional_dependencies: ['@commitlint/config-angular']
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,3 @@ We are committed to providing a welcoming and inclusive environment. All partici
If you have any questions or need further guidance, don't hesitate to ask for help in our [community channels](https://discord.gg/t7BMee4w). Our community and maintainers are here to support you.

Thank you for contributing to the Compute Subnet! Together, we're building the future of decentralized computing.

2 changes: 1 addition & 1 deletion Installation Script/SN27 Installer Instructions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Bittensor/Compute Subnet Installer Script
This repository contains an installation script for setting up a Bittensor miner with the necessary dependencies and configurations for SN27 (Subnet 27) of the Bittensor network. This installation process requires Ubuntu 22.04. You are limited to one external IP per UID. There is automatic blacklisting in place if validators detect anomalous behavior.
This repository contains an installation script for setting up a Bittensor miner with the necessary dependencies and configurations for SN27 (Subnet 27) of the Bittensor network. This installation process requires Ubuntu 22.04. You are limited to one external IP per UID. There is automatic blacklisting in place if validators detect anomalous behavior.


## Features
Expand Down
38 changes: 19 additions & 19 deletions Installation Script/install_sn27.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ohai() {
cd "/usr" || exit 1

linux_install_pre() {
sudo apt-get update
sudo apt-get update
sudo apt-get install --no-install-recommends --no-install-suggests -y apt-utils curl git cmake build-essential ca-certificates

# Add Docker's official GPG key:
Expand Down Expand Up @@ -110,10 +110,10 @@ linux_install_python() {
ohai "Updating python"
sudo apt-get install --only-upgrade $python
fi
exit_on_error $?
exit_on_error $?
ohai "Installing python tools"
sudo apt-get install --no-install-recommends --no-install-suggests -y $python-pip $python-dev
exit_on_error $?
sudo apt-get install --no-install-recommends --no-install-suggests -y $python-pip $python-dev
exit_on_error $?
}

linux_update_pip() {
Expand All @@ -129,7 +129,7 @@ linux_install_bittensor() {
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)
ohai "Installing bittensor"
$python -m pip install -e ~/.bittensor/bittensor/
exit_on_error $?
exit_on_error $?
}

linux_increase_ulimit(){
Expand Down Expand Up @@ -158,20 +158,20 @@ linux_install_compute_subnet() {
ohai "Cloning Compute-Subnet into ~/Compute-Subnet"
mkdir -p ~/Compute-Subnet
git clone https://github.com/neuralinternet/Compute-Subnet.git ~/Compute-Subnet/ 2> /dev/null || (cd ~/Compute-Subnet/ ; git pull --ff-only ; git reset --hard ; git clean -xdf)

ohai "Installing Compute-Subnet dependencies"
cd ~/Compute-Subnet
$python -m pip install -r requirements.txt
$python -m pip install --no-deps -r requirements-compute.txt
$python -m pip install -e .
sudo apt -y install ocl-icd-libopencl1 pocl-opencl-icd

ohai "Starting Docker service, adding user to docker, and installing 'at' package"
sudo groupadd docker
sudo usermod -aG docker $USER
sudo systemctl start docker
sudo apt install -y at

cd ~
exit_on_error $?
}
Expand Down Expand Up @@ -240,15 +240,15 @@ if [[ "$OS" == "Linux" ]]; then
abort "This linux based install requires apt. To run with other distros (centos, arch, etc), you will need to manually install the requirements"
fi
echo """
░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓████████▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓███████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓████████▓▒░ ░▒▓█▓▒░
░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓████████▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
░▒▓███████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓████████▓▒░ ░▒▓█▓▒░
- Bittensor; Mining a new element.
"""
ohai "This script will install:"
Expand Down Expand Up @@ -297,14 +297,14 @@ if [[ "$OS" == "Linux" ]]; then

elif [[ "$OS" == "Darwin" ]]; then
echo """
██████╗░██╗████████╗████████╗███████╗███╗░░██╗░██████╗░█████╗░██████╗░
██╔══██╗██║╚══██╔══╝╚══██╔══╝██╔════╝████╗░██║██╔════╝██╔══██╗██╔══██╗
██████╦╝██║░░░██║░░░░░░██║░░░█████╗░░██╔██╗██║╚█████╗░██║░░██║██████╔╝
██╔══██╗██║░░░██║░░░░░░██║░░░██╔══╝░░██║╚████║░╚═══██╗██║░░██║██╔══██╗
██████╦╝██║░░░██║░░░░░░██║░░░███████╗██║░╚███║██████╔╝╚█████╔╝██║░░██║
╚═════╝░╚═╝░░░╚═╝░░░░░░╚═╝░░░╚══════╝╚═╝░░╚══╝╚═════╝░░╚════╝░╚═╝░░╚═╝
- Mining a new element.
"""
ohai "This script will install:"
Expand Down
12 changes: 12 additions & 0 deletions QA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Style guide and linting tools

We are starting to introduce pre-commit and adding checks to it and enabling GitHub Actions.

Locally, start by installing pre-commit package and running `pre-commit install --install-hooks`. It will ensure checksare being run before each commit is made.

Autolinting commits (made after running `pre-commit run -a` and fixing all files with new checks) are to be recorded in `.git-blame-ignore-revs` and that file can be used with git blame and git config snippet like this (or command-line `--ignore-revs-file`) to skip such commits when examining history.

```
[blame]
ignoreRevsFile = .git-blame-ignore-revs
```
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This repository serves as a compute-composable subnet, integrating various cloud

## Installation

This repository requires python3.8 or higher. To install, simply clone this repository and install the requirements. You are limited to one external IP per UID. There is automatic blacklisting in place if validators detect anomalous behavior.
This repository requires python3.8 or higher. To install, simply clone this repository and install the requirements. You are limited to one external IP per UID. There is automatic blacklisting in place if validators detect anomalous behavior.

### Bittensor

Expand Down Expand Up @@ -143,7 +143,7 @@ If you have more complicated needs, see the [subtensor](https://github.com/opent
# Running a Miner / Validator

Prior to running a miner or validator, you must [create a wallet](https://github.com/opentensor/docs/blob/main/reference/btcli.md)
and [register the wallet to a netuid](https://github.com/opentensor/docs/blob/main/subnetworks/registration.md).
and [register the wallet to a netuid](https://github.com/opentensor/docs/blob/main/subnetworks/registration.md).
Once you have done so, you can run the miner and validator with the following commands.

## Running Miner
Expand All @@ -157,7 +157,7 @@ It is important to ensure that port 4444 is open on the host machine or that an
```bash
# To run the miner
cd neurons
python -m miner.py
python -m miner.py
--netuid <your netuid> # The subnet id you want to connect to
--subtensor.network <your chain url> # blockchain endpoint you want to connect
--wallet.name <your miner wallet> # name of your wallet
Expand Down Expand Up @@ -374,8 +374,8 @@ Enter any additional options for hashcat to use. It's recommended to use the ```
> "I don't receive any request, 'Challenge' or 'Specs' or 'Allocation', what could be the reason ?"
Starting from v1.6.0, hashcat challenge benchmarking is no longer performed.
Most probably you are running into a **network issue**.
- check your ports
Most probably you are running into a **network issue**.
- check your ports
- check your firewall

> "I have been deregistered, why ?"
Expand Down
2 changes: 1 addition & 1 deletion cert/gen_ca.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ echo "3.5. Convert the cer to PEM CRT format"
openssl x509 -inform PEM -in client.cer -out client.crt

echo "3.6. Clean up - now that the cert has been created, we no longer need the request."
rm client.req
rm client.req
2 changes: 1 addition & 1 deletion commitlint-config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']}
module.exports = {extends: ['@commitlint/config-conventional']}
8 changes: 4 additions & 4 deletions compute/axon.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from bittensor.core.types import AxonServeCallParams
from bittensor_wallet import Wallet
from bittensor.core.subtensor import Subtensor

def custom_serve_extrinsic(
subtensor: "Subtensor",
wallet: "Wallet",
Expand Down Expand Up @@ -188,7 +188,7 @@ def __init__(
external_port (:type:`Optional[int]`): The external port of the server to broadcast to the network.
max_workers (:type:`Optional[int]`): Used to create the threadpool if not passed, specifies the number of active threads servicing requests.
"""

# Build and check config.
if config is None:
config = axon.config()
Expand Down Expand Up @@ -220,13 +220,13 @@ def __init__(
)
self.full_address = str(self.config.axon.ip) + ":" + str(self.config.axon.port) # type: ignore
self.started = False

# Build middleware
self.thread_pool = PriorityThreadPoolExecutor(
max_workers=self.config.axon.max_workers # type: ignore
)
self.nonces: dict[str, int] = {}

# Request default functions.
self.forward_class_types: dict[str, list[Signature]] = {}
self.blacklist_fns: dict[str, Callable | None] = {}
Expand Down
2 changes: 1 addition & 1 deletion compute/utils/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def check_port(host, port):
return None
except socket.error:
bt.logging.error(f"API: Couldn't connect to server {host}")
return None
return None
6 changes: 3 additions & 3 deletions compute/utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_local_version():
here = path.abspath(path.dirname(__file__))
parent = here.rsplit("/", 1)[0]
init_file_path = os.path.join(parent, "__init__.py")

with codecs.open(init_file_path, encoding="utf-8") as init_file:
content = init_file.read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", content, re.M)
Expand Down Expand Up @@ -123,7 +123,7 @@ def update_repo():
if stashed:
bt.logging.info("Applying stashed changes")
repo.git.stash('apply', '--index')

# Restore the specific file from remote to ensure it is not overwritten by stash
repo.git.checkout('origin/main', '--', 'compute/__init__.py')

Expand Down Expand Up @@ -225,4 +225,4 @@ def check_hashcat_version(hashcat_path: str = "hashcat"):
bt.logging.error(
"Hashcat is not available nor installed on the machine. Please make sure hashcat is available in your PATH or give the explicit location using the following argument: --miner.hashcat.path"
)
exit()
exit()
Loading

0 comments on commit b5d8f58

Please sign in to comment.