Skip to content

Commit

Permalink
fix: #30 and add latest tag (#31)
Browse files Browse the repository at this point in the history
* install git inside docker image

* add env to disable version check in docker container

* use uppercase TASK_ID env in dockerfile

* add latest tag to gh action

* don't import git in docker container
  • Loading branch information
zJuuu authored Jun 19, 2024
1 parent 0cb011d commit fa1a4da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
context: .
file: ./Dockerfile-gpu
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
2 changes: 2 additions & 0 deletions Dockerfile-gpu
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]
13 changes: 11 additions & 2 deletions src/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import time
import shutil
import git

import gc
import click
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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(",")
Expand Down

0 comments on commit fa1a4da

Please sign in to comment.