simonlesaumon commited on
Commit
3fbcbf8
·
verified ·
1 Parent(s): ad0587c

Upload scripts/launch.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/launch.py +37 -0
scripts/launch.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """Launch Modal pipeline — writes output to file, avoids Windows console encoding issues."""
3
+ import subprocess, sys, os, io
4
+
5
+ os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
6
+
7
+ # Force UTF-8 encoding for the Modal CLI subprocess
8
+ env = os.environ.copy()
9
+ env["PYTHONIOENCODING"] = "utf-8"
10
+ env["PYTHONUTF8"] = "1"
11
+
12
+ print("Launching DiffusionGemma Humanizer on Modal (A100 80GB)...", flush=True)
13
+
14
+ result = subprocess.run(
15
+ ["modal", "run", "modal_project/app.py::run_full_pipeline"],
16
+ stdout=subprocess.PIPE,
17
+ stderr=subprocess.STDOUT,
18
+ encoding="utf-8",
19
+ errors="replace",
20
+ env=env,
21
+ )
22
+
23
+ # Write to UTF-8 file (avoids console encoding issues)
24
+ log_path = "C:/Users/yoann/AppData/Local/Temp/modal_output.txt"
25
+ with open(log_path, "w", encoding="utf-8") as f:
26
+ f.write(result.stdout)
27
+
28
+ # Print sanitized summary to console
29
+ lines = result.stdout.split("\n")
30
+ for line in lines:
31
+ # Sanitize: keep only ASCII-safe chars for console
32
+ safe = line.encode("ascii", errors="replace").decode("ascii")
33
+ print(safe)
34
+
35
+ print(f"\nExit code: {result.returncode}")
36
+ print(f"Full log: {log_path}")
37
+ sys.exit(result.returncode)