akiko19191 commited on
Commit
024a8ef
·
verified ·
1 Parent(s): 93e7067

Update tests.py

Browse files
Files changed (1) hide show
  1. tests.py +15 -5
tests.py CHANGED
@@ -208,12 +208,23 @@ def create_code_files(filename: str, code: str) -> dict:
208
  f.write(code)
209
  f.close()
210
  return {"info":"task completed. The referenced code files were created successfully. "}
211
-
212
  @mcp.tool()
213
  def run_code(python_packages:str,filename: str, code: str,start_cmd:str) -> dict:
214
- """python_packages:python_packages to install seperated by space.eg-(python packages:numpy matplotlib).The following python packages are preinstalled:gradio XlsxWriter openpyxl
215
- filename,code:Create code files by passing the the filename as well the entire code to write.The file is created by default in the /app/code_interpreter directory.Note:All user uploaded files that you might need to work upon are stored in the /app/code_interpreter directory.
216
- start_cmd:Example- python /app/code_interpreter/app.py or bash /app/code_interpreter/app.py.The files must be inside the /app/code_interpreter directory.
 
 
 
 
 
 
 
 
 
 
 
217
  """
218
 
219
  global files_list
@@ -236,7 +247,6 @@ def run_code(python_packages:str,filename: str, code: str,start_cmd:str) -> dict
236
  run(start_cmd, 300)
237
  while stderr=="" and stdout=="":
238
  pass
239
- time.sleep(1.5)
240
  onlyfiles = glob.glob("/app/code_interpreter/*")
241
  onlyfiles=list(set(onlyfiles)-set(files_list))
242
  uploaded_filenames=[]
 
208
  f.write(code)
209
  f.close()
210
  return {"info":"task completed. The referenced code files were created successfully. "}
211
+
212
  @mcp.tool()
213
  def run_code(python_packages:str,filename: str, code: str,start_cmd:str) -> dict:
214
+ """
215
+ Execute Python code in a controlled environment with package installation and file handling.
216
+
217
+ Args:
218
+ python_packages: Space-separated list of packages to install (e.g., "numpy matplotlib").
219
+ Preinstalled packages: gradio, XlsxWriter, openpyxl.
220
+ filename: Name of the file to create (stored in /app/code_interpreter/).
221
+ code: Full Python code to write to the file.
222
+ start_cmd: Command to execute the file (e.g., "python /app/code_interpreter/app.py"
223
+ or "bash /app/code_interpreter/app.py").
224
+
225
+ Notes:
226
+ - All user-uploaded files are in /app/code_interpreter/.
227
+ - After execution, embed a download link (or display images/gifs/videos directly in markdown format) in your response.
228
  """
229
 
230
  global files_list
 
247
  run(start_cmd, 300)
248
  while stderr=="" and stdout=="":
249
  pass
 
250
  onlyfiles = glob.glob("/app/code_interpreter/*")
251
  onlyfiles=list(set(onlyfiles)-set(files_list))
252
  uploaded_filenames=[]