Esempio n. 1
0
def test_fashion(helloworld_args, query_document, mocker):
    """Regression test for fashion example."""
    def validate_response(resp):
        assert len(resp.search.docs) == 1
        for doc in resp.search.docs:
            assert len(doc.matches) == 10

    hello_world(helloworld_args)
    flow_query_path = os.path.join(resource_filename('jina', 'resources'),
                                   'fashion')

    mock_on_done = mocker.Mock()
    mock_on_fail = mocker.Mock()

    with Flow.load_config(
            os.path.join(flow_query_path, 'helloworld.flow.query.yml')) as f:
        f.search(
            inputs=[query_document],
            on_done=mock_on_done,
            on_fail=mock_on_fail,
            top_k=10,
        )

    mock_on_fail.assert_not_called()
    validate_callback(mock_on_done, validate_response)
Esempio n. 2
0
def test_helloworld_py_multimodal(tmpdir):
    from jina.helloworld.multimodal import hello_world
    hello_world(set_hw_multimodal_parser().parse_args([
        '--workdir',
        str(tmpdir), '--unblock-query-flow', '--port-expose',
        str(random_port())
    ]))
Esempio n. 3
0
def hello_world(args: 'Namespace'):
    """
    Run the fashion hello world example

    :param args: arguments coming from the CLI.
    """
    from jina.helloworld.fashion import hello_world

    hello_world(args)
Esempio n. 4
0
def test_helloworld_py_chatbot(tmpdir):
    from jina.helloworld.chatbot import hello_world

    hello_world(set_hw_chatbot_parser().parse_args([
        '--workdir',
        str(tmpdir),
        '--unblock-query-flow',
        '--port-expose',
        str(helper.random_port()),
    ]))
Esempio n. 5
0
def hello(args: 'Namespace'):
    if args.hello == 'fashion':
        from jina.helloworld.fashion import hello_world
    elif args.hello == 'chatbot':
        from jina.helloworld.chatbot import hello_world
    elif args.hello == 'multimodal':
        from jina.helloworld.multimodal import hello_world
    else:
        raise ValueError(f'must be one of [`fashion`, `chatbot`, `multimodal`]')

    hello_world(args)
Esempio n. 6
0
def hello(args: 'Namespace'):
    """
    Run any of the hello world examples

    :param args: arguments coming from the CLI.
    """
    if args.hello == 'fashion':
        from jina.helloworld.fashion import hello_world
    elif args.hello == 'chatbot':
        from jina.helloworld.chatbot import hello_world
    elif args.hello == 'multimodal':
        from jina.helloworld.multimodal import hello_world
    else:
        raise ValueError(
            f'must be one of [`fashion`, `chatbot`, `multimodal`]')

    hello_world(args)
Esempio n. 7
0
File: api.py Progetto: yuanl/jina
def hello_world(args: 'Namespace'):
    from jina.helloworld.fashion import hello_world
    hello_world(args)
Esempio n. 8
0
def test_helloworld_py(tmpdir):
    from jina.helloworld.fashion import hello_world
    hello_world(set_hw_parser().parse_args(['--workdir', str(tmpdir)]))
    check_hello_world_results(os.path.join(str(tmpdir), 'hello-world.html'))