From cda75bae1a4d40977270c013aa78f7f262e00014 Mon Sep 17 00:00:00 2001 From: jannik Date: Mon, 28 Oct 2024 16:32:04 +0100 Subject: [PATCH] changes --- remote_challenge_evaluation/main.py | 47 +++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/remote_challenge_evaluation/main.py b/remote_challenge_evaluation/main.py index 932ef88..c517613 100644 --- a/remote_challenge_evaluation/main.py +++ b/remote_challenge_evaluation/main.py @@ -1,18 +1,61 @@ import json import os import time +from pathlib import Path +import sys import requests from eval_ai_interface import EvalAI_Interface from evaluate import evaluate + + +############################################################################# +def load_config(file_path='github/host_config.json'): + try: + with open(file_path, 'r') as f: + return json.load(f) + except FileNotFoundError: + print(f"Error: {file_path} not found.") + sys.exit(1) + except json.JSONDecodeError: + print(f"Error: {file_path} is not a valid JSON file.") + sys.exit(1) + +# Load configuration from JSON file +config = load_config() + + +# Define mapping between config file keys and required variable names +config_mapping = { + "token": "AUTH_TOKEN", + "evalai_host_url": "API_SERVER", + + "queue_name": "QUEUE_NAME", + "challenge_pk": "CHALLENGE_PK", + "save_dir": "SAVE_DIR" +} + +# Set environment variables from config +for config_key, env_var in config_mapping.items(): + if config_key in config: + os.environ[env_var] = str(config[config_key]) + # elif env_var != "SAVE_DIR": # SAVE_DIR is optional + # print(f"Error: {config_key} is not set in the config file.") + # sys.exit(1) +# Set default for SAVE_DIR if not in config +if "SAVE_DIR" not in os.environ: + os.environ["SAVE_DIR"] = "./" + +############################################################################# + # Remote Evaluation Meta Data # See https://evalai.readthedocs.io/en/latest/evaluation_scripts.html#writing-remote-evaluation-script auth_token = os.environ["AUTH_TOKEN"] evalai_api_server = os.environ["API_SERVER"] -queue_name = os.environ["QUEUE_NAME"] -challenge_pk = os.environ["CHALLENGE_PK"] +queue_name = "embed2scale-challenge-test2--2389-production-c43a1f6e-35a3-4e13-b1ef-14f7fa771e6" +challenge_pk = "2389" #os.environ["CHALLENGE_PK"] save_dir = os.environ.get("SAVE_DIR", "./")