diff --git a/jina/helloworld/__init__.py b/jina/helloworld/__init__.py index 40197d983d909..c0114471ab4ca 100644 --- a/jina/helloworld/__init__.py +++ b/jina/helloworld/__init__.py @@ -34,26 +34,36 @@ def hello_world(args): } } + # download the data download_data(targets) + # this envs are referred in index and query flow YAMLs os.environ['RESOURCE_DIR'] = resource_filename('jina', 'resources') os.environ['SHARDS'] = str(args.shards) os.environ['REPLICAS'] = str(args.replicas) os.environ['HW_WORKDIR'] = args.workdir os.environ['WITH_LOGSERVER'] = str(args.logserver) + + # reduce the network load by using `fp16`, or even `uint8` os.environ['JINA_ARRAY_QUANT'] = 'fp16' + # now comes the real work + # load index flow from a YAML file f = Flow.load_config(args.index_yaml_path) + # run it! with f: f.index(input_fn(targets['index']['filename']), batch_size=args.index_batch_size) + # wait for couple of seconds countdown(8, reason=colored('behold! im going to switch to query mode', 'cyan', attrs=['underline', 'bold', 'reverse'])) + # now load query flow from another YAML file f = Flow.load_config(args.query_yaml_path) + # run it! with f: f.search(input_fn(targets['query']['filename'], index=False, num_doc=args.num_query), output_fn=print_result, top_k=args.top_k, batch_size=args.query_batch_size) - html_path = os.path.join(args.workdir, 'hello-world.html') - write_html(html_path) + # write result to html + write_html(os.path.join(args.workdir, 'hello-world.html'))