Skip to content

Commit

Permalink
fix empty miner to assign issue
Browse files Browse the repository at this point in the history
  • Loading branch information
acer-king committed Oct 12, 2024
1 parent 732f9d0 commit a1bb1c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions validators/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def choose_miner(self, synapse: ALL_SYNAPSE_TYPE):
if bandwidth is not None and bandwidth > 0:
# decrease resource by one after choosing this miner for the request.
available_uids.append(uid)
if not available_uids:
return None
uid = random.choice(available_uids)
self.remain_resources[uid][provider][model] -= 1
return uid
4 changes: 3 additions & 1 deletion validators/weight_setter.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ async def perform_synthetic_queries(self):
query_synapses = await self.create_query_syns_for_remaining_bandwidth()
for query_syn in query_synapses:
uid = self.task_mgr.assign_task(query_syn)
if uid is None:
bt.logging.debug(f"No available uids for synthetic query process.")
synthetic_tasks.append((uid, self.query_miner(uid, query_syn)))

bt.logging.debug(f"{time.time() - start_time} elapsed for creating and submitting synthetic queries.")
Expand Down Expand Up @@ -448,7 +450,7 @@ async def _prompt(query_synapse: StreamPrompting, send: Send):
synapse.streaming = True
uid = self.task_mgr.assign_task(query_synapse)
if uid is None:
bt.logging.error("Can't create task.")
bt.logging.error("Can't create task. no available uids for now")
await send({"type": "http.response.body", "body": b'', "more_body": False})
return
bt.logging.trace(f"task is created and uid is {uid}")
Expand Down

0 comments on commit a1bb1c8

Please sign in to comment.