-
Notifications
You must be signed in to change notification settings - Fork 6
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
add ssh remote connection & validator installation for sn12 #39
Merged
Merged
Changes from 45 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
fff2ba6
feat: add validator installation scripts
drunest 36e6be5
feat: add remote validator installation
drunest 439a22b
chore: update script files
drunest 51c4e58
feat: add remote installation
drunest d565298
feat: add action of installing validator on a remote server
drunest 219687c
feat: add local scripts directory path
drunest 213b0f2
chore: update scrips and secret
drunest 02dd38f
chore: update pdm dependencies
drunest 2f02c31
fix: update codespell
drunest d8c76b6
fix: update script file for linter
drunest b60b338
Merge branch 'master' into development
drunest 0e5bf69
feat: add local scripts directory path
drunest 51f3d7c
chore: update pdm dependencies
drunest af6d047
fix: udpate pdm lock
drunest a4c9374
feat: codename list on config file
drunest 802b818
feat: dumper commands and codename api
drunest 4126a22
feat: generating new child hotkey and hotkey option
drunest 2236701
chore: pdm dependencies
drunest 30327dc
chore: ruff format
drunest d820370
fix: store child hotkey to the model
drunest 40c4460
perf: remove normalizing codename api
drunest 408f542
fix: delete .env.template on local scripts
drunest 20db475
refactor: separate dumper commands and view
drunest e85643c
update: creat wallet
drunest 8feec14
update: add wallet info on settings
drunest 291a4ff
refactor: add ssh childhotkey class
drunest 7031184
perf: update utils
drunest e425673
fix: remove codename list
drunest 9dc4262
chore: update dependencies
drunest 6667ac6
chore: update chilhotkey
drunest cd62d68
refactor: revoke conftest
drunest bc6c88f
fix: update new version of wallet
drunest 944397b
fix: update test conf
drunest 7dea1d9
fix: test config
drunest c2582a0
chore: update dependencies
drunest e95e9c8
test: update config
drunest a34b0c5
fix: update scripts config path
drunest 15cea39
feat: add pulling scripts from github
drunest c87dc95
update: vsubnet configuration path
drunest 74a33ab
update: log format and error handling
drunest d0d7b9c
update: separate subnet scripts path and configuration file path
drunest 0eecc4e
feat: add celery task for fetching subnet scripts periodically
drunest 54b6441
fix: setting variable name on util
drunest 86f789f
fix: subnet config file path
drunest f97cd0c
fix: some erros on the comments
drunest 5077a80
fix: handling installation error
drunest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...dator/core/migrations/0012_rename_hw_requirements_subnet_hardware_description_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Generated by Django 4.2.16 on 2024-10-08 01:54 | ||
|
||
import django.contrib.postgres.fields | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0011_alter_subnet_hw_requirements"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name="subnet", | ||
old_name="hw_requirements", | ||
new_name="hardware_description", | ||
), | ||
migrations.RenameField( | ||
model_name="subnet", | ||
old_name="mainnet_id", | ||
new_name="mainnet_netuid", | ||
), | ||
migrations.RenameField( | ||
model_name="subnet", | ||
old_name="maintainers_ids", | ||
new_name="maintainer_discord_ids", | ||
), | ||
migrations.RenameField( | ||
model_name="subnet", | ||
old_name="owner_id", | ||
new_name="owner_discord_id", | ||
), | ||
migrations.RenameField( | ||
model_name="subnet", | ||
old_name="testnet_id", | ||
new_name="testnet_netuid", | ||
), | ||
migrations.AddField( | ||
model_name="subnet", | ||
name="allowed_secrets", | ||
field=django.contrib.postgres.fields.ArrayField( | ||
base_field=models.CharField(max_length=255), | ||
blank=True, | ||
null=True, | ||
size=None, | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="subnet", | ||
name="dumper_commands", | ||
field=django.contrib.postgres.fields.ArrayField( | ||
base_field=models.CharField(max_length=255), | ||
blank=True, | ||
null=True, | ||
size=None, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import logging | ||
import sys | ||
from io import StringIO | ||
|
||
from bittensor import Wallet | ||
from bittensor_cli import CLIManager | ||
|
||
from ..models import Hotkey | ||
|
||
|
||
class CLIManagerWrapper: | ||
def __init__(self): | ||
self.cli_manager = CLIManager() | ||
|
||
def __enter__(self): | ||
sys.stdin = StringIO("y\n") | ||
return self | ||
|
||
def __exit__(self, type, value, traceback): | ||
sys.stdin = sys.__stdin__ | ||
|
||
def stake_revoke_children(self, *args, **kwargs): | ||
result = self.cli_manager.stake_revoke_children(*args, **kwargs) | ||
return result | ||
|
||
def stake_get_children(self, *args, **kwargs): | ||
result = self.cli_manager.stake_get_children(*args, **kwargs) | ||
return result | ||
|
||
def stake_set_children(self, *args, **kwargs): | ||
result = self.cli_manager.stake_set_children(*args, **kwargs) | ||
return result | ||
|
||
|
||
class ChildHotkey: | ||
def __init__( | ||
self, parent_wallet_name: str, parent_hotkey_name: str, parent_wallet_path: str = "~/.bittensor/wallets" | ||
): | ||
self.logger = logging.getLogger(__name__) | ||
self.parent_wallet_name = parent_wallet_name | ||
self.parent_hotkey_name = parent_hotkey_name | ||
self.parent_wallet_path = parent_wallet_path | ||
|
||
def connect_to_parent_wallet(self): | ||
self.parent_wallet = Wallet(name=self.parent_wallet_name, hotkey=self.parent_hotkey_name) | ||
if not self.parent_wallet.coldkey_file.exists_on_device(): | ||
raise ValueError("Coldkey file for parent wallet %s not found.", self.parent_wallet_name) | ||
if not self.parent_wallet.hotkey_file.exists_on_device(): | ||
raise ValueError("Hotkey file for parent wallet %s not found.", self.parent_wallet_name) | ||
|
||
def __enter__(self): | ||
self.connect_to_parent_wallet() | ||
return self | ||
|
||
def create_new_child_hotkey( | ||
self, | ||
network: str, | ||
netuid: int, | ||
child_wallet_name: str, | ||
child_hotkey_name: str, | ||
proportion: float = 1, | ||
) -> str: | ||
child_wallet = Wallet(name=child_wallet_name, hotkey=child_hotkey_name) | ||
if not child_wallet.coldkey_file.exists_on_device(): | ||
child_wallet.create_new_coldkey(overwrite=False, use_password=False) | ||
if not child_wallet.hotkey_file.exists_on_device(): | ||
child_wallet.create_new_hotkey(overwrite=False, use_password=False) | ||
|
||
cli_manager = CLIManagerWrapper() | ||
|
||
with CLIManagerWrapper() as cli_manager: | ||
cli_manager.stake_set_children( | ||
wallet_name=self.parent_wallet_name, | ||
wallet_hotkey=self.parent_hotkey_name, | ||
wallet_path=self.parent_wallet_path, | ||
network=network, | ||
netuid=netuid, | ||
all_netuids=False, | ||
children=[child_wallet.hotkey.ss58_address], | ||
proportions=[proportion], | ||
quiet=True, | ||
verbose=False, | ||
wait_for_finalization=True, | ||
wait_for_inclusion=True, | ||
) | ||
Hotkey.objects.create(hotkey=child_wallet.hotkey.ss58_address) | ||
return child_wallet.hotkey.ss58_address | ||
|
||
def get_child_hotkeys(self, network: str, netuid: int): | ||
with CLIManagerWrapper() as cli_manager: | ||
result = cli_manager.stake_get_children( | ||
wallet_name=self.parent_wallet_name, | ||
wallet_hotkey=self.parent_hotkey_name, | ||
wallet_path=self.parent_wallet_path, | ||
network=network, | ||
netuid=netuid, | ||
all_netuids=False, | ||
quiet=True, | ||
verbose=False, | ||
) | ||
return result | ||
|
||
def revoke_child_hotkeys( | ||
self, | ||
network: str, | ||
netuid: int, | ||
) -> bool: | ||
with CLIManagerWrapper() as cli_manager: | ||
cli_manager.stake_revoke_children( | ||
wallet_name=self.parent_wallet_name, | ||
wallet_hotkey=self.parent_hotkey_name, | ||
wallet_path=self.parent_wallet_path, | ||
network=network, | ||
netuid=netuid, | ||
all_netuids=False, | ||
quiet=True, | ||
verbose=False, | ||
wait_for_finalization=True, | ||
wait_for_inclusion=True, | ||
) | ||
return True |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and then the caller doesn't need to
with
but can just call a method