Push HuggingFace Model to S3 from HuggingFace Hub #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push HuggingFace Model to S3 from HuggingFace Hub | |
on: | |
workflow_dispatch: | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
AWS_REGION: "us-east-1" | |
ENVIRONMENT: ${{ github.ref_name == 'main' && 'prod' || github.ref_name == 'test' && 'test' }} | |
HF_USERNAME: "tabularisai" | |
HF_REPOSITORY_NAME: "multilingual-sentiment-analysis" | |
jobs: | |
push_model_to_s3: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Clone HuggingFace Repository | |
run: | | |
git clone https://huggingface.co/${{ env.HF_USERNAME }}/${{ env.HF_REPOSITORY_NAME }} | |
- name: Create Model Archive | |
run: | | |
cd ${{ env.HF_REPOSITORY_NAME }} | |
tar -czvf model.tar.gz * | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
audience: sts.amazonaws.com | |
aws-region: ${{ env.AWS_REGION }} | |
role-to-assume: arn:aws:iam::639269844451:role/github-actions | |
role-session-name: ${{ env.ENVIRONMENT }}-deployment | |
- name: Upload Model to S3 | |
env: | |
S3_BUCKET_NAME: "sagemaker-us-east-1-639269844451" | |
S3_MODEL_KEY: "${{ env.ENVIRONMENT }}/${{ env.HF_USERNAME }}/${{ env.HF_REPOSITORY_NAME }}/model.tar.gz" | |
run: | | |
cd ${{ env.HF_REPOSITORY_NAME }} | |
aws s3 cp model.tar.gz s3://${{ env.S3_BUCKET_NAME }}/${{ env.S3_MODEL_KEY }} --no-progress |