oscarwang2 commited on
Commit
99c33e4
1 Parent(s): d18467f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -42,6 +42,7 @@ def handle_upload():
42
 
43
  # Create a temporary directory to store uploaded files
44
  temp_dir = tempfile.mkdtemp()
 
45
 
46
  # Save the uploaded files to the temporary directory
47
  folder_path = os.path.join(temp_dir, 'uploaded_folder')
@@ -49,11 +50,13 @@ def handle_upload():
49
  for file_obj in files:
50
  file_path = os.path.join(folder_path, file_obj.filename)
51
  file_obj.save(file_path)
 
52
 
53
  # Save the script content to a file
54
  script_path = os.path.join(folder_path, 'user_script.py')
55
  with open(script_path, 'w') as script_file:
56
  script_file.write(script_content)
 
57
 
58
  # Run the script using MPI
59
  log_output = run_script_with_mpi(script_path, folder_path)
@@ -64,6 +67,7 @@ def handle_upload():
64
  for root, _, files in os.walk(folder_path):
65
  for file in files:
66
  zipf.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), folder_path))
 
67
 
68
  return jsonify({"status": "success", "log_output": log_output, "download_url": f"/download/{os.path.basename(zip_path)}"})
69
 
 
42
 
43
  # Create a temporary directory to store uploaded files
44
  temp_dir = tempfile.mkdtemp()
45
+ logger.info(f"Temporary directory created at {temp_dir}")
46
 
47
  # Save the uploaded files to the temporary directory
48
  folder_path = os.path.join(temp_dir, 'uploaded_folder')
 
50
  for file_obj in files:
51
  file_path = os.path.join(folder_path, file_obj.filename)
52
  file_obj.save(file_path)
53
+ logger.info(f"File saved to {file_path}")
54
 
55
  # Save the script content to a file
56
  script_path = os.path.join(folder_path, 'user_script.py')
57
  with open(script_path, 'w') as script_file:
58
  script_file.write(script_content)
59
+ logger.info(f"Script content saved to {script_path}")
60
 
61
  # Run the script using MPI
62
  log_output = run_script_with_mpi(script_path, folder_path)
 
67
  for root, _, files in os.walk(folder_path):
68
  for file in files:
69
  zipf.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), folder_path))
70
+ logger.info(f"Output folder zipped at {zip_path}")
71
 
72
  return jsonify({"status": "success", "log_output": log_output, "download_url": f"/download/{os.path.basename(zip_path)}"})
73