diff --git a/.github/workflows/publish-ghcr.yml b/.github/workflows/publish-ghcr.yml index acdd618..f9751ab 100644 --- a/.github/workflows/publish-ghcr.yml +++ b/.github/workflows/publish-ghcr.yml @@ -38,4 +38,4 @@ jobs: context: . file: ./Dockerfile-gpu push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} \ No newline at end of file + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} diff --git a/Dockerfile-gpu b/Dockerfile-gpu index 35f364b..53a8760 100644 --- a/Dockerfile-gpu +++ b/Dockerfile-gpu @@ -15,4 +15,6 @@ RUN pip3 install -r requirements.txt WORKDIR /app/src +ENV IS_DOCKER_CONTAINER=1 + CMD ["sh", "-c", "bash start.sh --hf_token ${HF_TOKEN} --flock_api_key ${FLOCK_API_KEY} --task_id ${TASK_ID}"] \ No newline at end of file diff --git a/src/validate.py b/src/validate.py index 5537a6d..6bfff4d 100644 --- a/src/validate.py +++ b/src/validate.py @@ -2,7 +2,6 @@ import os import time import shutil -import git import gc import click @@ -40,6 +39,11 @@ raise ValueError("FLOCK_API_KEY is not set") LOSS_FOR_MODEL_PARAMS_EXCEED = 999.0 HF_TOKEN = os.getenv("HF_TOKEN") +IS_DOCKER_CONTAINER = os.getenv("IS_DOCKER_CONTAINER", False) + +if not IS_DOCKER_CONTAINER: + import git # only import git in non-docker container environment because it is not installed in docker image + if HF_TOKEN is None: raise ValueError( "You need to set HF_TOKEN to download some gated model from HuggingFace" @@ -372,7 +376,12 @@ def loop(validation_args_file: str, task_id: str = None, auto_clean_cache: bool logger.info("Skip auto clean the model cache") repo_path = Path(__file__).resolve().parent.parent - is_latest_version(repo_path) + + if not IS_DOCKER_CONTAINER: + is_latest_version(repo_path) + else: + logger.info("Skip checking the latest version in docker container") + logger.info("Please make sure you are using the latest version of the docker image.") fed_ledger = FedLedger(FLOCK_API_KEY) task_id_list = task_id.split(",")