From 284121c66f5ed6fe086968cea46b9ce1431c8d5e Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Mon, 11 Dec 2023 17:04:48 +0000 Subject: [PATCH] tests: add sentence-transformers and transformers-musicgen Signed-off-by: Ettore Di Giacinto --- .github/workflows/test-extra.yml | 58 +++++++++++++++++++ .../test_sentencetransformers.py | 2 +- backend/python/transformers-musicgen/test.sh | 2 +- 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-extra.yml b/.github/workflows/test-extra.yml index 30c198af77a2..84af1683ec09 100644 --- a/.github/workflows/test-extra.yml +++ b/.github/workflows/test-extra.yml @@ -43,6 +43,34 @@ jobs: make -C backend/python/transformers make -C backend/python/transformers test + tests-sentencetransformers: + runs-on: ubuntu-latest + steps: + - name: Clone + uses: actions/checkout@v4 + with: + submodules: true + - name: Dependencies + run: | + sudo apt-get update + sudo apt-get install build-essential ffmpeg + curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg && \ + sudo install -o root -g root -m 644 conda.gpg /usr/share/keyrings/conda-archive-keyring.gpg && \ + gpg --keyring /usr/share/keyrings/conda-archive-keyring.gpg --no-default-keyring --fingerprint 34161F5BF5EB1D4BFBBB8F0A8AEB4F8B29D82806 && \ + sudo /bin/bash -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list' && \ + sudo /bin/bash -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" | tee -a /etc/apt/sources.list.d/conda.list' && \ + sudo apt-get update && \ + sudo apt-get install -y conda + sudo apt-get install -y ca-certificates cmake curl patch + sudo apt-get install -y libopencv-dev && sudo ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2 + + sudo rm -rfv /usr/bin/conda || true + + - name: Test sentencetransformers + run: | + export PATH=$PATH:/opt/conda/bin + make -C backend/python/sentencetransformers + make -C backend/python/sentencetransformers test tests-diffusers: runs-on: ubuntu-latest @@ -74,4 +102,34 @@ jobs: make -C backend/python/diffusers test + tests-transformers-musicgen: + runs-on: ubuntu-latest + steps: + - name: Clone + uses: actions/checkout@v4 + with: + submodules: true + - name: Dependencies + run: | + sudo apt-get update + sudo apt-get install build-essential ffmpeg + curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg && \ + sudo install -o root -g root -m 644 conda.gpg /usr/share/keyrings/conda-archive-keyring.gpg && \ + gpg --keyring /usr/share/keyrings/conda-archive-keyring.gpg --no-default-keyring --fingerprint 34161F5BF5EB1D4BFBBB8F0A8AEB4F8B29D82806 && \ + sudo /bin/bash -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list' && \ + sudo /bin/bash -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" | tee -a /etc/apt/sources.list.d/conda.list' && \ + sudo apt-get update && \ + sudo apt-get install -y conda + sudo apt-get install -y ca-certificates cmake curl patch + sudo apt-get install -y libopencv-dev && sudo ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2 + + sudo rm -rfv /usr/bin/conda || true + + - name: Test transformers-musicgen + run: | + export PATH=$PATH:/opt/conda/bin + make -C backend/python/transformers-musicgen + make -C backend/python/transformers-musicgen test + + \ No newline at end of file diff --git a/backend/python/sentencetransformers/test_sentencetransformers.py b/backend/python/sentencetransformers/test_sentencetransformers.py index 4790ae74e95c..45ba1e5cf103 100644 --- a/backend/python/sentencetransformers/test_sentencetransformers.py +++ b/backend/python/sentencetransformers/test_sentencetransformers.py @@ -19,6 +19,7 @@ def setUp(self): This method sets up the gRPC service by starting the server """ self.service = subprocess.Popen(["python3", "sentencetransformers.py", "--addr", "localhost:50051"]) + time.sleep(10) def tearDown(self) -> None: """ @@ -31,7 +32,6 @@ def test_server_startup(self): """ This method tests if the server starts up successfully """ - time.sleep(2) try: self.setUp() with grpc.insecure_channel("localhost:50051") as channel: diff --git a/backend/python/transformers-musicgen/test.sh b/backend/python/transformers-musicgen/test.sh index ab2f2e3e6889..f284db55ef26 100644 --- a/backend/python/transformers-musicgen/test.sh +++ b/backend/python/transformers-musicgen/test.sh @@ -8,4 +8,4 @@ source conda activate transformers-musicgen # get the directory where the bash script is located DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -python -m unittest $DIR/test_transformers_server.py \ No newline at end of file +python -m unittest $DIR/test_transformers.py \ No newline at end of file