34
34
upload_to_s3 ,
35
35
DigitalOceanS3Handler ,
36
36
)
37
- from folding .validators .forward import create_new_challenge , run_ping_step , run_step
37
+ from folding .validators .forward import create_new_challenge , run_step
38
38
from folding .validators .protein import Protein
39
39
from folding .registries .miner_registry import MinerRegistry
40
40
from folding .organic .api import start_organic_api
@@ -52,7 +52,11 @@ def __init__(self, config=None):
52
52
53
53
# Sample all the uids on the network, and return only the uids that are non-valis.
54
54
logger .info ("Determining all miner uids...⏳" )
55
- self .all_miner_uids : List = get_all_miner_uids (metagraph = self .metagraph , vpermit_tao_limit = self .config .neuron .vpermit_tao_limit )
55
+ self .all_miner_uids : List = get_all_miner_uids (
56
+ metagraph = self .metagraph ,
57
+ vpermit_tao_limit = self .config .neuron .vpermit_tao_limit ,
58
+ include_serving_in_check = False ,
59
+ )
56
60
57
61
# If we do not have any miner registry saved to the machine, create.
58
62
if not hasattr (self , "miner_registry" ):
@@ -79,24 +83,6 @@ def __init__(self, config=None):
79
83
except ValueError as e :
80
84
raise f"Failed to create S3 handler, check your .env file: { e } "
81
85
82
- def get_uids (self , hotkeys : List [str ]) -> List [int ]:
83
- """Returns the uids corresponding to the hotkeys.
84
- It is possible that some hotkeys have been dereg'd,
85
- so we need to check for them in the metagraph.
86
-
87
- Args:
88
- hotkeys (List[str]): List of hotkeys
89
-
90
- Returns:
91
- List[int]: List of uids
92
- """
93
- return [
94
- self .metagraph .hotkeys .index (hotkey )
95
- for hotkey in hotkeys
96
- if hotkey in self .metagraph .hotkeys
97
- and self .metagraph .axons [self .metagraph .hotkeys .index (hotkey )].is_serving
98
- ]
99
-
100
86
async def forward (self , job : Job ) -> dict :
101
87
"""Carries out a query to the miners to check their progress on a given job (pdb) and updates the job status based on the results.
102
88
@@ -123,32 +109,6 @@ async def forward(self, job: Job) -> dict:
123
109
job_type = job .job_type ,
124
110
)
125
111
126
- async def ping_all_miners (
127
- self ,
128
- exclude_uids : List [int ],
129
- ) -> Tuple [List [int ], List [int ]]:
130
- """Sample ALL (non-excluded) miner uids and return the list of uids
131
- that can serve jobs.
132
-
133
- Args:
134
- exclude_uids (List[int]): uids to exclude from the uids search
135
-
136
- Returns:
137
- Tuple(List,List): Lists of active and inactive uids
138
- """
139
-
140
- current_miner_uids = list (
141
- set (self .all_miner_uids ).difference (set (exclude_uids ))
142
- )
143
-
144
- ping_report = await run_ping_step (
145
- self , uids = current_miner_uids , timeout = self .config .neuron .ping_timeout
146
- )
147
- can_serve = ping_report ["miner_status" ] # list of booleans
148
-
149
- active_uids = np .array (current_miner_uids )[can_serve ].tolist ()
150
- return active_uids
151
-
152
112
async def add_job (self , job_event : dict [str , Any ], protein : Protein = None ) -> bool :
153
113
"""Add a job to the job store while also checking to see what uids can be assigned to the job.
154
114
If uids are not provided, then the function will sample random uids from the network.
@@ -255,16 +215,6 @@ async def add_k_synthetic_jobs(self, k: int):
255
215
await self .add_job (job_event = job_event )
256
216
await asyncio .sleep (0.01 )
257
217
258
- async def update_scores_wrapper (
259
- self , rewards : torch .FloatTensor , hotkeys : List [str ]
260
- ):
261
- """Wrapper function to update the scores of the miners based on the rewards they received."""
262
- uids = self .get_uids (hotkeys = hotkeys )
263
- await self .update_scores (
264
- rewards = rewards ,
265
- uids = uids ,
266
- )
267
-
268
218
async def update_job (self , job : Job ):
269
219
"""Updates the job status based on the event information
270
220
@@ -523,9 +473,9 @@ async def read_and_update_rewards(self):
523
473
)
524
474
continue
525
475
526
- await self .update_scores_wrapper (
476
+ await self .update_scores (
527
477
rewards = torch .Tensor (inactive_job .computed_rewards ),
528
- hotkeys = inactive_job .hotkeys ,
478
+ uids = inactive_job .event [ "uids" ] ,
529
479
)
530
480
await asyncio .sleep (0.01 )
531
481
0 commit comments