Skip to content

Commit

Permalink
Check branch in auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
HudsonGraeme committed Jan 16, 2025
1 parent 67a36c3 commit 11d79aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions neurons/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,5 @@ class Roles:
(57, 237), # gaia
(59, 249), # agent-arena
]
# GitHub repository URL
REPO_URL = "https://github.com/inference-labs-inc/omron-subnet"
17 changes: 13 additions & 4 deletions neurons/utils/auto_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import requests
from typing import Optional
from constants import REPO_URL

from bittensor import logging

Expand Down Expand Up @@ -46,9 +47,7 @@ def get_latest_release_tag(self):
Get the latest release tag from the GitHub repository
"""
try:
response = requests.get(
f"https://api.github.com/repos/inference-labs-inc/omron-subnet/releases/latest"
)
response = requests.get(f"{REPO_URL}/releases/latest")
response.raise_for_status()
latest_release = response.json()
return latest_release["tag_name"]
Expand Down Expand Up @@ -117,11 +116,21 @@ def update_to_latest_release(self) -> bool:
try:

if self.repo.is_dirty(untracked_files=False):
logging.error(
logging.warning(
"Current changeset is dirty. Please commit changes, discard changes or update manually."
)
return False

if self.repo.head.is_detached:
logging.warning("Current branch is detached. Please update manually.")
return False

if self.repo.active_branch.name != TARGET_BRANCH:
logging.warning(
f"Current branch is not {TARGET_BRANCH}. Please update manually."
)
return False

latest_release_tag_name = self.get_latest_release_tag()
if not latest_release_tag_name:
logging.error("Failed to fetch the latest release tag.")
Expand Down

0 comments on commit 11d79aa

Please sign in to comment.