Skip to content

Commit 0cd1d27

Browse files
author
Roman
committed
update subtensors' init and docstrings
1 parent 529d204 commit 0cd1d27

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

bittensor/core/async_subtensor.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,19 @@ def __init__(
115115
network: Optional[str] = None,
116116
config: Optional["Config"] = None,
117117
log_verbose: bool = False,
118-
fallback_chains: Optional[list[str]] = None,
118+
fallback_endpoints: Optional[list[str]] = None,
119119
retry_forever: bool = False,
120120
_mock: bool = False,
121121
):
122122
"""
123123
Initializes an instance of the AsyncSubtensor class.
124124
125125
Arguments:
126-
network (str): The network name or type to connect to.
127-
config (Optional[Config]): Configuration object for the AsyncSubtensor instance.
128-
log_verbose (bool): Enables or disables verbose logging.
129-
fallback_chains (list): List of fallback chains endpoints to use if no network is specified. Defaults to `None`.
130-
retry_forever (bool): Whether to retry forever on connection errors. Defaults to `False`.
126+
network: The network name or type to connect to.
127+
config: Configuration object for the AsyncSubtensor instance.
128+
log_verbose: Enables or disables verbose logging.
129+
fallback_endpoints: List of fallback endpoints to use if default or provided network is not available. Defaults to `None`.
130+
retry_forever: Whether to retry forever on connection errors. Defaults to `False`.
131131
_mock: Whether this is a mock instance. Mainly just for use in testing.
132132
133133
Raises:
@@ -148,7 +148,9 @@ def __init__(
148148
f"chain_endpoint: [blue]{self.chain_endpoint}[/blue]..."
149149
)
150150
self.substrate = self._get_substrate(
151-
fallback_chains=fallback_chains, retry_forever=retry_forever, _mock=_mock
151+
fallback_endpoints=fallback_endpoints,
152+
retry_forever=retry_forever,
153+
_mock=_mock,
152154
)
153155
if self.log_verbose:
154156
logging.info(
@@ -284,24 +286,24 @@ async def get_hyperparameter(
284286

285287
def _get_substrate(
286288
self,
287-
fallback_chains: Optional[list[str]] = None,
289+
fallback_endpoints: Optional[list[str]] = None,
288290
retry_forever: bool = False,
289291
_mock: bool = False,
290292
) -> Union[AsyncSubstrateInterface, RetryAsyncSubstrate]:
291293
"""Creates the Substrate instance based on provided arguments.
292294
293295
Arguments:
294-
fallback_chains (list): List of fallback chains endpoints to use if no network is specified. Defaults to `None`.
295-
retry_forever (bool): Whether to retry forever on connection errors. Defaults to `False`.
296+
fallback_endpoints: List of fallback endpoints to use if default or provided network is not available. Defaults to `None`.
297+
retry_forever: Whether to retry forever on connection errors. Defaults to `False`.
296298
_mock: Whether this is a mock instance. Mainly just for use in testing.
297299
298300
Returns:
299301
the instance of the SubstrateInterface or RetrySyncSubstrate class.
300302
"""
301-
if fallback_chains or retry_forever:
303+
if fallback_endpoints or retry_forever:
302304
return RetryAsyncSubstrate(
303305
url=self.chain_endpoint,
304-
fallback_chains=fallback_chains,
306+
fallback_chains=fallback_endpoints,
305307
ss58_format=SS58_FORMAT,
306308
type_registry=TYPE_REGISTRY,
307309
retry_forever=retry_forever,

bittensor/core/subtensor.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,19 @@ def __init__(
117117
network: Optional[str] = None,
118118
config: Optional["Config"] = None,
119119
log_verbose: bool = False,
120-
fallback_chains: Optional[list[str]] = None,
120+
fallback_endpoints: Optional[list[str]] = None,
121121
retry_forever: bool = False,
122122
_mock: bool = False,
123123
):
124124
"""
125125
Initializes an instance of the Subtensor class.
126126
127127
Arguments:
128-
network (str): The network name or type to connect to.
129-
config (Optional[Config]): Configuration object for the AsyncSubtensor instance.
130-
log_verbose (bool): Enables or disables verbose logging.
131-
fallback_chains (list): List of fallback chains endpoints to use if no network is specified. Defaults to `None`.
132-
retry_forever (bool): Whether to retry forever on connection errors. Defaults to `False`.
128+
network: The network name or type to connect to.
129+
config: Configuration object for the AsyncSubtensor instance.
130+
log_verbose: Enables or disables verbose logging.
131+
fallback_endpoints: List of fallback endpoints to use if default or provided network is not available. Defaults to `None`.
132+
retry_forever: Whether to retry forever on connection errors. Defaults to `False`.
133133
_mock: Whether this is a mock instance. Mainly just for use in testing.
134134
135135
Raises:
@@ -148,7 +148,9 @@ def __init__(
148148
f"chain_endpoint: [blue]{self.chain_endpoint}[/blue]> ..."
149149
)
150150
self.substrate = self._get_substrate(
151-
fallback_chains=fallback_chains, retry_forever=retry_forever, _mock=_mock
151+
fallback_endpoints=fallback_endpoints,
152+
retry_forever=retry_forever,
153+
_mock=_mock,
152154
)
153155
if self.log_verbose:
154156
logging.info(
@@ -167,28 +169,28 @@ def close(self):
167169

168170
def _get_substrate(
169171
self,
170-
fallback_chains: Optional[list[str]] = None,
172+
fallback_endpoints: Optional[list[str]] = None,
171173
retry_forever: bool = False,
172174
_mock: bool = False,
173175
) -> Union[SubstrateInterface, RetrySyncSubstrate]:
174176
"""Creates the Substrate instance based on provided arguments.
175177
176178
Arguments:
177-
fallback_chains (list): List of fallback chains endpoints to use if no network is specified. Defaults to `None`.
178-
retry_forever (bool): Whether to retry forever on connection errors. Defaults to `False`.
179+
fallback_endpoints: List of fallback chains endpoints to use if main network isn't available. Defaults to `None`.
180+
retry_forever: Whether to retry forever on connection errors. Defaults to `False`.
179181
_mock: Whether this is a mock instance. Mainly just for use in testing.
180182
181183
Returns:
182184
the instance of the SubstrateInterface or RetrySyncSubstrate class.
183185
"""
184-
if fallback_chains or retry_forever:
186+
if fallback_endpoints or retry_forever:
185187
return RetrySyncSubstrate(
186188
url=self.chain_endpoint,
187189
ss58_format=SS58_FORMAT,
188190
type_registry=TYPE_REGISTRY,
189191
use_remote_preset=True,
190192
chain_name="Bittensor",
191-
fallback_chains=fallback_chains,
193+
fallback_endpoints=fallback_endpoints,
192194
retry_forever=retry_forever,
193195
_mock=_mock,
194196
)

0 commit comments

Comments
 (0)