def test_run_command_with_input_file(bento_archive_path): input_path = generate_test_input_file() runner = CliRunner() cli = create_bento_service_cli() run_cmd = cli.commands["<API_NAME>"] result = runner.invoke( run_cmd, ["predict", bento_archive_path, "--input", input_path, "-o", "json"]) assert result.exit_code == 0 result_json = json.loads(result.output) assert result_json[0]["age"] == 6
def test_gunicorn_serve_command(): runner = CliRunner() cli = create_bento_service_cli() gunicorn_cmd = cli.commands["serve-gunicorn"] with mock.patch('bentoml.server.gunicorn_server.GunicornBentoServer', ) as mocked_class: runner.invoke( gunicorn_cmd, ["/"], ) instance = mocked_class.return_value assert instance.run.called
def test_run_command_with_input_file(bento_bundle_path): input_path = generate_test_input_file() runner = CliRunner() cli = create_bento_service_cli() run_cmd = cli.commands["<API_NAME>"] result = runner.invoke( run_cmd, [ "predict_dataframe", bento_bundle_path, "--input", input_path, "-o", "json" ], ) assert result.exit_code == 0 assert result.output.strip() == '"3"'
import os import sys import logging from bentoml import saved_bundle, configure_logging from bentoml.cli import create_bento_service_cli # By default, ignore warnings when loading BentoService installed as PyPI distribution # CLI will change back to default log level in config(info), and by adding --quiet or # --verbose CLI option, user can change the CLI output behavior configure_logging(logging.ERROR) __VERSION__ = "20200727163421_432B4B" __module_path = os.path.abspath(os.path.dirname(__file__)) IrisClassifier = saved_bundle.load_bento_service_class(__module_path) cli=create_bento_service_cli(__module_path) def load(): return saved_bundle.load(__module_path) __all__ = ['__version__', 'IrisClassifier', 'load']