Spaces:
Running
on
L40S
Running
on
L40S
miaoyibo
commited on
Commit
·
49e9feb
1
Parent(s):
ad1769a
- app.py +5 -5
- kimi_dev/serve/templates.py +46 -17
app.py
CHANGED
@@ -332,11 +332,11 @@ def main(args: argparse.Namespace):
|
|
332 |
)
|
333 |
|
334 |
if __name__ == "__main__":
|
335 |
-
print("Start serving vllm...")
|
336 |
-
script_path = os.path.join(os.path.dirname(__file__), "serve_vllm.sh")
|
337 |
-
subprocess.Popen(["bash", script_path])
|
338 |
-
time.sleep(450)
|
339 |
-
print("Served vllm!")
|
340 |
|
341 |
|
342 |
args = parse_args()
|
|
|
332 |
)
|
333 |
|
334 |
if __name__ == "__main__":
|
335 |
+
# print("Start serving vllm...")
|
336 |
+
# script_path = os.path.join(os.path.dirname(__file__), "serve_vllm.sh")
|
337 |
+
# subprocess.Popen(["bash", script_path])
|
338 |
+
# time.sleep(450)
|
339 |
+
# print("Served vllm!")
|
340 |
|
341 |
|
342 |
args = parse_args()
|
kimi_dev/serve/templates.py
CHANGED
@@ -119,15 +119,15 @@ def create_structure(directory_path):
|
|
119 |
"""
|
120 |
structure = {}
|
121 |
for root, _, files in os.walk(directory_path):
|
|
|
122 |
relative_root = os.path.relpath(root, directory_path)
|
123 |
if relative_root == ".":
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
curr_struct = curr_struct[part]
|
131 |
for file_name in files:
|
132 |
if file_name.endswith(".py"):
|
133 |
file_path = os.path.join(root, file_name)
|
@@ -138,18 +138,47 @@ def create_structure(directory_path):
|
|
138 |
"text": file_lines,
|
139 |
}
|
140 |
else:
|
141 |
-
|
142 |
-
try:
|
143 |
-
with open(file_path, 'r', encoding='utf-8') as f:
|
144 |
-
file_content = f.read()
|
145 |
-
curr_struct[file_name] = {
|
146 |
-
"text": file_content.splitlines()
|
147 |
-
}
|
148 |
-
except Exception as e:
|
149 |
-
print(f"fail to read {file_path}: {e}")
|
150 |
-
curr_struct[file_name] = {}
|
151 |
return structure
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
def build_repo_structure(root_path):
|
154 |
"""Build repository structure using improved parsing method"""
|
155 |
return create_structure(root_path)
|
|
|
119 |
"""
|
120 |
structure = {}
|
121 |
for root, _, files in os.walk(directory_path):
|
122 |
+
repo_name = os.path.basename(directory_path)
|
123 |
relative_root = os.path.relpath(root, directory_path)
|
124 |
if relative_root == ".":
|
125 |
+
relative_root = repo_name
|
126 |
+
curr_struct = structure
|
127 |
+
for part in relative_root.split(os.sep):
|
128 |
+
if part not in curr_struct:
|
129 |
+
curr_struct[part] = {}
|
130 |
+
curr_struct = curr_struct[part]
|
|
|
131 |
for file_name in files:
|
132 |
if file_name.endswith(".py"):
|
133 |
file_path = os.path.join(root, file_name)
|
|
|
138 |
"text": file_lines,
|
139 |
}
|
140 |
else:
|
141 |
+
curr_struct[file_name] = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
return structure
|
143 |
|
144 |
+
# def create_structure(directory_path):
|
145 |
+
# """Create the structure of the repository directory by parsing Python files.
|
146 |
+
# :param directory_path: Path to the repository directory.
|
147 |
+
# :return: A dictionary representing the structure.
|
148 |
+
# """
|
149 |
+
# structure = {}
|
150 |
+
# for root, _, files in os.walk(directory_path):
|
151 |
+
# relative_root = os.path.relpath(root, directory_path)
|
152 |
+
# if relative_root == ".":
|
153 |
+
# curr_struct = structure
|
154 |
+
# else:
|
155 |
+
# curr_struct = structure
|
156 |
+
# for part in relative_root.split(os.sep):
|
157 |
+
# if part not in curr_struct:
|
158 |
+
# curr_struct[part] = {}
|
159 |
+
# curr_struct = curr_struct[part]
|
160 |
+
# for file_name in files:
|
161 |
+
# if file_name.endswith(".py"):
|
162 |
+
# file_path = os.path.join(root, file_name)
|
163 |
+
# class_info, function_names, file_lines = parse_python_file(file_path)
|
164 |
+
# curr_struct[file_name] = {
|
165 |
+
# "classes": class_info,
|
166 |
+
# "functions": function_names,
|
167 |
+
# "text": file_lines,
|
168 |
+
# }
|
169 |
+
# else:
|
170 |
+
# file_path = os.path.join(root, file_name)
|
171 |
+
# try:
|
172 |
+
# with open(file_path, 'r', encoding='utf-8') as f:
|
173 |
+
# file_content = f.read()
|
174 |
+
# curr_struct[file_name] = {
|
175 |
+
# "text": file_content.splitlines()
|
176 |
+
# }
|
177 |
+
# except Exception as e:
|
178 |
+
# print(f"fail to read {file_path}: {e}")
|
179 |
+
# curr_struct[file_name] = {}
|
180 |
+
# return structure
|
181 |
+
|
182 |
def build_repo_structure(root_path):
|
183 |
"""Build repository structure using improved parsing method"""
|
184 |
return create_structure(root_path)
|