Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.

Commit 9abedf6

Browse files
committed
fix(backend): num_docs
1 parent 19b0e49 commit 9abedf6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

backend/app.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def trim_string(
4646
return trimmed_string
4747

4848

49-
def prep_docs(input_file: str, max_docs:int=max_docs):
49+
def prep_docs(input_file: str, num_docs:int=max_docs):
5050
"""
5151
Create generator for every row in csv as a Document
5252
:param input_file: Input csv filename
@@ -56,7 +56,7 @@ def prep_docs(input_file: str, max_docs:int=max_docs):
5656
with open(input_file, "r") as csv_file:
5757
csv_reader = csv.DictReader(csv_file)
5858
input_field = "Description"
59-
for row in itertools.islice(csv_reader, max_docs):
59+
for row in itertools.islice(csv_reader, num_docs):
6060
# Fix invalid ratings and counts
6161
if row["Average User Rating"] == "":
6262
row["Average User Rating"] = random.uniform(0.0, 5.0)
@@ -70,7 +70,7 @@ def prep_docs(input_file: str, max_docs:int=max_docs):
7070
yield doc
7171

7272

73-
def index():
73+
def index(num_docs=max_docs):
7474
flow = (
7575
Flow()
7676
# .add(uses='jinahub+docker://TransformerTorchEncoder', pretrained_model_name_or_path="sentence-transformers/msmarco-distilbert-base-v3", name="encoder", max_length=50)
@@ -84,7 +84,7 @@ def index():
8484
with flow:
8585
flow.post(
8686
on="/index",
87-
inputs=prep_docs(input_file=backend_datafile, max_docs=max_docs),
87+
inputs=prep_docs(input_file=backend_datafile, num_docs=num_docs),
8888
request_size=64,
8989
read_mode="r",
9090
)
@@ -131,7 +131,7 @@ def main(task: str, num_docs: int, force: bool):
131131
\n +----------------------------------------------------------------------------------+"
132132
)
133133
sys.exit(1)
134-
index()
134+
index(num_docs=num_docs)
135135
if task == "query_restful":
136136
if not os.path.exists(workspace):
137137
print(

0 commit comments

Comments
 (0)