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

Add prometheus extrinsic #1125

Merged
merged 18 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions bittensor/_prometheus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def __new__(
network: str = None,
chain_endpoint: str = None,
subtensor: 'bittensor.subtensor' = None,
prompt: bool = False,
):
""" Instantiates a global prometheus DB which can be accessed by other processes.
Each prometheus DB is designated by a port.
Expand All @@ -76,8 +75,6 @@ def __new__(
If subtensor is not set, uses this network flag to create the subtensor connection.
chain_endpoint (default=None, type=str)
Overrides the network argument if not set.
prompt (:obj:`bool`, `optional`):
If true, the call waits for confirmation from the user before proceeding.
"""
if config == None:
config = prometheus.config()
Expand All @@ -98,15 +95,13 @@ def __new__(
subtensor = subtensor,
port = config.prometheus.port,
level = config.prometheus.level,
prompt = prompt,
)

def serve(cls, wallet, subtensor, netuid, port, level, prompt):
def serve(cls, wallet, subtensor, netuid, port, level):
serve_success = subtensor.serve_prometheus(
wallet = wallet,
port = port,
netuid = netuid,
prompt = prompt
)
if serve_success and (level != prometheus.level.OFF.name):
try:
Expand All @@ -121,7 +116,6 @@ def serve(cls, wallet, subtensor, netuid, port, level, prompt):
else:
logger.success('Prometheus:'.ljust(20) + '<red>OFF</red>')
raise RuntimeError('Failed to serve neuron.')
return False

@classmethod
def config(cls) -> 'bittensor.Config':
Expand Down
2 changes: 0 additions & 2 deletions bittensor/_subtensor/extrinsics/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ def prometheus_extrinsic(
wait_for_finalization (bool):
if set, waits for the extrinsic to be finalized on the chain before returning true,
or returns false if the extrinsic fails to be finalized within the timeout.
prompt (bool):
If true, the call waits for confirmation from the user before proceeding.
Returns:
success (bool):
flag is true if extrinsic was finalized or uncluded in the block.
Expand Down
3 changes: 1 addition & 2 deletions bittensor/_subtensor/subtensor_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,8 @@ def serve_prometheus (
netuid: int,
wait_for_inclusion: bool = False,
wait_for_finalization: bool = True,
prompt: bool = False,
) -> bool:
return prometheus_extrinsic( self, wallet = wallet, port = port, netuid = netuid, wait_for_inclusion = wait_for_inclusion, wait_for_finalization = wait_for_finalization, prompt = prompt)
return prometheus_extrinsic( self, wallet = wallet, port = port, netuid = netuid, wait_for_inclusion = wait_for_inclusion, wait_for_finalization = wait_for_finalization)
#################
#### Staking ####
#################
Expand Down
3 changes: 2 additions & 1 deletion tests/integration_tests/test_prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ def test_init_prometheus_success(self):

def test_init_prometheus_failed(self):
self.subtensor.substrate.submit_extrinsic = MagicMock(return_value = self.fail)
assert False == bittensor.prometheus(wallet = self.wallet, subtensor = self.subtensor)
with pytest.raises(Exception):
bittensor.prometheus(wallet = self.wallet, subtensor = self.subtensor)