-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from beclab/feat/bertv3-embedding
feat: add r4userembedding with model image
- Loading branch information
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Publish to Dockerhub ( userembedding ) | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tags: | ||
description: 'Release Tags' | ||
|
||
jobs: | ||
publish_dockerhub_amd64: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASS }} | ||
|
||
- name: Build r4userembeddingwithmodel and push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: beclab/r4userembeddingwithmodel:${{ github.event.inputs.tags }}-amd64 | ||
file: Dockerfile.r4userembeddingwithmodel | ||
platforms: linux/amd64 | ||
|
||
publish_dockerhub_arm64: | ||
runs-on: self-hosted | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASS }} | ||
|
||
- name: Build r4userembeddingwithmodel and push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: beclab/r4userembeddingwithmodel:${{ github.event.inputs.tags }}-arm64 | ||
file: Dockerfile.r4userembeddingwithmodel | ||
platforms: linux/arm64 | ||
|
||
publish_manifest: | ||
needs: | ||
- publish_dockerhub_amd64 | ||
- publish_dockerhub_arm64 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASS }} | ||
|
||
- name: Push manifest | ||
run: | | ||
docker manifest create beclab/r4userembeddingwithmodel:${{ github.event.inputs.tags }} --amend beclab/r4userembeddingwithmodel:${{ github.event.inputs.tags }}-amd64 --amend beclab/r4userembeddingwithmodel:${{ github.event.inputs.tags }}-arm64 | ||
docker manifest push beclab/r4userembeddingwithmodel:${{ github.event.inputs.tags }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM ubuntu:jammy As builder | ||
|
||
# RUN apk add openssl-dev musl-dev g++ | ||
|
||
RUN mkdir -p /userembedding && \ | ||
apt update && \ | ||
apt install curl -y && \ | ||
curl https://sh.rustup.rs -sSf | bash -s -- -y && \ | ||
# echo 'source $HOME/.cargo/env' >> $HOME/.bashrc && \ | ||
apt install build-essential -y && \ | ||
apt-get install libssl-dev -y && \ | ||
apt-get install pkg-config -y | ||
|
||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
WORKDIR /userembedding | ||
COPY user-embedding/src /userembedding/src | ||
COPY user-embedding/Cargo.toml /userembedding/Cargo.toml | ||
RUN cargo build --release | ||
RUN /userembedding/target/release/downloadmodel | ||
|
||
|
||
|
||
FROM ubuntu:jammy | ||
|
||
# Import from builder. | ||
|
||
|
||
WORKDIR /userembedding | ||
|
||
# Copy our build | ||
COPY --from=builder /root/.cache/huggingface /root/.cache/huggingface | ||
COPY --from=builder /userembedding/target/release/userembedding ./ | ||
|
||
|
||
CMD ["/userembedding/userembedding"] |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use hf_hub::api::sync::Api; | ||
|
||
use userembedding::{ | ||
common, | ||
embedding_common::{self, MODEL_RELATED_INFO_MAP}, | ||
}; | ||
|
||
fn download_models() -> Result<(), Box<dyn std::error::Error>> { | ||
for (_, model_related_info) in MODEL_RELATED_INFO_MAP.iter() { | ||
tracing::info!("Downloading model {}...", model_related_info.model_name); | ||
let default_model: String = model_related_info.hugging_face_model_name.to_string(); | ||
let default_revision: String = model_related_info.hugging_face_model_revision.to_string(); | ||
let (_, _) = | ||
embedding_common::build_model_and_tokenizer(default_model, default_revision).unwrap(); | ||
tracing::info!( | ||
"Model {} downloaded successfully", | ||
model_related_info.model_name | ||
); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
fn main() { | ||
// Call the function to download models | ||
common::init_logger(); | ||
|
||
if let Err(e) = download_models() { | ||
eprintln!("Error downloading models: {}", e); | ||
} | ||
} |