Skip to content

Commit

Permalink
adding break to loop
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzaimran08 committed Nov 29, 2023
1 parent 5701477 commit 1894d21
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
24 changes: 14 additions & 10 deletions serve-python/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 \

Check failure on line 15 in serve-python/Dockerfile.test

View workflow job for this annotation

GitHub Actions / lint

DL3015 info: Avoid additional packages by specifying `--no-install-recommends`

Check failure on line 15 in serve-python/Dockerfile.test

View workflow job for this annotation

GitHub Actions / lint

DL3042 warning: Avoid use of cache directory with pip. Use `pip install --no-cache-dir <package>`

Check failure on line 15 in serve-python/Dockerfile.test

View workflow job for this annotation

GitHub Actions / lint

DL3027 warning: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead

Check failure on line 15 in serve-python/Dockerfile.test

View workflow job for this annotation

GitHub Actions / lint

DL3015 info: Avoid additional packages by specifying `--no-install-recommends`

Check failure on line 15 in serve-python/Dockerfile.test

View workflow job for this annotation

GitHub Actions / lint

DL3042 warning: Avoid use of cache directory with pip. Use `pip install --no-cache-dir <package>`

Check failure on line 15 in serve-python/Dockerfile.test

View workflow job for this annotation

GitHub Actions / lint

DL3027 warning: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead
&& 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
Expand All @@ -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 ..

Check failure on line 39 in serve-python/Dockerfile.test

View workflow job for this annotation

GitHub Actions / lint

DL3003 warning: Use WORKDIR to switch to a directory

Check failure on line 39 in serve-python/Dockerfile.test

View workflow job for this annotation

GitHub Actions / lint

DL3042 warning: Avoid use of cache directory with pip. Use `pip install --no-cache-dir <package>`

Check failure on line 39 in serve-python/Dockerfile.test

View workflow job for this annotation

GitHub Actions / lint

DL3003 warning: Use WORKDIR to switch to a directory

Check failure on line 39 in serve-python/Dockerfile.test

View workflow job for this annotation

GitHub Actions / lint

DL3042 warning: Avoid use of cache directory with pip. Use `pip install --no-cache-dir <package>`

ENV STACKN_MODEL_PATH=$HOME/models
ENV PYTHONPATH=$HOME/models

CMD ./deploy.sh
CMD ["./deploy.sh"]
1 change: 0 additions & 1 deletion serve-python/tests/model/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions serve-python/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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!"
Expand All @@ -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"
Expand Down

0 comments on commit 1894d21

Please sign in to comment.