Skip to content

Commit 16dd965

Browse files
authored
Update dependencies / fix tests (#280)
* Update installation * Add debug_mode * Update installation * Update versions * Fix tests and upgrade requirements * Downgrade * Unrestricted requirements * Remove dep versions * Add dockerfile * Install git * Skip mxnet tests * Iterating on dockerfile * Skip mxnet tests
1 parent 119ee9e commit 16dd965

File tree

17 files changed

+140
-56
lines changed

17 files changed

+140
-56
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ Notes:
5555

5656
### Run the tests
5757

58-
We're using `pytest` for the tests. You can type `pytest`, or use
59-
this `Makefile` command:
58+
This project has _a lot_ of dependencies. To run the tests, I'm using Docker:
6059

6160
```bash
6261
❯ make test

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM ubuntu
2+
WORKDIR /usr/src/app
3+
4+
ARG DEBIAN_FRONTEND=noninteractive
5+
RUN apt-get update && \
6+
apt-get install -y build-essential && \
7+
apt-get install -y git ninja-build ccache libopenblas-dev libopencv-dev cmake && \
8+
apt-get install -y gcc mono-mcs g++ && \
9+
apt-get install -y python3 python3-pip && \
10+
apt-get install -y default-jdk && \
11+
rm -rf /var/lib/apt/lists/*
12+
13+
RUN pip3 install --upgrade pip setuptools
14+
15+
# Install & install requirements
16+
ADD requirements-dev0.txt ./requirements-dev0.txt
17+
RUN pip3 install -r requirements-dev0.txt
18+
19+
ADD requirements-dev1.txt ./requirements-dev1.txt
20+
RUN pip3 install -r requirements-dev1.txt
21+
22+
ADD requirements.txt ./requirements.txt
23+
RUN pip3 install -r requirements.txt
24+
25+
# Copy library source
26+
COPY modelstore ./modelstore
27+
COPY tests ./tests
28+
29+
# Run tests
30+
ENTRYPOINT ["python3", "-m", "pytest", "--exitfirst", "./tests"]

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
VIRTUALENV_NAME=$(shell pwd | rev | cut -d '/' -f 1 | rev)-dev
22

3-
.PHONY: library test setup install uninstall release-test release-prod clean update
4-
3+
.PHONY: uninstall
54
uninstall:
65
@./bin/_pyenv_uninstall $(VIRTUALENV_NAME)
76

7+
.PHONY: setup
88
setup:
99
@./bin/_brew_install
1010

11+
.PHONY: install
1112
install: uninstall
1213
@./bin/_pyenv_install $(VIRTUALENV_NAME)
1314

15+
.PHONY: update
1416
update:
1517
@./bin/_pyenv_update
1618

19+
.PHONY: build
1720
build : test
1821
@./bin/_build_library
1922

23+
.PHONY: test
2024
test:
21-
@python -m pytest tests/
25+
@docker build . -t modelstore-dev
26+
@docker run -it --rm modelstore-dev
2227

28+
.PHONY: release-test
2329
release-test: build
2430
@./bin/_release_test
2531

32+
.PHONY: release-prod
2633
release-prod:
2734
@./bin/_release_prod
2835

36+
.PHONY: cleanup
2937
clean:
3038
@./bin/_cleanup

bin/_cleanup

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
2-
echo "\n 🧼 Removing pycache files"
2+
echo -e "\n 🧼 Removing pycache files"
33
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
44

5-
echo "\n 🧼 Removing build directories"
5+
echo -e "\n 🧼 Removing build directories"
66
rm -rf *.egg-info
77
rm -rf build
88
rm -rf dist
99

10-
echo "\n 🎉 Done."
10+
echo -e "\n 🎉 Done."

bin/_pyenv_config

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/bin/bash
22
# export PYTHON_VERSION=3.7.15
3-
# export PYTHON_VERSION=3.8.12
4-
export PYTHON_VERSION=3.9.16
3+
export PYTHON_VERSION=3.8.12
4+
# export PYTHON_VERSION=3.9.16
55

66
export VIRTUALENV_NAME="$1-${PYTHON_VERSION//./-}"
77
export REPO_ROOT=$(cd $(dirname $0)/.. && pwd)
88

99
echo -e "\n 💬 Using a venv called: ${VIRTUALENV_NAME}"
10+
11+
eval "$(pyenv init --path)"
12+
eval "$(pyenv virtualenv-init -)"

bin/_pyenv_install

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ env PYTHON_CONFIGURE_OPTS="--enable-framework CC=clang" \
1919
echo -e "\n 💬 Setting local: $VIRTUALENV_NAME"
2020
pyenv local $VIRTUALENV_NAME
2121

22+
echo -e "\n 💬 Upgrading pip"
2223
pip install --upgrade pip setuptools wheel
24+
2325
for i in ./requirements*txt; do
2426
echo -e "\n\n 💬 Installing requirements in: $i"
2527
pip install -r $i

modelstore/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright 2024 Neal Lathia
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
114
from pkg_resources import DistributionNotFound, get_distribution
215

316
# pylint: disable=unused-import

modelstore/models/managers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def get_manager(name: str, storage: CloudStorage = None) -> ModelManager:
9595
manager = TensorflowManager(storage)
9696
else:
9797
manager = _LIBRARIES[name](storage)
98-
if all(module_exists(x) for x in manager.required_dependencies()):
99-
return manager
100-
raise ValueError(f"could not create manager for {name}: dependencies not installed")
98+
for x in manager.required_dependencies():
99+
if not module_exists(x):
100+
raise ValueError(f"could not create manager for {name}: {x} not installed")
101+
return manager
102+

modelstore/utils/log.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import logging
1515
import sys
1616

17-
1817
def get_logger():
1918
"""Builds the modelstore logger"""
2019
log = logging.getLogger(name="modelstore")
@@ -27,3 +26,13 @@ def get_logger():
2726

2827

2928
logger = get_logger()
29+
30+
31+
def debug_mode(on: bool):
32+
global logger
33+
logger = get_logger()
34+
if not on:
35+
return
36+
logger.setLevel(logging.DEBUG)
37+
for handler in logger.handlers:
38+
handler.setLevel(logging.DEBUG)

requirements-dev0.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ rope>=1.6.0
1010
twine>=4.0.2
1111

1212
# Data / dependencies for ML libraries
13-
numpy==1.23.5 # numba 0.58.0 requires numpy<1.26,>=1.21; numpy>1.23.5 currently breaks mxnet
14-
numba>=0.55.1
15-
Cython>=0.29.28
16-
python-Levenshtein>=0.12.2
13+
numba>=0.58.1
14+
numpy==1.23.5 # numpy>1.23.5 currently breaks mxnet
15+
Cython>=3.0.8
16+
python-Levenshtein>=0.24.0
1717
pandas>=1.3.5; python_version < '3.8'
1818
pandas>=1.4.1; python_version > '3.7'
19+
20+
# ML Dependencies
21+
# pydoop<=2.0.0; sys_platform == 'darwin'

0 commit comments

Comments
 (0)