From acd01575e8e034aad79cb0f8b3a9b903ad849496 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 4 Sep 2024 18:44:24 +0800 Subject: [PATCH] add github actions --- .github/workflows/build_push_image.yml | 52 ++++++++++++++++++++++++++ .github/workflows/smoke_test.yml | 52 ++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 .github/workflows/build_push_image.yml create mode 100644 .github/workflows/smoke_test.yml diff --git a/.github/workflows/build_push_image.yml b/.github/workflows/build_push_image.yml new file mode 100644 index 0000000..8fe3a8c --- /dev/null +++ b/.github/workflows/build_push_image.yml @@ -0,0 +1,52 @@ +name: "CD: build & push image" + +on: + push: + branches: + - 'init' + +# on: +# workflow_dispatch: + +env: + PYTHON_DEFAULT_VERSION: "3.12" + TAG_VERSION: "v0-latest" + DOCKER_REPO_NAME: "backenddevelopersltd/compute-horde-prompt-gen" + +jobs: + deploy: + timeout-minutes: 15 + # runs-on: ubuntu-latest + # runs-on: ubuntu-latest-4-cores + runs-on: + group: bulkier + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_DEFAULT_VERSION }} + + - name: Login Dockerhub + run: echo "${{ secrets.DOCKERHUB_KEY }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin + + - name: Install dependencies + run: | + # python -m pip install --upgrade 'pdm>=2.12,<3' + # pdm install transformers + python -m pip install transformers torch + + - name: Docker build and push + run: | + df -h + IMAGE_NAME="${DOCKER_REPO_NAME}:${TAG_VERSION}" + + cd src/compute_horde_prompt_gen + python download_model.py --huggingface_token "${{ secrets.HUGGINGFACE_API_KEY }}" + + ls + docker build -t $IMAGE_NAME . + + # docker run -v ./output/:/app/output/ $IMAGE_NAME --number_of_batches 5 --number_of_prompts_per_batch 30 --uuids uuid1,uuid2,uuid3,uuid4,uuid5 diff --git a/.github/workflows/smoke_test.yml b/.github/workflows/smoke_test.yml new file mode 100644 index 0000000..da9979a --- /dev/null +++ b/.github/workflows/smoke_test.yml @@ -0,0 +1,52 @@ +name: Run Smoke Test + +on: + push: + branches: [master, main] + pull_request: + branches: [master, main] + +env: + PYTHON_DEFAULT_VERSION: "3.11" + +jobs: + test: + timeout-minutes: 10 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }} + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_DEFAULT_VERSION }} + + - name: Run Test + run: | + cd src/compute_horde_prompt_gen + + python3 run.py --mock_model --number_of_batches 5 --number_of_prompts_per_batch 20 --uuids uuid1,uuid2,uuid3,uuid4,uuid5 + + # mkdir saved_models/ + # mkdir output/ + # + # echo "building image with no model" + # docker build -t compute-horde-prompt-gen . + # + # echo "running prompt generation with mock model" + # docker run -v ./output/:/app/output/ compute-horde-prompt-gen --mock_model --number_of_batches 5 --number_of_prompts_per_batch 20 --uuids uuid1,uuid2,uuid3,uuid4,uuid5 + + echo -e "\ngenerated batches:" + ls output/ + + echo -e "\nchecking if prompts are generated fine" + for i in $(seq 1 5); do + if [ $(cat output/prompts_uuid$i.txt | wc -l) -ne 20 ]; then + echo "Missing prompts: $(cat output/prompts_uuid{$i}.txt)" + exit 1 + fi + done + echo "OK" +