Skip to content

Commit 102a072

Browse files
committed
Handle netuid not set
1 parent 66fc4ae commit 102a072

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

cli.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -3159,7 +3159,11 @@ def subnets_register(
31593159

31603160
def subnets_metagraph(
31613161
self,
3162-
netuid: int = Options.netuid,
3162+
netuid: Optional[int] = typer.Option(
3163+
None,
3164+
help="The netuid (network unique identifier) of the subnet within the root network, (e.g. 1). This does"
3165+
"is ignored when used with `--reuse-last`.",
3166+
),
31633167
network: str = Options.network,
31643168
chain: str = Options.chain,
31653169
reuse_last: bool = typer.Option(
@@ -3234,8 +3238,15 @@ def subnets_metagraph(
32343238
not as a standalone function within user code.
32353239
"""
32363240
if reuse_last:
3241+
if netuid is not None:
3242+
console.print("Cannot specify netuid when using `--reuse-last`")
3243+
raise typer.Exit()
32373244
subtensor = None
32383245
else:
3246+
if netuid is None:
3247+
netuid = rich.prompt.IntPrompt.ask(
3248+
"Enter the netuid (network unique identifier) of the subnet within the root network, (e.g. 1)."
3249+
)
32393250
subtensor = self.initialize_chain(network, chain)
32403251
return self._run_command(
32413252
subnets.metagraph_cmd(subtensor, netuid, reuse_last, html_output)

src/commands/subnets.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,10 @@ async def register(wallet: Wallet, subtensor: "SubtensorInterface", netuid: int)
329329

330330

331331
async def metagraph_cmd(
332-
subtensor: "SubtensorInterface", netuid: int, reuse_last: bool, html_output: bool
332+
subtensor: "SubtensorInterface",
333+
netuid: Optional[int],
334+
reuse_last: bool,
335+
html_output: bool,
333336
):
334337
"""Prints an entire metagraph."""
335338
# TODO allow config to set certain columns

0 commit comments

Comments
 (0)