Skip to content

Commit

Permalink
[hotfix] fix flags for multiproc register limit (#876)
Browse files Browse the repository at this point in the history
* add dot get

* add to subtensor args and defaults

* remove dot get because in subtensor args

* typo

* fix test
  • Loading branch information
Cameron Fairchild authored Aug 12, 2022
1 parent 4288c3a commit 4629b82
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
17 changes: 0 additions & 17 deletions bittensor/_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,23 +571,6 @@ def config() -> 'bittensor.config':
help='''Set true to avoid prompting the user.''',
default=False,
)
register_parser.add_argument(
'--num_processes',
'--num',
'-n',
dest='num_processes',
help="Number of processors to use for registration",
type=int,
default=None,
)
register_parser.add_argument(
'--update_interval',
'-u',
dest='update_interval',
help="The number of nonces to process before checking for next block during registration",
type=int,
default=None,
)

bittensor.wallet.add_args( register_parser )
bittensor.subtensor.add_args( register_parser )
Expand Down
2 changes: 1 addition & 1 deletion bittensor/_cli/cli_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def register( self ):
"""
wallet = bittensor.wallet( config = self.config )
subtensor = bittensor.subtensor( config = self.config )
subtensor.register( wallet = wallet, prompt = not self.config.no_prompt, num_processes = self.config.num_processes, update_interval = self.config.update_interval )
subtensor.register( wallet = wallet, prompt = not self.config.no_prompt, num_processes = self.config.subtensor.register.num_processes, update_interval = self.config.subtensor.register.update_interval )

def transfer( self ):
r""" Transfer token of amount to destination.
Expand Down
7 changes: 7 additions & 0 deletions bittensor/_subtensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ def add_args(cls, parser: argparse.ArgumentParser, prefix: str = None ):
help='''The subtensor endpoint flag. If set, overrides the --network flag.
''')
parser.add_argument('--' + prefix_str + 'subtensor._mock', action='store_true', help='To turn on subtensor mocking for testing purposes.', default=bittensor.defaults.subtensor._mock)

parser.add_argument('--' + prefix_str + 'subtensor.register.num_processes', '-n', dest='subtensor.register.num_processes', help="Number of processors to use for registration", type=int, default=bittensor.defaults.subtensor.register.num_processes)
parser.add_argument('--' + prefix_str + 'subtensor.register.update_interval', '-u', dest='subtensor.register.update_interval', help="The number of nonces to process before checking for next block during registration", type=int, default=bittensor.defaults.subtensor.register.update_interval)
except argparse.ArgumentError:
# re-parsing arguments.
pass
Expand All @@ -197,6 +200,10 @@ def add_defaults(cls, defaults ):
defaults.subtensor.chain_endpoint = os.getenv('BT_SUBTENSOR_CHAIN_ENDPOINT') if os.getenv('BT_SUBTENSOR_CHAIN_ENDPOINT') != None else None
defaults.subtensor._mock = os.getenv('BT_SUBTENSOR_MOCK') if os.getenv('BT_SUBTENSOR_MOCK') != None else False

defaults.subtensor.register = bittensor.Config()
defaults.subtensor.register.num_processes = os.getenv('BT_SUBTENSOR_REGISTER_NUM_PROCESSES') if os.getenv('BT_SUBTENSOR_REGISTER_NUM_PROCESSES') != None else None # uses processor count by default within the function
defaults.subtensor.register.update_interval = os.getenv('BT_SUBTENSOR_REGISTER_UPDATE_INTERVAL') if os.getenv('BT_SUBTENSOR_REGISTER_UPDATE_INTERVAL') != None else 50_000

@staticmethod
def check_config( config: 'bittensor.Config' ):
assert config.subtensor
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,8 @@ def test_register( self ):
config = self.config
config.subtensor._mock = True
config.command = "register"
config.num_processes = 1
config.update_interval = 50_000
config.subtensor.register.num_processes = 1
config.subtensor.register.update_interval = 50_000
config.subtensor.network = "mock"
config.no_prompt = True

Expand Down

0 comments on commit 4629b82

Please sign in to comment.