diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..397a6f2 Binary files /dev/null and b/.DS_Store differ diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..adfbec4 --- /dev/null +++ b/__init__.py @@ -0,0 +1,7 @@ +__version__ = "0.0.8" +version_split = __version__.split(".") +__spec_version__ = ( + (1000 * int(version_split[0])) + + (10 * int(version_split[1])) + + (1 * int(version_split[2])) +) \ No newline at end of file diff --git a/validator/validator_daemon.py b/validator/validator_daemon.py index d7f2259..b60f1f8 100644 --- a/validator/validator_daemon.py +++ b/validator/validator_daemon.py @@ -6,6 +6,9 @@ import numpy as np import bittensor as bt import logging +import re +import subprocess +import codecs from typing import List from shared.debug_util import DEBUG_LOCAL from shared.log_data import LoggerType @@ -128,6 +131,33 @@ def aggregate_results(results_dir, moving_scores): bt.logging.error(f"DAEMON | Error deleting file {filepath}: {e}") return moving_scores, vericore_responses +def update_repository(): + bt.logging.info("checking repository updates") + try: + subprocess.run(["git", "pull"], check=True) + except subprocess.CalledProcessError: + bt.logging.error("Git pull failed") + return False + + here = os.path.abspath(os.path.dirname(__file__)) + parent_dir = os.path.dirname(here) + init_file_path = os.path.join(parent_dir, '__init__.py') + + with codecs.open(init_file_path, encoding='utf-8') as init_file: + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", init_file.read(), re.M) + if version_match: + new_version = version_match.group(1) + current_version = __version__ + bt.logging.success(f"current version: {current_version}, new version: {new_version}") + if current_version != new_version: + try: + # subprocess.run(["python3", "voiceguard/utils/download.py"], check=True) + subprocess.run(["python3", "-m", "pip", "install", "-e", "."], check=True) + os._exit(1) + except subprocess.CalledProcessError: + bt.logging.error("Pip install failed") + else: + bt.logging.info("No changes detected!") def main(): config = get_config() @@ -200,6 +230,11 @@ def main(): incentives, ) + if step % 5 == 0: + update_repository() + + step += 1 + metagraph.sync() time.sleep(60) except KeyboardInterrupt: