mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 10:35:01 +00:00
fix(transformers*): add sentence-transformers and transformers-musicgen tests, fix musicgen wrapper (#1420)
* tests: add sentence-transformers and transformers-musicgen Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com> * fix: tranformers-musicgen conda env Initialize correctly the environment for the transformers-musicgen backend. * fix(tests): transformer-musicgen tests fixups --------- Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
This commit is contained in:
parent
9222bec8b1
commit
718a5d4a9e
5 changed files with 65 additions and 7 deletions
|
@ -19,6 +19,7 @@ class TestBackendServicer(unittest.TestCase):
|
|||
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 @@ class TestBackendServicer(unittest.TestCase):
|
|||
"""
|
||||
This method tests if the server starts up successfully
|
||||
"""
|
||||
time.sleep(2)
|
||||
try:
|
||||
self.setUp()
|
||||
with grpc.insecure_channel("localhost:50051") as channel:
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
echo "Launching gRPC server for transformers-musicgen"
|
||||
|
||||
export PATH=$PATH:/opt/conda/bin
|
||||
|
||||
# Activate conda environment
|
||||
source $CONDA_PREFIX/etc/profile.d/conda.sh
|
||||
conda activate transformers-musicgen
|
||||
source activate transformers-musicgen
|
||||
|
||||
# get the directory where the bash script is located
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
## A bash script wrapper that runs the transformers server with conda
|
||||
|
||||
# Activate conda environment
|
||||
source conda activate transformers-musicgen
|
||||
source 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
|
||||
python -m unittest $DIR/test_transformers.py
|
|
@ -19,6 +19,7 @@ class TestBackendServicer(unittest.TestCase):
|
|||
This method sets up the gRPC service by starting the server
|
||||
"""
|
||||
self.service = subprocess.Popen(["python3", "transformers_server.py", "--addr", "localhost:50051"])
|
||||
time.sleep(10)
|
||||
|
||||
def tearDown(self) -> None:
|
||||
"""
|
||||
|
@ -31,7 +32,6 @@ class TestBackendServicer(unittest.TestCase):
|
|||
"""
|
||||
This method tests if the server starts up successfully
|
||||
"""
|
||||
time.sleep(2)
|
||||
try:
|
||||
self.setUp()
|
||||
with grpc.insecure_channel("localhost:50051") as channel:
|
||||
|
@ -71,7 +71,7 @@ class TestBackendServicer(unittest.TestCase):
|
|||
stub = backend_pb2_grpc.BackendStub(channel)
|
||||
response = stub.LoadModel(backend_pb2.ModelOptions(Model="facebook/musicgen-small"))
|
||||
self.assertTrue(response.success)
|
||||
tts_request = backend_pb2.TTSRequest(Model="facebook/musicgen-small", Input="80s TV news production music hit for tonight's biggest story")
|
||||
tts_request = backend_pb2.TTSRequest(text="80s TV news production music hit for tonight's biggest story")
|
||||
tts_response = stub.TTS(tts_request)
|
||||
self.assertIsNotNone(tts_response)
|
||||
except Exception as err:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue