Skip to content

Commit f53f23c

Browse files
atrivedi-tsavoritesiAshish Trivedi
andauthored
@FIR-742: Add system-info, txe-restart functionality and cd to right path (#16)
The changes are as follows 1. change directory to right folder before running the commands 2. Add system-info and txe-restart functionlity Co-authored-by: Ashish Trivedi <atrivedi@fpga4.tsavoritesi.net>
1 parent cd734f0 commit f53f23c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tools/flaskIfc/flaskIfc.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
port = '/dev/ttyUSB3'
1313
baudrate = '921600'
14+
exe_path = "/usr/bin/tsi/v0.1.1.tsv31_06_06_2025/bin/"
1415

1516
@app.route('/')
1617
def index():
@@ -49,8 +50,8 @@ def llama_cli_serial_command():
4950
#]
5051
# URL to Test this end point is as follows
5152
# http://10.50.30.167:5001/llama-cli?model=tiny-llama&backend=tSavorite&tokens=5&prompt=Hello+How+are+you
52-
script_path = "/usr/bin/tsi/v0.1.1.tsv31_06_06_2025/bin/run_llama_cli.sh"
53-
command = f"{script_path} \"{prompt}\" {tokens} {model_path} {backend}"
53+
script_path = "./run_llama_cli.sh"
54+
command = f"cd {exe_path}; {script_path} \"{prompt}\" {tokens} {model_path} {backend}"
5455

5556
try:
5657
result = subprocess.run(['python3', 'serial_script.py', port, baudrate, command], capture_output=True, text=True, check=True)
@@ -109,11 +110,17 @@ def upload_file():
109110

110111
@app.route('/restart-txe', methods=['GET'])
111112
def restart_txe_serial_command():
112-
command = f"telnet localhost 8000; close all"
113+
command = f"telnet localhost 8000\r\nclose all\r\n"
113114

114115
try:
115116
result = subprocess.run(['python3', 'serial_script.py', port, baudrate, command], capture_output=True, text=True, check=True)
116-
return result.stdout, 200
117+
time.sleep(5)
118+
command = f"{exe_path}/../install/tsi-start\nyes\n"
119+
try:
120+
result = subprocess.run(['python3', 'serial_script.py', port, baudrate, command], capture_output=True, text=True, check=True)
121+
return result.stdout, 200
122+
except subprocess.CalledProcessError as e:
123+
return f"Error executing script: {e.stderr}", 500
117124
except subprocess.CalledProcessError as e:
118125
return f"Error executing script: {e.stderr}", 500
119126

@@ -140,7 +147,7 @@ def test_serial_command():
140147
@app.route('/system-info', methods=['GET'])
141148
def system_info_serial_command():
142149

143-
command = f"lscpu"
150+
command = f"{exe_path}../install/tsi-version;lscpu"
144151

145152
try:
146153
result = subprocess.run(['python3', 'serial_script.py', port, baudrate, command], capture_output=True, text=True, check=True)
@@ -184,8 +191,8 @@ def submit():
184191
# "--top-p", "1"
185192
#]
186193

187-
script_path = "/usr/bin/tsi/v0.1.1.tsv31_06_06_2025/bin/run_llama_cli.sh"
188-
command = f"{script_path} \"{prompt}\" {tokens} {model_path} {backend}"
194+
script_path = "./run_llama_cli.sh"
195+
command = f"cd {exe_path}; {script_path} \"{prompt}\" {tokens} {model_path} {backend}"
189196

190197

191198
def run_script():

0 commit comments

Comments
 (0)