Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/roman/reafctoring-before-test-coverage #2230

Merged
merged 3 commits into from
Aug 13, 2024
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
2 changes: 1 addition & 1 deletion bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import warnings

from .core.settings import __version__, version_split, DEFAULTS
from .utils.deprecated import *
from .utils.btlogging import logging
from .utils.deprecated import *


def __getattr__(name):
Expand Down
21 changes: 21 additions & 0 deletions bittensor/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The MIT License (MIT)
# Copyright © 2024 Opentensor Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# 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.

from bittensor import __version__

if __name__ == "__main__":
print(f"Bittensor SDK version: {__version__}")
4 changes: 2 additions & 2 deletions bittensor/core/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
from scalecodec.types import GenericCall
from scalecodec.utils.ss58 import ss58_encode

from .settings import SS58_FORMAT
from bittensor.utils import networking as net, RAOPERTAO, u16_normalized_float
from bittensor.utils.balance import Balance
from bittensor.utils.registration import torch, use_torch
from bittensor.utils.btlogging import logging
from bittensor.utils.registration import torch, use_torch
from .settings import SS58_FORMAT

custom_rpc_type_registry = {
"types": {
Expand Down
9 changes: 5 additions & 4 deletions bittensor/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
# 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 argparse
import copy
import os
import sys
import yaml
import copy
from copy import deepcopy
from munch import DefaultMunch
from typing import List, Optional, Dict, Any, TypeVar, Type
import argparse

import yaml
from munch import DefaultMunch


class InvalidConfigFile(Exception):
Expand Down
5 changes: 2 additions & 3 deletions bittensor/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
import os
import re
from pathlib import Path
from rich.console import Console
from rich.traceback import install

from munch import munchify

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

# Rich console.
__console__ = Console()
Expand Down
41 changes: 20 additions & 21 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@
from scalecodec.types import ScaleType
from substrateinterface.base import QueryMapResult, SubstrateInterface

from bittensor.core import settings
from bittensor.core.axon import Axon
from bittensor.core.chain_data import (
NeuronInfo,
PrometheusInfo,
SubnetHyperparameters,
NeuronInfoLite,
custom_rpc_type_registry,
)
from bittensor.core.config import Config
from bittensor.core.metagraph import Metagraph
from bittensor.core.types import AxonServeCallParams, PrometheusServeCallParams
from bittensor.utils import torch, format_error_message
from bittensor.utils import u16_normalized_float, networking
from bittensor.utils.balance import Balance
from bittensor.utils.btlogging import logging
from bittensor.utils.deprecated.extrinsics.commit_weights import (
commit_weights_extrinsic,
reveal_weights_extrinsic,
)
from bittensor.utils.deprecated.extrinsics.prometheus import (
prometheus_extrinsic,
)
Expand All @@ -49,31 +69,10 @@
from bittensor.utils.deprecated.extrinsics.set_weights import (
set_weights_extrinsic,
)
from bittensor.utils.deprecated.extrinsics.commit_weights import (
commit_weights_extrinsic,
reveal_weights_extrinsic,
)
from bittensor.utils.deprecated.extrinsics.transfer import (
transfer_extrinsic,
)
from bittensor.utils.weight_utils import generate_weight_hash
from bittensor.core import settings
from bittensor.core.axon import Axon
from bittensor.core.chain_data import (
NeuronInfo,
PrometheusInfo,
SubnetHyperparameters,
NeuronInfoLite,
custom_rpc_type_registry,
)
from bittensor.core.config import Config
from bittensor.core.metagraph import Metagraph
from bittensor.core.types import AxonServeCallParams, PrometheusServeCallParams
from bittensor.utils import u16_normalized_float, networking
from bittensor.utils import torch, format_error_message
from bittensor.utils.balance import Balance
from bittensor.utils.btlogging import logging


KEY_NONCE: Dict[str, int] = {}

Expand Down
8 changes: 5 additions & 3 deletions bittensor/core/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
# 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 numpy as np
import base64
from typing import Optional, Union, List

import msgpack
import msgpack_numpy
from typing import Optional, Union, List
from bittensor.utils.registration import torch, use_torch
import numpy as np
from pydantic import ConfigDict, BaseModel, Field, field_validator

from bittensor.utils.registration import torch, use_torch


class DTypes(dict):
def __init__(self, *args, **kwargs):
Expand Down
17 changes: 8 additions & 9 deletions bittensor/core/threadpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@

__author__ = "Brian Quinlan ([email protected])"

import argparse
import itertools
import logging
import os
import sys
import time
import queue
import random
import weakref
import logging
import argparse
import itertools
import sys
import threading

from typing import Callable
import time
import weakref
from concurrent.futures import _base
from typing import Callable

from bittensor.core.config import Config
from bittensor.utils.btlogging.defines import BITTENSOR_LOGGER_NAME
from bittensor.core.settings import BLOCKTIME
from bittensor.utils.btlogging.defines import BITTENSOR_LOGGER_NAME

# Workers are created as daemon threads. This is done to allow the interpreter
# to exit when there are still idle threads in a ThreadPoolExecutor's thread
Expand Down
1 change: 0 additions & 1 deletion bittensor/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from .registration import torch, use_torch
from .version import version_checking, check_version, VersionCheckError


RAOPERTAO = 1e9
U16_MAX = 65535
U64_MAX = 18446744073709551615
Expand Down
1 change: 0 additions & 1 deletion bittensor/utils/btlogging/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

from colorama import init, Fore, Back, Style


init(autoreset=True)

TRACE_LEVEL_NUM: int = 5
Expand Down
1 change: 0 additions & 1 deletion bittensor/utils/btlogging/loggingmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from statemachine import State, StateMachine

from bittensor.core.config import Config

from .defines import (
BITTENSOR_LOGGER_NAME,
DATE_FORMAT,
Expand Down
2 changes: 1 addition & 1 deletion bittensor/utils/deprecated/extrinsics/set_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from numpy.typing import NDArray
from rich.prompt import Confirm

from bittensor.utils import weight_utils
from bittensor.core.settings import bt_console
from bittensor.utils import weight_utils
from bittensor.utils.btlogging import logging
from bittensor.utils.registration import torch, use_torch

Expand Down
2 changes: 1 addition & 1 deletion bittensor/utils/deprecated/extrinsics/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

from typing import Union, TYPE_CHECKING

from bittensor_wallet import Wallet
from rich.prompt import Confirm

from bittensor.core.settings import bt_console, NETWORK_EXPLORER_MAP
from bittensor.utils import get_explorer_url_for_network
from bittensor.utils import is_valid_bittensor_address_or_public_key
from bittensor.utils.balance import Balance
from bittensor_wallet import Wallet

# For annotation purposes
if TYPE_CHECKING:
Expand Down
3 changes: 1 addition & 2 deletions bittensor/utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import requests
from packaging.version import Version

from bittensor.core.settings import __version__
from bittensor.core.settings import PIPADDRESS
from bittensor.core.settings import __version__, PIPADDRESS
from bittensor.utils.btlogging import logging

VERSION_CHECK_THRESHOLD = 86400
Expand Down
2 changes: 1 addition & 1 deletion requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ termcolor
tqdm
uvicorn
wheel
git+https://github.com/opentensor/btwallet.git@main#egg=bittensor-wallet
git+ssh://git@github.com/opentensor/btwallet.git@main#egg=bittensor-wallet