Skip to content

Commit ada478a

Browse files
authored
Refactor llama-deploy sample app (#23)
* chore(samples): format and remove unused imports * fix(samples): remove unused code * refactor(samples): introduce function in tests
1 parent 3142caf commit ada478a

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

samples/llama-deploy/llama-sum/Taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
---
5-
version: "3"
5+
version: '3'
66

77
silent: true
88

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025 Cisco and/or its affiliates.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import json
5-
import os
6-
import sys
7-
import time
84

95
from llama_deploy import ControlPlaneConfig, LlamaDeployClient
106

11-
init_timestamp = time.time()
12-
13-
# points to deployed control plane
14-
client = LlamaDeployClient(ControlPlaneConfig())
15-
16-
session = client.create_session()
17-
result = session.run("sum", max=10)
18-
v = result.split()
19-
# expected string in the form of
20-
# v1 + v2 = v3
21-
# we check it the sum returned is correct
22-
sum = int(v[0]) + int(v[2])
23-
assert v[4] == str(
24-
sum
25-
), f"Got a wrong results. Expected {str(sum)}, received {v[4]}"
26-
print("test succeded")
7+
result = None
8+
9+
10+
def run_test():
11+
# points to deployed control plane
12+
client = LlamaDeployClient(ControlPlaneConfig())
13+
14+
session = client.create_session()
15+
result = session.run("sum", max=10)
16+
v = result.split()
17+
# expected string in the form of
18+
# v1 + v2 = v3
19+
# we check it the sum returned is correct
20+
sum = int(v[0]) + int(v[2])
21+
assert v[4] == str(sum), (
22+
f"Got a wrong results. Expected {str(sum)}, received {v[4]}"
23+
)
24+
print("test succeded")
25+
26+
27+
run_test()

0 commit comments

Comments
 (0)