@@ -623,6 +623,7 @@ def __init__(self):
623
623
"wallet_hotkey" : None ,
624
624
"network" : None ,
625
625
"use_cache" : True ,
626
+ "disk_cache" : False ,
626
627
"rate_tolerance" : None ,
627
628
"safe_staking" : True ,
628
629
"allow_partial_stake" : False ,
@@ -1092,6 +1093,7 @@ def initialize_chain(
1092
1093
"Verify this is intended." ,
1093
1094
)
1094
1095
if not self .subtensor :
1096
+ use_disk_cache = self .config .get ("disk_cache" , False )
1095
1097
if network :
1096
1098
network_ = None
1097
1099
for item in network :
@@ -1108,15 +1110,21 @@ def initialize_chain(
1108
1110
f"[{ COLORS .G .ARG } ]{ ', ' .join (not_selected_networks )} [/{ COLORS .G .ARG } ]"
1109
1111
)
1110
1112
1111
- self .subtensor = SubtensorInterface (network_ )
1113
+ self .subtensor = SubtensorInterface (
1114
+ network_ , use_disk_cache = use_disk_cache
1115
+ )
1112
1116
elif self .config ["network" ]:
1113
1117
console .print (
1114
1118
f"Using the specified network [{ COLORS .G .LINKS } ]{ self .config ['network' ]} "
1115
1119
f"[/{ COLORS .G .LINKS } ] from config"
1116
1120
)
1117
- self .subtensor = SubtensorInterface (self .config ["network" ])
1121
+ self .subtensor = SubtensorInterface (
1122
+ self .config ["network" ], use_disk_cache = use_disk_cache
1123
+ )
1118
1124
else :
1119
- self .subtensor = SubtensorInterface (defaults .subtensor .network )
1125
+ self .subtensor = SubtensorInterface (
1126
+ defaults .subtensor .network , use_disk_cache = use_disk_cache
1127
+ )
1120
1128
return self .subtensor
1121
1129
1122
1130
def _run_command (self , cmd : Coroutine , exit_early : bool = True ):
@@ -1273,6 +1281,13 @@ def set_config(
1273
1281
help = "Disable caching of some commands. This will disable the `--reuse-last` and `--html` flags on "
1274
1282
"commands such as `subnets metagraph`, `stake show` and `subnets list`." ,
1275
1283
),
1284
+ disk_cache : Optional [bool ] = typer .Option (
1285
+ None ,
1286
+ "--disk-cache/--no-disk-cache" ,
1287
+ " /--no-disk-cache" ,
1288
+ help = "Enables or disables the caching on disk. Enabling this can significantly speed up commands run "
1289
+ "sequentially" ,
1290
+ ),
1276
1291
rate_tolerance : Optional [float ] = typer .Option (
1277
1292
None ,
1278
1293
"--tolerance" ,
@@ -1319,12 +1334,13 @@ def set_config(
1319
1334
"wallet_hotkey" : wallet_hotkey ,
1320
1335
"network" : network ,
1321
1336
"use_cache" : use_cache ,
1337
+ "disk_cache" : disk_cache ,
1322
1338
"rate_tolerance" : rate_tolerance ,
1323
1339
"safe_staking" : safe_staking ,
1324
1340
"allow_partial_stake" : allow_partial_stake ,
1325
1341
"dashboard_path" : dashboard_path ,
1326
1342
}
1327
- bools = ["use_cache" , "safe_staking" , "allow_partial_stake" ]
1343
+ bools = ["use_cache" , "disk_cache" , " safe_staking" , "allow_partial_stake" ]
1328
1344
if all (v is None for v in args .values ()):
1329
1345
# Print existing configs
1330
1346
self .get_config ()
0 commit comments