Spaces:
Running
Running
import os | |
from huggingface_hub import HfApi | |
# Dynamically determine if we're running in local mode | |
def is_local_mode(): | |
if os.environ.get("SPACE_AUTHOR_NAME") and os.environ.get("SPACE_REPO_NAME") and os.environ.get("HF_TOKEN") and os.environ.get("SPACE_ID"): | |
return False | |
return True | |
LOCAL_MODE = is_local_mode() | |
# Info to change for your repository | |
# ---------------------------------- | |
# Get token from environment or use None in local mode | |
TOKEN = os.environ.get("HF_TOKEN") if not LOCAL_MODE else None | |
OWNER = "holistic-ai" # Change to your org - don't forget to create a results and request dataset, with the correct format! | |
# ---------------------------------- | |
REPO_ID = f"{OWNER}/LibVulnWatch" | |
QUEUE_REPO = REPO_ID # Use the same repository | |
RESULTS_REPO = REPO_ID # Use the same repository | |
if not LOCAL_MODE: | |
REPO_ID = str(os.environ.get("SPACE_ID")) | |
QUEUE_REPO = REPO_ID | |
RESULTS_REPO = REPO_ID | |
# If you setup a cache later, just change HF_HOME | |
CACHE_PATH=os.getenv("HF_HOME", ".") | |
# Local caches | |
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "assessment-queue") | |
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "assessment-results") | |
EVAL_REQUESTS_PATH_BACKEND = os.path.join(CACHE_PATH, "assessment-queue-bk") | |
EVAL_RESULTS_PATH_BACKEND = os.path.join(CACHE_PATH, "assessment-results-bk") | |
# Initialize API with token if available | |
API = HfApi(token=TOKEN) | |