Skip to content

Commit

Permalink
Merge pull request #275 from neuralinternet/return-the-miner-version-…
Browse files Browse the repository at this point in the history
…on-the-Allocation-request

Return-the-miner-version-on-the-Allocation-request
  • Loading branch information
thomas-chu123 authored and mo0haned committed Feb 3, 2025
1 parent cb7bc78 commit 4df02a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions neurons/Miner/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from io import BytesIO
import sys
from docker.types import DeviceRequest

from compute import __version_as_int__
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(parent_dir)

Expand Down Expand Up @@ -178,7 +178,7 @@ def run_container(cpu_usage, ram_usage, hard_disk_usage, gpu_usage, public_key,
# Check the status to determine if the container ran successfully
if container.status == "created":
bt.logging.info("Container was created successfully.")
info = {"username": "root", "password": password, "port": docker_ssh_port}
info = {"username": "root", "password": password, "port": docker_ssh_port, "version" : __version_as_int__}
info_str = json.dumps(info)
public_key = public_key.encode("utf-8")
encrypted_info = rsa.encrypt_data(public_key, info_str)
Expand Down
6 changes: 4 additions & 2 deletions neurons/register_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class Allocation(BaseModel):
ssh_command: str = ""
ssh_key: str = ""
uuid_key: str = ""
miner_version: int = 0


class DockerRequirement(BaseModel):
Expand Down Expand Up @@ -518,7 +519,7 @@ async def allocate_spec(requirements: DeviceRequirement, docker_requirement: Doc
allocated.ssh_password = info["password"]
allocated.uuid_key = info["uuid"]
allocated.ssh_command = f"ssh {info['username']}@{result['ip']} -p {str(info['port'])}"

allocated.miner_version = info.get("version", 0)
update_allocation_db(result_hotkey, info, True)
await self._update_allocation_wandb()
bt.logging.info(f"API: Resource {result_hotkey} was successfully allocated")
Expand Down Expand Up @@ -667,7 +668,7 @@ async def allocate_hotkey(hotkey: str, ssh_key: Optional[str] = None,
allocated.ssh_password = info["password"]
allocated.uuid_key = info["uuid"]
allocated.ssh_command = f"ssh {info['username']}@{result['ip']} -p {str(info['port'])}"

allocated.miner_version = info.get("version", 0)
update_allocation_db(result_hotkey, info, True)
await self._update_allocation_wandb()

Expand Down Expand Up @@ -1390,6 +1391,7 @@ async def list_allocations() -> JSONResponse:
)
entry.uuid_key = info["uuid"]
entry.ssh_key = info["ssh_key"]
entry.miner_version = info.get("version", 0)
allocation_list.append(entry)

except Exception as e:
Expand Down

0 comments on commit 4df02a0

Please sign in to comment.