From f5aeccedf8fd80b90c58d7435edbbdaf44994031 Mon Sep 17 00:00:00 2001 From: codebender <167290009+codebender37@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:34:00 +0700 Subject: [PATCH] fix: removed env for worker-api in validator side --- .env.validator.example | 1 - README.md | 5 +---- commons/human_feedback/dojo.py | 3 ++- dojo_cli.py | 4 +++- main_validator.py | 2 -- template/__init__.py | 10 +++++++--- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.env.validator.example b/.env.validator.example index 9cb2816f..708c4320 100644 --- a/.env.validator.example +++ b/.env.validator.example @@ -1,4 +1,3 @@ -DOJO_API_BASE_URL= WANDB_API_KEY= # for dojo-synthetic-api diff --git a/README.md b/README.md index 4046ee78..3ed9b191 100644 --- a/README.md +++ b/README.md @@ -386,10 +386,7 @@ Copy the validator .env file and set up the .env file cp .env.validator.example .env # edit the .env file with vim, vi or nano -# for mainnet -DOJO_API_BASE_URL="https://dojo-api.tensorplex.ai" -# for testnet -DOJO_API_BASE_URL="https://dojo-api-testnet.tensorplex.ai" + # head to https://wandb.ai/authorize to get your API key WANDB_API_KEY="" diff --git a/commons/human_feedback/dojo.py b/commons/human_feedback/dojo.py index 14681346..595b1336 100644 --- a/commons/human_feedback/dojo.py +++ b/commons/human_feedback/dojo.py @@ -6,9 +6,10 @@ import template from commons.utils import loaddotenv, set_expire_time -from template import DOJO_API_BASE_URL +from template import get_dojo_api_base_url from template.protocol import FeedbackRequest, MultiScoreCriteria, RankingCriteria +DOJO_API_BASE_URL = get_dojo_api_base_url() # Set to True to enable debug mode # TODO could possible setup with logger to enable debug mode DEBUG = False diff --git a/dojo_cli.py b/dojo_cli.py index a12a3f83..d3949aa6 100644 --- a/dojo_cli.py +++ b/dojo_cli.py @@ -9,7 +9,9 @@ from prompt_toolkit.completion import FuzzyCompleter, WordCompleter from rich.console import Console -from template import DOJO_API_BASE_URL +from template import get_dojo_api_base_url + +DOJO_API_BASE_URL = get_dojo_api_base_url() load_dotenv() console = Console() diff --git a/main_validator.py b/main_validator.py index 153d38e8..4bab364a 100644 --- a/main_validator.py +++ b/main_validator.py @@ -11,7 +11,6 @@ from commons.api.middleware import LimitContentLengthMiddleware from commons.api.reward_route import reward_router from commons.dataset.synthetic import SyntheticAPI -from commons.human_feedback.dojo import DojoAPI from commons.objects import ObjectManager from database.client import connect_db, disconnect_db from neurons.validator import DojoTaskTracker @@ -32,7 +31,6 @@ async def lifespan(app: FastAPI): wandb.finish() validator.save_state() await SyntheticAPI._session.close() - await DojoAPI._http_client.aclose() await disconnect_db() diff --git a/template/__init__.py b/template/__init__.py index 7a14616a..edde18f6 100644 --- a/template/__init__.py +++ b/template/__init__.py @@ -43,6 +43,10 @@ def get_latest_git_tag(): MINER_STATUS = 60 DOJO_TASK_MONITORING = 60 -DOJO_API_BASE_URL = os.getenv("DOJO_API_BASE_URL") -if DOJO_API_BASE_URL is None: - raise ValueError("DOJO_API_BASE_URL is not set in the environment") + +def get_dojo_api_base_url() -> str: + base_url = os.getenv("DOJO_API_BASE_URL") + if base_url is None: + raise ValueError("DOJO_API_BASE_URL is not set in the environment.") + + return base_url