Skip to content

adding ci pipeline and make sure quality and tests work #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Quality Check

on: [pull_request]

jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install Python dependencies
run: pip install -e .[quality]
- name: Run Quality check
run: make quality
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Run Tests

on: [pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install Python dependencies
run: pip install -e .[test,dev]
- name: Run Unit Tests
run: make unit-test
# - name: Run Integration Tests
# run: make integ-test
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: quality style unit-test integ-test

check_dirs := src deployment docker tests
check_dirs := src tests

# run tests

Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@
extras["transformers"] = ["transformers[sklearn,sentencepiece]>=4.5.1"]

# framework specific dependencies
extras["torch"] = ["torch>=1.4.0"]
extras["tensorflow-cpu"] = ["tensorflow-cpu>=2.3"]
extras["tensorflow"] = ["tensorflow>=2.3"]
extras["torch"] = ["torch>=1.8.0"]
extras["tensorflow"] = ["tensorflow>=2.4.0"]

# MMS Server dependencies
extras["mms"] = ["multi-model-server>=1.1.4", "retrying"]
Expand All @@ -74,7 +73,7 @@
"flake8>=3.8.3",
]

extras["all"] = extras["test"] + extras["quality"] + extras["benchmark"] + extras["transformers"] + extras["mms"]
extras["dev"] = extras["transformers"] + extras["mms"] + extras["torch"] + extras["tensorflow"]

setup(
name="sagemaker-huggingface-inference-toolkit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def decode_csv(string_like): # type: (str) -> np.array
# detects if the incoming csv has headers
if not any(header in string_like.splitlines()[0].lower() for header in ["question", "context", "inputs"]):
raise PredictionException(
f"You need to provide the correct CSV with Header columns to use it with the inference toolkit default handler.",
"You need to provide the correct CSV with Header columns to use it with the inference toolkit default handler.",
400,
)
# reads csv as io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from sagemaker_inference import content_types, environment, utils
from transformers.pipelines import SUPPORTED_TASKS

from mms import metrics
from mms.service import PredictionException
from sagemaker_huggingface_inference_toolkit import decoder_encoder
from sagemaker_huggingface_inference_toolkit.transformers_utils import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from huggingface_hub.file_download import cached_download, hf_hub_url
from transformers import pipeline
from transformers.file_utils import is_tf_available, is_torch_available
from transformers.pipelines import Pipeline, Conversation
from transformers.pipelines import Conversation, Pipeline


if is_tf_available():
import tensorflow as tf
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_decoder_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_decode_csv():
]
}
text_classification_input = "inputs\r\nI love you\r\nI like you"
decoded_data = decoder_encoder.decode_csv(DECODE_CSV_INPUT)
decoded_data = decoder_encoder.decode_csv(text_classification_input)
assert decoded_data == {"inputs": ["I love you", "I like you"]}


Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_handler_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
import json
import os
import sys
import tempfile

import pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_transformers_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import os
import tempfile

from transformers.file_utils import is_torch_available
from transformers import pipeline
from transformers.file_utils import is_torch_available
from transformers.testing_utils import require_tf, require_torch, slow

from sagemaker_huggingface_inference_toolkit.transformers_utils import (
Expand Down