-
Notifications
You must be signed in to change notification settings - Fork 0
/
pytriton_server_prepare.py
29 lines (27 loc) · 1019 Bytes
/
pytriton_server_prepare.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import subprocess
def prepare(message):
#try:
output = "empty"
model_to_run = message["model"]
repo_url = message["model_info"]["repo_url"]
git_lfs_command = "git lfs install"
git_clone_command = f"git clone {repo_url}"
#output = subprocess.check_output(git_lfs_command, shell=True)
#output = subprocess.check_output(git_clone_command, shell=True)
pytriton_file_name = "pytriton_server.py"
pytriton_file = open(pytriton_file_name, "w")
with open ("codegen_pre.txt", "r") as f:
for line in f.readlines():
pytriton_file.write(line)
with open (f"{model_to_run}/interface.txt", "r") as f:
for line in f.readlines():
pytriton_file.write(line)
with open ("codegen_post.txt", "r") as f:
for line in f.readlines():
pytriton_file.write(line)
pytriton_file.close()
return pytriton_file_name
def run_pytriton(pytriton_file_name):
command = f"python {pytriton_file_name}"
os.system(command)