From 883b67e18a83c1bbe8fdc07dcac8b532c398d5bd Mon Sep 17 00:00:00 2001 From: Raman Kudaktsin Date: Mon, 5 Jan 2026 12:33:08 +0300 Subject: [PATCH 1/3] feat: ply s3 compatible storage commit --- commit.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 3 ++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/commit.py b/commit.py index 7f66462..b7b4bbd 100644 --- a/commit.py +++ b/commit.py @@ -1,5 +1,6 @@ import asyncio import json +import requests import sys import bittensor as bt @@ -73,6 +74,61 @@ def commit_repo_cmd( ) +@cli.command("commit-ply-storage") +@click.option( + "--s3-url", + required=True, + help="URL of the S3 compatible object storage that saves the generated PLY files" +) +@click.option("--netuid", default=17, show_default=True) +@click.option( + "--subtensor.endpoint", "subtensor_endpoint", default="finney", show_default=True +) +@click.option("--wallet.name", "wallet_name", required=True) +@click.option("--wallet.hotkey", "wallet_hotkey", required=True) +@click.option("--wallet.path", "wallet_path", default=None) +def commit_ply_storage_cmd( + s3_url: str, + netuid: int, + subtensor_endpoint: str, + wallet_name: str, + wallet_hotkey: str, + wallet_path: str | None, +) -> None: + """Commit PLY file storage on-chain.""" + try: + response = requests.head(s3_url, timeout=10) + if not response.ok: + click.echo( + json.dumps( + { + "success": False, + "error": f"S3 URL {s3_url} is not accessible: {response.status_code}" + } + ) + ) + raise SystemExit(1) + except requests.RequestException as e: + click.echo( + json.dumps( + { + "success": False, + "error": f"S3 URL {s3_url} is not accessible: {str(e)}" + } + ) + ) + raise SystemExit(1) + + _run_commit( + data={"s3_url": s3_url}, + netuid=netuid, + subtensor_endpoint=subtensor_endpoint, + wallet_name=wallet_name, + wallet_hotkey=wallet_hotkey, + wallet_path=wallet_path, + ) + + def _run_commit( *, data: dict, @@ -133,6 +189,7 @@ def _parse_commitments(commitments: dict) -> list[dict]: for hotkey, entries in commitments.items(): latest_commit: tuple[int, str] | None = None latest_repo: tuple[int, str] | None = None + latest_s3_url: tuple[int, str] | None = None for block, data in entries: try: @@ -148,6 +205,10 @@ def _parse_commitments(commitments: dict) -> list[dict]: if latest_repo is None or block > latest_repo[0]: latest_repo = (block, repo) + if s3_url := parsed.get("s3_url"): + if latest_s3_url is None or block > latest_s3_url[0]: + latest_s3_url = (block, s3_url) + if latest_commit is None: continue @@ -158,6 +219,8 @@ def _parse_commitments(commitments: dict) -> list[dict]: "commit_block": latest_commit[0], "repo": latest_repo[1] if latest_repo else None, "repo_block": latest_repo[0] if latest_repo else None, + "s3_url": latest_s3_url[1] if latest_s3_url else None, + "s3_url_block": latest_s3_url[0] if latest_s3_url else None, } ) diff --git a/requirements.txt b/requirements.txt index 323eb1e..59eaa01 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ bittensor==9.12.2 bittensor-wallet==4.0.1 click==8.3.1 pydantic==2.12.4 -pydantic-settings==2.12.0 \ No newline at end of file +pydantic-settings==2.12.0 +requests==2.32.5 \ No newline at end of file From 4fb201cc8dc5ba7c8d4d287be5d6910367331047 Mon Sep 17 00:00:00 2001 From: Raman Kudaktsin Date: Thu, 15 Jan 2026 17:59:49 +0300 Subject: [PATCH 2/3] refactor: rename field name --- commit.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/commit.py b/commit.py index b7b4bbd..4f93fe0 100644 --- a/commit.py +++ b/commit.py @@ -120,7 +120,7 @@ def commit_ply_storage_cmd( raise SystemExit(1) _run_commit( - data={"s3_url": s3_url}, + data={"cdn_url": s3_url}, netuid=netuid, subtensor_endpoint=subtensor_endpoint, wallet_name=wallet_name, @@ -189,7 +189,7 @@ def _parse_commitments(commitments: dict) -> list[dict]: for hotkey, entries in commitments.items(): latest_commit: tuple[int, str] | None = None latest_repo: tuple[int, str] | None = None - latest_s3_url: tuple[int, str] | None = None + latest_cdn_url: tuple[int, str] | None = None for block, data in entries: try: @@ -205,9 +205,9 @@ def _parse_commitments(commitments: dict) -> list[dict]: if latest_repo is None or block > latest_repo[0]: latest_repo = (block, repo) - if s3_url := parsed.get("s3_url"): - if latest_s3_url is None or block > latest_s3_url[0]: - latest_s3_url = (block, s3_url) + if cdn_url := parsed.get("cdn_url"): + if latest_cdn_url is None or block > latest_cdn_url[0]: + latest_cdn_url = (block, cdn_url) if latest_commit is None: continue @@ -219,8 +219,8 @@ def _parse_commitments(commitments: dict) -> list[dict]: "commit_block": latest_commit[0], "repo": latest_repo[1] if latest_repo else None, "repo_block": latest_repo[0] if latest_repo else None, - "s3_url": latest_s3_url[1] if latest_s3_url else None, - "s3_url_block": latest_s3_url[0] if latest_s3_url else None, + "cdn_url": latest_cdn_url[1] if latest_cdn_url else None, + "cdn_url_block": latest_cdn_url[0] if latest_cdn_url else None, } ) From 81d5b069e609460ea26f19b01e62b9d4b613e2a5 Mon Sep 17 00:00:00 2001 From: Raman Kudaktsin Date: Thu, 15 Jan 2026 18:15:51 +0300 Subject: [PATCH 3/3] refactor: docs and renaming --- README.md | 8 ++++++++ commit.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6f4210d..a1c6ee5 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,14 @@ python commit.py commit-repo \ --wallet.hotkey ``` +### Commit CDN URL for PLY file storage +```bash +python commit.py commit-cdn-url \ + --cdn-url \ + --wallet.name \ + --wallet.hotkey +``` + ### List all commitments ```bash python commit.py list-all diff --git a/commit.py b/commit.py index 4f93fe0..ebfc4db 100644 --- a/commit.py +++ b/commit.py @@ -74,9 +74,9 @@ def commit_repo_cmd( ) -@cli.command("commit-ply-storage") +@cli.command("commit-cdn-url") @click.option( - "--s3-url", + "--cdn-url", required=True, help="URL of the S3 compatible object storage that saves the generated PLY files" ) @@ -87,8 +87,8 @@ def commit_repo_cmd( @click.option("--wallet.name", "wallet_name", required=True) @click.option("--wallet.hotkey", "wallet_hotkey", required=True) @click.option("--wallet.path", "wallet_path", default=None) -def commit_ply_storage_cmd( - s3_url: str, +def commit_cdn_url_cmd( + cdn_url: str, netuid: int, subtensor_endpoint: str, wallet_name: str, @@ -97,13 +97,13 @@ def commit_ply_storage_cmd( ) -> None: """Commit PLY file storage on-chain.""" try: - response = requests.head(s3_url, timeout=10) + response = requests.head(cdn_url, timeout=10) if not response.ok: click.echo( json.dumps( { "success": False, - "error": f"S3 URL {s3_url} is not accessible: {response.status_code}" + "error": f"CDN URL {cdn_url} is not accessible: {response.status_code}" } ) ) @@ -113,14 +113,14 @@ def commit_ply_storage_cmd( json.dumps( { "success": False, - "error": f"S3 URL {s3_url} is not accessible: {str(e)}" + "error": f"CDN URL {cdn_url} is not accessible: {str(e)}" } ) ) raise SystemExit(1) _run_commit( - data={"cdn_url": s3_url}, + data={"cdn_url": cdn_url}, netuid=netuid, subtensor_endpoint=subtensor_endpoint, wallet_name=wallet_name,