From 656a06d35ea742c53c546f3abf504e731353b63b Mon Sep 17 00:00:00 2001 From: Sherif Akoush Date: Thu, 5 Aug 2021 10:49:29 +0100 Subject: [PATCH] Sherif akoush/quickfix/improve docs (#180) Co-authored-by: Sherif Akoush --- .github/workflows/tests.yml | 7 ++++-- CONTRIBUTING.md | 9 +++++++ Dockerfile | 2 +- requirements-dev.txt | 1 + setup.py | 2 +- tests/artifacts/pipeline/conda.yaml.tmpl | 20 +-------------- tests/conftest.py | 32 +++++++++++++----------- tests/seldon/docker/test_pipeline.py | 6 ++--- 8 files changed, 39 insertions(+), 40 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f4a4ffc4..b32fce77 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,13 +9,16 @@ on: jobs: tests: runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.7', '3.8', '3.9' ] steps: - uses: actions/checkout@v2 - - name: Set up Python 3.7 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: 3.7.10 + python-version: ${{ matrix.python-version }} - name: Install dependencies run: | make install-dev diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bdfc0d1a..c8a7b66c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,3 +84,12 @@ You can do so as: $ pytest ``` +### Additional system requirements for running the tests: + +- `docker` +- `conda`: for example `Miniconda`, follow the steps described in this [link](https://docs.conda.io/projects/conda/en/latest/user-guide/). +- Models artifacts: +For first time, install `gsutil` and download the models from Seldon's Google Storage bucket: +```bash +$ make tests/testdata +``` diff --git a/Dockerfile b/Dockerfile index 7e6212f0..7dca8fa2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ LABEL name="Seldon MLOPs Utils" \ vendor="Seldon Technologies" \ version="0.1" \ release="1" \ - summary="Seldon MLOPs untils" \ + summary="Seldon MLOPs Utils" \ description="Artifact handling utilities" RUN pip install pip -U diff --git a/requirements-dev.txt b/requirements-dev.txt index fd68100f..ba7f4d4b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,6 +6,7 @@ mypy==0.800 # Testing pytest==6.2.0 +pytest-cov==2.12.1 pytest-asyncio==0.14.0 pytest-cases==3.4.6 tox==3.22.0 diff --git a/setup.py b/setup.py index b02a62dc..50ab8ea9 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ def _load_description() -> str: url="https://github.com/SeldonIO/tempo", packages=find_packages(), include_package_data=True, - python_requires=">=3.6", + python_requires=">=3.7", setup_requires=["pytest-runner"], install_requires=[ "grpcio>=1.32.0", diff --git a/tests/artifacts/pipeline/conda.yaml.tmpl b/tests/artifacts/pipeline/conda.yaml.tmpl index 21797d68..a15dbf5c 100644 --- a/tests/artifacts/pipeline/conda.yaml.tmpl +++ b/tests/artifacts/pipeline/conda.yaml.tmpl @@ -1,23 +1,5 @@ channels: - defaults dependencies: -- _libgcc_mutex=0.1=main -- ca-certificates=2021.1.19=h06a4308_1 -- certifi=2020.12.5=py37h06a4308_0 -- ld_impl_linux-64=2.33.1=h53a641e_7 -- libffi=3.3=he6710b0_2 -- libgcc-ng=9.1.0=hdf63c60_0 -- libstdcxx-ng=9.1.0=hdf63c60_0 -- ncurses=6.2=he6710b0_1 -- openssl=1.1.1k=h27cfd23_0 -- pip=21.0.1=py37h06a4308_0 -- python=3.7.10=hdb3f193_0 -- readline=8.1=h27cfd23_0 -- setuptools=52.0.0=py37h06a4308_0 -- sqlite=3.35.3=hdfb4753_0 -- tk=8.6.10=hbc83047_0 -- wheel=0.36.2=pyhd3eb1b0_0 -- xz=5.2.5=h7b6447c_0 -- zlib=1.2.11=h7b6447c_3 +- pip name: mlops-test -prefix: /home/clive/anaconda3/envs/mlops-test diff --git a/tests/conftest.py b/tests/conftest.py index b43704a5..22e106eb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ import os +import sys from pathlib import Path import numpy as np @@ -26,20 +27,23 @@ def pytest_collection_modifyitems(items): @pytest.fixture def pipeline_conda_yaml() -> str: - condaPath = PIPELINE_LOCAL_DIR + "/conda.yaml" - if not os.path.isfile(condaPath): - with open(PIPELINE_LOCAL_DIR + "/conda.yaml.tmpl") as f: - env = yaml.safe_load(f) - path = Path(TESTS_PATH) - parent = path.parent.absolute() - pip_deps = {"pip": []} - env["dependencies"].append(pip_deps) - for dep in MLServerEnvDeps: - pip_deps["pip"].append(dep) - pip_deps["pip"].append("mlops-tempo @ file://" + str(parent)) - with open(condaPath, "w") as f2: - yaml.safe_dump(env, f2) - return condaPath + vi = sys.version_info + python_version = f"{vi.major}.{vi.minor}.{vi.micro}" + conda_path = PIPELINE_LOCAL_DIR + "/conda.yaml" + with open(PIPELINE_LOCAL_DIR + "/conda.yaml.tmpl") as f: + env = yaml.safe_load(f) + path = Path(TESTS_PATH) + parent = path.parent.absolute() + env["dependencies"].append(f"python={python_version}") + pip_deps = {"pip": []} + env["dependencies"].append(pip_deps) + for dep in MLServerEnvDeps: + pip_deps["pip"].append(dep) + pip_deps["pip"].append("mlops-tempo @ file://" + str(parent)) + # pin the python version + with open(conda_path, "w") as f2: + yaml.safe_dump(env, f2) + return conda_path @pytest.fixture diff --git a/tests/seldon/docker/test_pipeline.py b/tests/seldon/docker/test_pipeline.py index 531b1f67..41d02da9 100644 --- a/tests/seldon/docker/test_pipeline.py +++ b/tests/seldon/docker/test_pipeline.py @@ -9,12 +9,12 @@ def test_conda_yaml(pipeline_conda_yaml): - print(pipeline_conda_yaml) with open(pipeline_conda_yaml) as f: env = yaml.safe_load(f) for dep in env["dependencies"]: - if dep == "pip": - assert dep[0] == MLServerEnvDeps[0] + # we want to fetch the pip dependencies + if isinstance(dep, dict): + assert dep["pip"][0] == MLServerEnvDeps[0] def test_deploy_pipeline_docker(