version: "3.9"
services:
  common:
    environment:
      # common
      COMMON_HF_ENDPOINT: ${COMMON_HF_ENDPOINT-https://huggingface.co}
      COMMON_HF_TOKEN: ${COMMON_HF_TOKEN-}
      # log
      LOG_LEVEL: ${LOG_LEVEL-INFO}
      # huggingface_hub
      HF_ENDPOINT: ${COMMON_HF_ENDPOINT-https://huggingface.co} # see https://github.com/huggingface/datasets/pull/5196#issuecomment-1322191411
      # cache
      CACHE_MAX_DAYS: ${CACHE_MAX_DAYS-90}
      CACHE_MONGO_URL: ${CACHE_MONGO_URL-mongodb://mongodb} # use mongo container by default
      CACHE_MONGO_DATABASE: ${CACHE_MONGO_DATABASE-datasets_server_cache}
      # queue
      QUEUE_MONGO_URL: ${QUEUE_MONGO_URL-mongodb://mongodb} # use mongo container by default
      QUEUE_MONGO_DATABASE: ${QUEUE_MONGO_DATABASE-datasets_server_queue}
      # metrics
      METRICS_MONGO_URL: ${METRICS_MONGO_URL-mongodb://mongodb} # use mongo container by default
      METRICS_MONGO_DATABASE: ${METRICS_MONGO_DATABASE-datasets_server_metrics}
      # worker
      WORKER_CONTENT_MAX_BYTES: ${WORKER_CONTENT_MAX_BYTES-10_000_000}
      WORKER_MAX_DISK_USAGE_PCT: ${WORKER_MAX_DISK_USAGE_PCT-90}
      WORKER_MAX_JOB_DURATION_SECONDS: ${WORKER_MAX_JOB_DURATION_SECONDS-1200}
      WORKER_MAX_LOAD_PCT: ${WORKER_MAX_LOAD_PCT-70}
      WORKER_MAX_MEMORY_PCT: ${WORKER_MAX_MEMORY_PCT-80}
      WORKER_SLEEP_SECONDS: ${WORKER_SLEEP_SECONDS-15}
  api:
    extends:
      service: common
    environment:
      NUMBA_CACHE_DIR: ${NUMBA_CACHE_DIR-/numba-cache}
  datasets-worker:
    extends:
      service: common
    environment:
      # datasets
      DATASETS_BASED_HF_DATASETS_CACHE: ${HF_DATASETS_CACHE-/datasets-cache}
      HF_MODULES_CACHE: ${HF_DATASETS_CACHE-/modules-cache}
      NUMBA_CACHE_DIR: ${NUMBA_CACHE_DIR-/numba-cache}
