Exemplo n.º 1
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())
    ]))
Exemplo n.º 2
0
                  download_proxy=None,
                  task_name='download fashion-mnist'):
    """
    Download data.

    :param targets: target path for data.
    :param download_proxy: download proxy (e.g. 'http', 'https')
    :param task_name: name of the task
    """
    opener = urllib.request.build_opener()
    opener.addheaders = [('User-agent', 'Mozilla/5.0')]
    if download_proxy:
        proxy = urllib.request.ProxyHandler({
            'http': download_proxy,
            'https': download_proxy
        })
        opener.add_handler(proxy)
    urllib.request.install_opener(opener)
    with ProgressBar(description=task_name) as t:
        for k, v in targets.items():
            if not os.path.exists(v['filename']):
                urllib.request.urlretrieve(
                    v['url'],
                    v['filename'],
                    reporthook=lambda *x: t.update(0.01))


if __name__ == '__main__':
    args = set_hw_multimodal_parser().parse_args()
    hello_world(args)