Example #1
0
def test_helloworld_flow(tmpdir):
    args = set_hw_parser().parse_args([])

    os.environ['RESOURCE_DIR'] = resource_filename('jina', 'resources')
    os.environ['SHARDS'] = str(args.shards)
    os.environ['PARALLEL'] = str(args.parallel)
    os.environ['HW_WORKDIR'] = str(tmpdir)
    os.environ['WITH_LOGSERVER'] = str(args.logserver)

    f = Flow.load_config(
        resource_filename('jina', '/'.join(
            ('resources', 'helloworld.flow.index.yml'))))

    targets = {
        'index': {
            'url': args.index_data_url,
            'filename': os.path.join(tmpdir, 'index-original')
        },
        'query': {
            'url': args.query_data_url,
            'filename': os.path.join(tmpdir, 'query-original')
        }
    }

    # download the data
    Path(tmpdir).mkdir(parents=True, exist_ok=True)
    download_data(targets)

    # run it!
    with f:
        py_client(
            host=f.host,
            port_expose=f.port_expose,
        ).index(input_numpy(targets['index']['data']),
                batch_size=args.index_batch_size)
Example #2
0
def hello_world(args):
    Path(args.workdir).mkdir(parents=True, exist_ok=True)

    targets = {
        'index': {
            'url': args.index_data_url,
            'filename': os.path.join(args.workdir, 'index-original')
        },
        'query': {
            'url': args.query_data_url,
            'filename': os.path.join(args.workdir, 'query-original')
        }
    }

    # download the data
    download_data(targets, args.download_proxy)

    # run it!
    py_client(port_expose=args.port_expose,
              host=args.host).index(input_numpy(targets['index']['data']),
                                    batch_size=args.index_batch_size)
Example #3
0
def test_input_numpy(array):
    PyClient.check_input(input_numpy(array))
Example #4
0
    def test_io_np(self):
        print(type(np.random.random([100, 4])))
        PyClient.check_input(input_numpy(np.random.random([100, 4, 2])))
        PyClient.check_input(['asda', 'dsadas asdasd'])

        print(type(array2pb(np.random.random([100, 4, 2]))))
Example #5
0
 def test_io_np(self):
     PyClient.check_input(input_numpy(np.random.random([100, 4, 2])))
     PyClient.check_input(['asda', 'dsadas asdasd'])