yifan0sun commited on
Commit
7452296
Β·
1 Parent(s): 002c53a

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +24 -1
server.py CHANGED
@@ -91,7 +91,8 @@ def print_directory_tree(path):
91
  print(f"{indent}πŸ“ {os.path.basename(root)}/")
92
  for f in files:
93
  print(f"{indent} πŸ“„ {f}")
94
- @app.get("/copy_and_extract")
 
95
  def copy_zip_extract_and_report():
96
  src_base = "./hf_cache"
97
  dst_base = "/data/hf_cache"
@@ -132,8 +133,30 @@ def copy_zip_extract_and_report():
132
 
133
 
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
 
136
 
 
 
 
 
 
 
 
 
137
  @app.post("/load_model")
138
  def load_model(req: LoadModelRequest):
139
  print(f"\n--- /load_model request received ---")
 
91
  print(f"{indent}πŸ“ {os.path.basename(root)}/")
92
  for f in files:
93
  print(f"{indent} πŸ“„ {f}")
94
+
95
+
96
  def copy_zip_extract_and_report():
97
  src_base = "./hf_cache"
98
  dst_base = "/data/hf_cache"
 
133
 
134
 
135
 
136
+ @app.get("/copy_and_extract")
137
+ def copy_and_extract():
138
+ import io
139
+ from contextlib import redirect_stdout
140
+
141
+ f = io.StringIO()
142
+ with redirect_stdout(f):
143
+ copy_zip_extract_and_report()
144
+ output = f.getvalue()
145
+ return {"message": "done", "log": output}
146
+
147
+
148
+
149
+
150
 
151
 
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
  @app.post("/load_model")
161
  def load_model(req: LoadModelRequest):
162
  print(f"\n--- /load_model request received ---")