@@ -618,6 +618,7 @@ def __init__(self):
618
618
"wallet_hotkey" : None ,
619
619
"network" : None ,
620
620
"use_cache" : True ,
621
+ "disk_cache" : False ,
621
622
"rate_tolerance" : None ,
622
623
"safe_staking" : True ,
623
624
"allow_partial_stake" : False ,
@@ -1087,6 +1088,7 @@ def initialize_chain(
1087
1088
"Verify this is intended." ,
1088
1089
)
1089
1090
if not self .subtensor :
1091
+ use_disk_cache = self .config .get ("disk_cache" , False )
1090
1092
if network :
1091
1093
network_ = None
1092
1094
for item in network :
@@ -1103,15 +1105,15 @@ def initialize_chain(
1103
1105
f"[{ COLORS .G .ARG } ]{ ', ' .join (not_selected_networks )} [/{ COLORS .G .ARG } ]"
1104
1106
)
1105
1107
1106
- self .subtensor = SubtensorInterface (network_ )
1108
+ self .subtensor = SubtensorInterface (network_ , use_disk_cache = use_disk_cache )
1107
1109
elif self .config ["network" ]:
1108
1110
console .print (
1109
1111
f"Using the specified network [{ COLORS .G .LINKS } ]{ self .config ['network' ]} "
1110
1112
f"[/{ COLORS .G .LINKS } ] from config"
1111
1113
)
1112
- self .subtensor = SubtensorInterface (self .config ["network" ])
1114
+ self .subtensor = SubtensorInterface (self .config ["network" ], use_disk_cache = use_disk_cache )
1113
1115
else :
1114
- self .subtensor = SubtensorInterface (defaults .subtensor .network )
1116
+ self .subtensor = SubtensorInterface (defaults .subtensor .network , use_disk_cache = use_disk_cache )
1115
1117
return self .subtensor
1116
1118
1117
1119
def _run_command (self , cmd : Coroutine , exit_early : bool = True ):
@@ -1268,6 +1270,13 @@ def set_config(
1268
1270
help = "Disable caching of some commands. This will disable the `--reuse-last` and `--html` flags on "
1269
1271
"commands such as `subnets metagraph`, `stake show` and `subnets list`." ,
1270
1272
),
1273
+ disk_cache : Optional [bool ] = typer .Option (
1274
+ None ,
1275
+ "--disk-cache/--no-disk-cache" ,
1276
+ " /--no-disk-cache" ,
1277
+ help = "Enables or disables the caching on disk. Enabling this can significantly speed up commands run "
1278
+ "sequentially"
1279
+ ),
1271
1280
rate_tolerance : Optional [float ] = typer .Option (
1272
1281
None ,
1273
1282
"--tolerance" ,
@@ -1314,12 +1323,13 @@ def set_config(
1314
1323
"wallet_hotkey" : wallet_hotkey ,
1315
1324
"network" : network ,
1316
1325
"use_cache" : use_cache ,
1326
+ "disk_cache" : disk_cache ,
1317
1327
"rate_tolerance" : rate_tolerance ,
1318
1328
"safe_staking" : safe_staking ,
1319
1329
"allow_partial_stake" : allow_partial_stake ,
1320
1330
"dashboard_path" : dashboard_path ,
1321
1331
}
1322
- bools = ["use_cache" , "safe_staking" , "allow_partial_stake" ]
1332
+ bools = ["use_cache" , "disk_cache" , " safe_staking" , "allow_partial_stake" ]
1323
1333
if all (v is None for v in args .values ()):
1324
1334
# Print existing configs
1325
1335
self .get_config ()
0 commit comments