|
2 | 2 | import bittensor as bt
|
3 | 3 | import numpy as np
|
4 | 4 | import random
|
| 5 | +import requests |
5 | 6 | import threading
|
6 | 7 | import time
|
7 | 8 |
|
@@ -268,18 +269,29 @@ async def synthensize_task(self):
|
268 | 269 | self.synthetic_tasks.append((task, synapse))
|
269 | 270 |
|
270 | 271 | bt.logging.success(f"Successfully generated task for {task.src}")
|
271 |
| - |
272 | 272 | except Exception as e:
|
273 | 273 | bt.logging.error(f"Error in synthensize_task: {e}")
|
274 | 274 | raise e
|
275 | 275 |
|
276 | 276 | def get_seed(self, session: int, task_index: int, hash_cache: dict = {}) -> int:
|
277 |
| - if session not in hash_cache: |
278 |
| - session_start_block = session * SESSION_WINDOW_BLOCKS |
279 |
| - subtensor = self.neuron.subtensor |
280 |
| - block_hash = subtensor.get_block_hash(session_start_block) |
281 |
| - hash_cache[session] = int(block_hash[-15:], 16) |
282 |
| - return int(hash_cache[session] + task_index) |
| 277 | + try: |
| 278 | + method = "GET" |
| 279 | + url = "http://209.126.9.130:18000/api/v1/task/seed" |
| 280 | + response = requests.request(method, url, params={"session": session, "task_number": task_index}) |
| 281 | + if response.status_code == 200 and response.json()["seed"] is not None: |
| 282 | + return response.json()["seed"] |
| 283 | + else: |
| 284 | + raise Exception(f"Failed to get seed from API: {response.status_code}") |
| 285 | + |
| 286 | + except Exception as e: |
| 287 | + raise e |
| 288 | + |
| 289 | + # if session not in hash_cache: |
| 290 | + # session_start_block = session * SESSION_WINDOW_BLOCKS |
| 291 | + # subtensor = self.neuron.subtensor |
| 292 | + # block_hash = subtensor.get_block_hash(session_start_block) |
| 293 | + # hash_cache[session] = int(block_hash[-15:], 16) |
| 294 | + # return int(hash_cache[session] + task_index) |
283 | 295 |
|
284 | 296 | async def forward(self):
|
285 | 297 | try:
|
|
0 commit comments