Skip to content

Commit

Permalink
remove ftfy imports and add warning if not installed (microsoft#578)
Browse files Browse the repository at this point in the history
Co-authored-by: Sayan Shaw <sayanshaw@microsoft.com>
  • Loading branch information
sayanshaw24 and Sayan Shaw committed Oct 19, 2023
1 parent c71e2ae commit 92d17b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# include requirements.txt so pip has context to avoid installing incompatible dependencies
-r requirements.txt
pytest
ftfy
# multiple versions of onnxruntime are supported, but only one can be installed at a time
protobuf < 4.0.0
onnxruntime >=1.12.0
Expand Down
6 changes: 5 additions & 1 deletion test/test_autotokenizer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import unittest
import pkg_resources

import numpy as np
import ftfy
from transformers import AutoTokenizer, GPT2Tokenizer
from onnxruntime_extensions import OrtPyFunction, gen_processing_models, ort_inference, util

Expand Down Expand Up @@ -129,4 +129,8 @@ def print_prime(n):


if __name__ == '__main__':
try:
dist = pkg_resources.get_distribution('ftfy')
except pkg_resources.DistributionNotFound:
raise Exception("WARNING: ftfy is not installed - it is required for parity between CLIPTokenizer and CLIPTokenizerFast.")
unittest.main()
6 changes: 5 additions & 1 deletion test/test_cliptok.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
import numpy as np
import onnxruntime as _ort
import ftfy
import pkg_resources

from pathlib import Path
from onnx import helper, onnx_pb as onnx_proto
Expand Down Expand Up @@ -150,4 +150,8 @@ def test_optional_outputs(self):


if __name__ == "__main__":
try:
dist = pkg_resources.get_distribution('ftfy')
except pkg_resources.DistributionNotFound:
raise Exception("WARNING: ftfy is not installed - it is required for parity between CLIPTokenizer and CLIPTokenizerFast.")
unittest.main()

0 comments on commit 92d17b0

Please sign in to comment.