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: add self-commands request to server #5

Merged
merged 8 commits into from
Oct 8, 2024

Conversation

drunest
Copy link
Contributor

@drunest drunest commented Sep 28, 2024

Fix the autodetection of bittensor wallet
Fix the commands as list type
Add the feature for requesting commands to auto-validator server

Comment on lines 18 to 22
CODENAME_MAP = {
"computehorde": ["sn12", "12", "computehorde"],
"omron": ["sn13", "13", "omron", "Omron"],
"textprompting": ["sn14", "14", "textprompting"],
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has to be retrieved from the autovalidator, should not be hardcoded here

@@ -57,49 +71,46 @@ def main(apiver: str | None = None):

if not (subnet_identifier := args.subnet_identifier) or not (autovalidator_address := args.autovalidator_address):
autovalidator_address, subnet_identifier = load_config(config_path=config_path)
dump_and_upload(subnet_identifier, args.subnet_realm, autovalidator_address, args.note)
filtered_subnet_identifier = re.sub(r"[_\-.]", "", str.lower(subnet_identifier))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this line to normalize_codename()

@@ -250,5 +263,37 @@ def update_confg(config_path: str, new_autovalidator_address: str, new_codename:
raise RuntimeError(f"Failed to write to the configuration file: {config_path}.\n Error: {e}")


def request_commands_to_server(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def request_commands_to_server(
def request_commands_from_server(

src/bt_auto_dumper/_v2/__main__.py Outdated Show resolved Hide resolved
src/bt_auto_dumper/_v2/__main__.py Show resolved Hide resolved
src/bt_auto_dumper/_v2/__main__.py Outdated Show resolved Hide resolved
src/bt_auto_dumper/_v2/__main__.py Outdated Show resolved Hide resolved
src/bt_auto_dumper/_v2/__main__.py Outdated Show resolved Hide resolved
src/bt_auto_dumper/_v2/__main__.py Outdated Show resolved Hide resolved
src/bt_auto_dumper/_v2/__main__.py Outdated Show resolved Hide resolved
src/bt_auto_dumper/_v2/__main__.py Outdated Show resolved Hide resolved
src/bt_auto_dumper/_v2/__main__.py Outdated Show resolved Hide resolved
src/bt_auto_dumper/_v2/__main__.py Outdated Show resolved Hide resolved
Comment on lines 106 to 108
logger.info(f"Subnet dumper commands of {subnet_identifier} retrieved successfully. {commands}")
if not commands:
print(f"Subnet identifier {subnet_identifier} not found.")
logger.error(f"Subnet dumper commands of {subnet_identifier} not found.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there are no commands, both of those logs will be emitted

@@ -277,46 +283,13 @@ def get_commands_from_server(
response = make_signed_request("GET", url, headers, "", wallet, subnet_realm)
if response.status_code == 200:
data = response.json()
print(data)
print("Commands successfully retrieved.")
logger.info("Commands successfully retrieved.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.info("Commands successfully retrieved.")

this duplicates a log statement from main.py line 106

commands = get_commands_from_server(subnet_identifier, subnet_realm, wallet, autovalidator_address)

# get normalized subnet identifier and commands from the central server
subnet_identifier, commands = get_commands_from_server(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to docstring and return type of get_commands_from_server(), the function only returns commands and does not return a subnet identifier


args = parser.parse_args()

# Get configuration directory from env variable.
config_base_dir = os.getenv("CONFIG_DIR")
config_base_dir = os.getenv("CONFIG_DIR", default="")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
config_base_dir = os.getenv("CONFIG_DIR", default="")
config_base_dir = os.getenv("CONFIG_DIR", default=`~/.config/bt-auto-dumper`)


wallet = bt.wallet(name="validator", hotkey="validator-hotkey", path="~/.bittensor/wallets")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should all be taken from the config, but should have defaults

wallet
"/path/test.zip",
wallet,
"mainnet"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"mainnet"
"mainnet",

Comment on lines +59 to +60
autovalidator_address, subnet_identifier, __, __, __ = load_config(config_path=config_path)
__, __, wallet_name, wallet_hotkey, wallet_path = load_config(config_path=config_path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not good but I'm so tired of this PR I'll let it slide

@ppolewicz ppolewicz merged commit 64ad702 into bactensor:master Oct 8, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants