Skip to content

Commit

Permalink
Merge pull request #551 from seymourtang/fix-lambda
Browse files Browse the repository at this point in the history
fix: update lambda functions to include unused parameter
  • Loading branch information
plutoless authored Jan 3, 2025
2 parents 6c873a3 + 2ab7e7b commit 95751b3
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def on_start(self, ten_env: TenEnvTester) -> None:
print("send hello_world")
ten_env.send_cmd(
new_cmd,
lambda ten_env, result: self.check_hello(ten_env, result),
lambda ten_env, result, _: self.check_hello(ten_env, result),
)

print("tester on_start_done")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def on_start(self, ten_env: TenEnvTester) -> None:
print("send hello_world")
ten_env.send_cmd(
new_cmd,
lambda ten_env, result: self.check_hello(ten_env, result),
lambda ten_env, result, _: self.check_hello(ten_env, result),
)

print("tester on_start_done")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def on_start(self, ten_env: TenEnvTester) -> None:
print("send hello_world")
ten_env.send_cmd(
new_cmd,
lambda ten_env, result: self.check_hello(ten_env, result),
lambda ten_env, result, _: self.check_hello(ten_env, result),
)

print("tester on_start_done")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def on_start(self, ten_env: TenEnvTester) -> None:
print("send hello_world")
ten_env.send_cmd(
new_cmd,
lambda ten_env, result: self.check_hello(ten_env, result),
lambda ten_env, result,_: self.check_hello(ten_env, result),
)

print("tester on_start_done")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def create_collection(self, ten: TenEnv, collection_name: str, wait: bool):
wait_event = threading.Event()
ten.send_cmd(
cmd_out,
lambda ten, result: wait_event.set(),
lambda ten, result, _: wait_event.set(),
)
if wait:
wait_event.wait()
Expand All @@ -97,7 +97,7 @@ def embedding(self, ten: TenEnv, path: str, texts: List[str]):
cmd_out = Cmd.create("embed_batch")
cmd_out.set_property_from_json("inputs", json.dumps(texts))
ten.send_cmd(
cmd_out, lambda ten, result: self.vector_store(ten, path, texts, result)
cmd_out, lambda ten, result, _: self.vector_store(ten, path, texts, result)
)

def vector_store(self, ten: TenEnv, path: str, texts: List[str], result: CmdResult):
Expand All @@ -114,7 +114,7 @@ def vector_store(self, ten: TenEnv, path: str, texts: List[str], result: CmdResu
content.append({"text": text, "embedding": embedding})
cmd_out.set_property_string("content", json.dumps(content))
# ten.log_info(json.dumps(content))
ten.send_cmd(cmd_out, lambda ten, result: self.file_chunked(ten, path))
ten.send_cmd(cmd_out, lambda ten, result, _: self.file_chunked(ten, path))

def file_chunked(self, ten: TenEnv, path: str):
if path in self.counters and path in self.expected:
Expand All @@ -137,7 +137,7 @@ def file_chunked(self, ten: TenEnv, path: str):
cmd_out.set_property_string("collection", self.new_collection_name)
ten.send_cmd(
cmd_out,
lambda ten, result: ten.log_info("send_cmd done"),
lambda ten, result, _: ten.log_info("send_cmd done"),
)
self.file_chunked_event.set()
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def on_start(self, ten_env: TenEnvTester) -> None:
print("send hello_world")
ten_env.send_cmd(
new_cmd,
lambda ten_env, result: self.check_hello(ten_env, result),
lambda ten_env, result, _: self.check_hello(ten_env, result),
)

print("tester on_start_done")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def do_POST(self):
self.ten.log_info("incoming request %s", input_file)
self.ten.send_cmd(
Cmd.create_from_json(input_file),
lambda ten, result: ten.log_info(
lambda ten, result, _: ten.log_info(
"finish send_cmd from http server %s %s", input_file, result
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def on_cmd(self, ten: TenEnv, cmd: Cmd) -> None:
new_cmd.set_property_from_json(None, cmd_json)
ten.send_cmd(
new_cmd,
lambda ten, result: ten.log_info("send_cmd done"),
lambda ten, result, _: ten.log_info("send_cmd done"),
)

cmd_result = CmdResult.create(StatusCode.OK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _get_query_embedding(self, query: str) -> List[float]:
wait_event = threading.Event()
resp: List[float]

def callback(_, result):
def callback(_, result, __):
nonlocal resp
nonlocal wait_event

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def chat(self, messages: Sequence[ChatMessage], **kwargs: Any) -> ChatResponse:
resp: ChatResponse
wait_event = threading.Event()

def callback(_, result):
def callback(_, result, __):
self.ten.log_debug("LlamaLLM chat callback done")
nonlocal resp
nonlocal wait_event
Expand All @@ -71,7 +71,9 @@ def callback(_, result):
cmd = Cmd.create("call_chat")
cmd.set_property_string("messages", messages_str)
cmd.set_property_bool("stream", False)
self.ten.log_info(f"LlamaLLM chat send_cmd {cmd.get_name()}, messages {messages_str}")
self.ten.log_info(
f"LlamaLLM chat send_cmd {cmd.get_name()}, messages {messages_str}"
)

self.ten.send_cmd(cmd, callback)
wait_event.wait()
Expand Down Expand Up @@ -103,7 +105,7 @@ def gen() -> ChatResponseGen:
delta=delta_text,
)

def callback(_, result):
def callback(_, result, __):
nonlocal cur_tokens
nonlocal resp_queue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _retrieve(self, query_bundle: QueryBundle) -> List[NodeWithScore]:
wait_event = threading.Event()
resp: List[NodeWithScore] = []

def cmd_callback(_, result):
def cmd_callback(_, result, __):
nonlocal resp
nonlocal wait_event
resp = format_node_result(self.ten, result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def on_start(self, ten_env: TenEnvTester) -> None:
print("send hello_world")
ten_env.send_cmd(
new_cmd,
lambda ten_env, result: self.check_hello(ten_env, result),
lambda ten_env, result, _: self.check_hello(ten_env, result),
)

print("tester on_start_done")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def on_cmd(self, ten: TenEnv, cmd: Cmd) -> None:
cmd_out = Cmd.create("flush")
ten.send_cmd(
cmd_out,
lambda ten, result: ten.log_info("send_cmd flush done"),
lambda ten, result, _: ten.log_info("send_cmd flush done"),
)
elif cmd_name == "call_chat":
self.queue.put((cmd, ts))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def on_start(self, ten_env: TenEnvTester) -> None:
print("send hello_world")
ten_env.send_cmd(
new_cmd,
lambda ten_env, result: self.check_hello(ten_env, result),
lambda ten_env, result, _: self.check_hello(ten_env, result),
)

print("tester on_start_done")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def on_start(self, ten_env: TenEnvTester) -> None:
print("send hello_world")
ten_env.send_cmd(
new_cmd,
lambda ten_env, result: self.check_hello(ten_env, result),
lambda ten_env, result, _: self.check_hello(ten_env, result),
)

print("tester on_start_done")
Expand Down

0 comments on commit 95751b3

Please sign in to comment.