Skip to content

Commit f48a5f8

Browse files
committed
fix: ensure storage API URL is properly formatted by removing trailing slashes
1 parent ba997da commit f48a5f8

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/api/__main__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from .router import start_ping_server
3131
from ._base import BaseScoringApi
3232

33-
3433
SCORING_API_PORT = int(os.getenv(f"{ENV_PREFIX_SCORING_API}PORT", 8000))
3534

3635

@@ -153,7 +152,8 @@ def _fetch_miners_docker_info_from_storage(self) -> dict[str, dict]:
153152
"[FETCH MINER DOCKER INFO] Fetching miner docker info from storage"
154153
)
155154

156-
endpoint = f"{self.config.STORAGE_API_URL}/miner/docker-info"
155+
storage_url = str(self.config.STORAGE_API_URL).rstrip("/")
156+
endpoint = f"{storage_url}/miner/docker-info"
157157
header = self.validator_request_header_fn({})
158158

159159
try:
@@ -377,7 +377,8 @@ def _get_storage_api_key(self) -> str:
377377
"""
378378
Retrieves the storage API key from the config.
379379
"""
380-
endpoint = f"{self.config.STORAGE_API_URL}/get-api-key"
380+
storage_url = str(self.config.STORAGE_API_URL).rstrip("/")
381+
endpoint = f"{storage_url}/get-api-key"
381382
data = {"validator_uid": self.uid, "validator_hotkey": self.hotkey}
382383
header = self.validator_request_header_fn(data)
383384
response = requests.post(endpoint, json=data, headers=header)
@@ -633,7 +634,8 @@ def _update_validators_miner_commits(self):
633634
for validator_uid, validator_hotkey in valid_validators:
634635
# Skip if request fails
635636
try:
636-
endpoint = f"{self.config.STORAGE_API_URL}/fetch-latest-miner-commits"
637+
storage_url = str(self.config.STORAGE_API_URL).rstrip("/")
638+
endpoint = f"{storage_url}/fetch-latest-miner-commits"
637639
data = {
638640
"validator_uid": validator_uid,
639641
"validator_hotkey": validator_hotkey,
@@ -845,7 +847,8 @@ def _store_centralized_scoring(self, challenge_name: str = None):
845847
challenge_names = (
846848
[challenge_name] if challenge_name else list(self.scoring_results.keys())
847849
)
848-
endpoint = f"{self.config.STORAGE_API_URL}/upload-centralized-score"
850+
storage_url = str(self.config.STORAGE_API_URL).rstrip("/")
851+
endpoint = f"{storage_url}/upload-centralized-score"
849852

850853
for challenge_name in challenge_names:
851854
scoring_results_to_send: list[dict] = []
@@ -907,7 +910,8 @@ def _get_accepted_challenge_commits(self, challenge_name: str) -> list:
907910
_payload = {"challenge_name": challenge_name}
908911
header = self.validator_request_header_fn(_payload)
909912

910-
endpoint = f"{self.config.STORAGE_API_URL}/fetch-accepted-miner-commits"
913+
storage_url = str(self.config.STORAGE_API_URL).rstrip("/")
914+
endpoint = f"{storage_url}/fetch-accepted-miner-commits"
911915
commits = requests.post(endpoint, json=_payload, headers=header)
912916
if commits.status_code == 200 and commits.json().get("miner_commits"):
913917
commits = commits.json().get("miner_commits", [])
@@ -951,7 +955,8 @@ def _initialize_scoring_cache(self):
951955
# Request the most recent entries for this challenge
952956
entries_per_challenge = 256 # Match the LRU cache size
953957

954-
endpoint = f"{self.config.STORAGE_API_URL}/fetch-centralized-score"
958+
storage_url = str(self.config.STORAGE_API_URL).rstrip("/")
959+
endpoint = f"{storage_url}/fetch-centralized-score"
955960
data = {
956961
"challenge_names": [challenge_name],
957962
"limit": entries_per_challenge, # Get the most recent entries

0 commit comments

Comments
 (0)