Skip to content

Commit

Permalink
Merge pull request #20 from huggingface/build_images_and_run_tests_001
Browse files Browse the repository at this point in the history
Restructure workflow files
  • Loading branch information
ydshieh authored Feb 29, 2024
2 parents d81e9a2 + 4aac639 commit 0618bbb
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 40 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build images and run tests

on:
workflow_call:
inputs:
dockerfile_path:
description: 'Path to the Dockerfile'
type: string
required: true
docker_image_tag: # It should be in the form as mentioned in our internal docs. Just pass insensitive data here like huggingface-text-generation-inference-${accelerator}.${version}:latest
description: 'Docker Image Tag'
type: string
required: true

jobs:
build-push-image:
uses: ./.github/workflows/build_push_image.yml
secrets: inherit
with:
region: us-central1
dockerfile_path: ${{ inputs.dockerfile_path }}
docker_image_tag: ${{ inputs.docker_image_tag }}
gcp_artifact_registry_repository: deep-learning-images
GCP_PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}

model_test:
needs: build-push-image
uses: ./.github/workflows/test_model.yml
secrets: inherit
with:
region: us-central1
docker_image_tag: ${{ inputs.docker_image_tag }}
gcp_artifact_registry_repository: deep-learning-images
GCP_PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Push to GCP Artifact Registry Resuable Workflow
name: Build and push images

on:
workflow_call:
Expand All @@ -19,16 +19,13 @@ on:
description: 'GCP Artifact Registry Repository'
type: string
required: true
secrets:
GCP_SERVICE_ACCOUNT_JSON_KEY:
description: 'Service Account'
required: true
GCP_PROJECT_ID:
description: 'GCP Project ID'
type: string
required: true

jobs:
build-push-image-job:
build-push-image:
name: Build and Push Docker Image to GCP Artifact Registry
runs-on: [intel-cpu, 8-cpu, ci]
steps:
Expand All @@ -55,7 +52,5 @@ jobs:
uses: 'docker/[email protected]'
with:
file: ${{ inputs.dockerfile_path }} # Read more about it here: https://github.com/marketplace/actions/build-and-push-docker-images#customizing
tags: ${{ inputs.region }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ inputs.gcp_artifact_registry_repository }}/${{ inputs.docker_image_tag }}
tags: ${{ inputs.region }}-docker.pkg.dev/${{ inputs.GCP_PROJECT_ID }}/${{ inputs.gcp_artifact_registry_repository }}/${{ inputs.docker_image_tag }}
push: true


20 changes: 20 additions & 0 deletions .github/workflows/run_build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build images and run tests

on:
push:
branches:
- build_images_and_run_tests_*

jobs:
build-push-image:
strategy:
fail-fast: false
matrix:
torch: [2.1]
transformers: [4.38.1]
python: [310]
uses: ./.github/workflows/build_and_test.yml
secrets: inherit
with:
dockerfile_path: ./containers/pytorch/training/gpu/${{ matrix.torch }}/transformers/${{ matrix.transformers }}/py${{ matrix.python }}/Dockerfile
docker_image_tag: huggingface-pytorch-training-gpu-${{ matrix.torch }}.transformers.${{ matrix.transformers }}.py${{ matrix.python }}:latest
15 changes: 0 additions & 15 deletions .github/workflows/test-build-push-image.yml

This file was deleted.

43 changes: 35 additions & 8 deletions .github/workflows/test_model.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
name: Model Test
name: Model tests

on:
push:
branches:
- run_tests_against_images_*
workflow_call:
inputs:
region:
description: 'Region where the Artifact Registry is located'
type: string
required: true
docker_image_tag: # It should be in the form as mentioned in our internal docs. Just pass insensitive data here like huggingface-text-generation-inference-${accelerator}.${version}:latest
description: 'Docker Image Tag'
type: string
required: true
gcp_artifact_registry_repository:
description: 'GCP Artifact Registry Repository'
type: string
required: true
GCP_PROJECT_ID:
description: 'GCP Project ID'
type: string
required: true

env:
HF_HOME: /mnt/cache
Expand All @@ -13,16 +28,28 @@ env:

jobs:
run_test:
name: github repo
name: Run model tests
runs-on: [single-gpu, nvidia-gpu, a10, ci]
container:
# TODO: make this $ {{ inputs.image }} to use GCP's DLC images
image: huggingface/transformers-all-latest-gpu
image: ${{ inputs.region }}-docker.pkg.dev/${{ inputs.GCP_PROJECT_ID }}/${{ inputs.gcp_artifact_registry_repository }}/${{ inputs.docker_image_tag }}
options: --gpus all --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/
credentials:
username: _json_key
password: ${{ secrets.GCP_SERVICE_ACCOUNT_JSON_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Prepare `transformers` examples/pytorch directory
shell: bash
run: |
git config --global --add safe.directory /__w/Google-Cloud-Containers/Google-Cloud-Containers
git clone https://github.com/huggingface/transformers.git
cd transformers
git checkout tags/v4.38.1
git log -n 1
- name: run tests
run: |
export TRANSFORMERS_DIR=/__w/Google-Cloud-Containers/Google-Cloud-Containers/transformers
python3 -m pytest -v tests/models
10 changes: 2 additions & 8 deletions tests/models/vit/test_training_vit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@
from ..test_model import ModelTrainingTestMixin, TestCasePlus


# So far, the image we use has a `/transformers` directory.
# TODO: Find a way to get the installed `transformers` directory.
SRC_DIRS = [
os.path.join("/transformers/examples/pytorch", dirname)
for dirname in [
"image-classification",
]
]
# `TRANSFORMERS_DIR` is an environment variable pointing to a `transformers` source directory (containing `examples`)
SRC_DIRS = [os.path.join(os.getenv("TRANSFORMERS_DIR"), "examples/pytorch", dirname) for dirname in ["image-classification"]]
sys.path.extend(SRC_DIRS)


Expand Down

0 comments on commit 0618bbb

Please sign in to comment.