Accelerate Tests

- Create local and cloud test folders and move all the tests with duration > 1 second to the cloud tests.
- Update scripts
This commit is contained in:
Ömer Faruk Özdemir 2022-02-07 14:29:55 +03:00
parent 622e11c045
commit bb6805e25f
21 changed files with 9 additions and 11 deletions

View File

@ -1,9 +1,9 @@
import pkg_resources
from gradio.routes import get_state, set_state
from gradio.flagging import *
from gradio.interface import *
from gradio.mix import *
from gradio.flagging import FlaggingCallback, SimpleCSVLogger, CSVLogger, HuggingFaceDatasetSaver
from gradio.interface import Interface, close_all, reset_all
from gradio.mix import Parallel, Series
current_pkg_version = pkg_resources.require("gradio")[0].version
__version__ = current_pkg_version

View File

@ -4,5 +4,5 @@ if [ -z "$(ls | grep CONTRIBUTING.md)" ]; then
exit -1
else
echo "Running the tests"
python -m unittest
python -m pytest --durations=0 test/local
fi

0
test/cloud/__init__.py Normal file
View File

View File

@ -31,13 +31,11 @@ class TestHuggingFaceModelAPI(unittest.TestCase):
def test_question_answering(self):
model_type = "question-answering"
interface_info = gr.external.get_huggingface_interface(
"deepset/roberta-base-squad2", api_key=None, alias=model_type
"lysandre/tiny-vit-random", api_key=None, alias=model_type
)
self.assertEqual(interface_info["fn"].__name__, model_type)
self.assertIsInstance(interface_info["inputs"][0], gr.inputs.Textbox)
self.assertIsInstance(interface_info["inputs"][1], gr.inputs.Textbox)
self.assertIsInstance(interface_info["outputs"][0], gr.outputs.Textbox)
self.assertIsInstance(interface_info["outputs"][1], gr.outputs.Label)
self.assertIsInstance(interface_info["inputs"], gr.inputs.Image)
self.assertIsInstance(interface_info["outputs"], gr.outputs.Label)
def test_text_generation(self):
model_type = "text_generation"

View File

@ -49,11 +49,11 @@ class TestInterface(unittest.TestCase):
Interface(lambda x: x, examples=1234)
def test_examples_valid_path(self):
path = os.path.join(os.path.dirname(__file__), "test_data/flagged_with_log")
path = os.path.join(os.path.dirname(__file__), "../test_data/flagged_with_log")
interface = Interface(lambda x: 3 * x, "number", "number", examples=path)
self.assertEqual(len(interface.get_config_file()["examples"]), 2)
path = os.path.join(os.path.dirname(__file__), "test_data/flagged_no_log")
path = os.path.join(os.path.dirname(__file__), "../test_data/flagged_no_log")
interface = Interface(lambda x: 3 * x, "number", "number", examples=path)
self.assertEqual(len(interface.get_config_file()["examples"]), 3)

0
test/local/__init__.py Normal file
View File