From 1894d21771b9af170f64a744b79e77e7abcc236d Mon Sep 17 00:00:00 2001 From: Hamza Imran Saeed Date: Wed, 29 Nov 2023 18:52:03 +0100 Subject: [PATCH] adding break to loop --- serve-python/Dockerfile.test | 24 +++++++++++++---------- serve-python/tests/model/requirements.txt | 1 - serve-python/tests/test_api.py | 6 ++++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/serve-python/Dockerfile.test b/serve-python/Dockerfile.test index b10fa5f..5f1b7f1 100644 --- a/serve-python/Dockerfile.test +++ b/serve-python/Dockerfile.test @@ -12,15 +12,17 @@ RUN useradd -m -u 1000 $USER # Set working directory (this is where the code should go) WORKDIR $HOME -RUN /bin/bash -c "apt update" -RUN /bin/bash -c "apt install python3.7-dev -y" -RUN /bin/bash -c "apt install curl -y" -RUN /bin/bash -c "apt-get install python3-distutils -y" -RUN /bin/bash -c "curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py" -RUN /bin/bash -c "python3.7 get-pip.py" -RUN /bin/bash -c "apt install gcc -y" -RUN /bin/bash -c "update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1" -RUN /bin/bash -c "pip3 install --upgrade pip" +RUN apt update \ + && apt install python3.7-dev -y \ + && apt install curl -y \ + && apt-get install python3-distutils -y \ + && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \ + && python3.7 get-pip.py \ + && apt install gcc -y \ + && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 \ + && pip3 install --upgrade pip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* # RUN /bin/bash -c "apt update" # RUN /bin/bash -c "curl https://dl.min.io/client/mc/release/linux-amd64/mc --output mc && chmod +x mc" COPY requirements.txt $HOME/requirements.txt @@ -34,7 +36,9 @@ RUN chmod +x start-script.sh \ && chmod +x deploy.sh \ && chown -R $USER:$USER $HOME +RUN cd models && pip3 install -r requirements.txt && cd .. + ENV STACKN_MODEL_PATH=$HOME/models ENV PYTHONPATH=$HOME/models -CMD ./deploy.sh \ No newline at end of file +CMD ["./deploy.sh"] \ No newline at end of file diff --git a/serve-python/tests/model/requirements.txt b/serve-python/tests/model/requirements.txt index 7f72cf6..c29e0a7 100644 --- a/serve-python/tests/model/requirements.txt +++ b/serve-python/tests/model/requirements.txt @@ -2,7 +2,6 @@ -e . pydantic torch @ https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp37-cp37m-linux_x86_64.whl -tensorflow transformers tokenizers==0.9.4 ipywidgets diff --git a/serve-python/tests/test_api.py b/serve-python/tests/test_api.py index 7b9289c..cf63162 100644 --- a/serve-python/tests/test_api.py +++ b/serve-python/tests/test_api.py @@ -41,13 +41,14 @@ def test_container_ports(): def test_container_access(): """Test of basic communication with the container returns status 200 (OK).""" - max_attempts = 100 + max_attempts = 20 for attempt in range(1, max_attempts + 1): try: url = _get_api_url(container) + "/health" response = requests.get(url, timeout=TIMEOUT_CALL) if response.status_code == 200: assert True + break except: pass if attempt == max_attempts: @@ -64,7 +65,7 @@ def test_container_access(): def test_prediction(): """Verify that the model can be used for predictions.""" - max_attempts = 100 + max_attempts = 20 for attempt in range(1, max_attempts + 1): # Set input string example = "Jag är ett barn, och det här är mitt hem. Alltså är det ett barnhem!" @@ -79,6 +80,7 @@ def test_prediction(): assert json.loads(text_decoded) == { "result": ["barn", "hem", "hus", "spädbarn", "##hem"] } + break if attempt == max_attempts: RuntimeError( f"Python Deployment did not become ready after {max_attempts} attempts"