| #!/usr/bin/env python | |
| """Launch Modal pipeline — writes output to file, avoids Windows console encoding issues.""" | |
| import subprocess, sys, os, io | |
| os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| # Force UTF-8 encoding for the Modal CLI subprocess | |
| env = os.environ.copy() | |
| env["PYTHONIOENCODING"] = "utf-8" | |
| env["PYTHONUTF8"] = "1" | |
| print("Launching DiffusionGemma Humanizer on Modal (A100 80GB)...", flush=True) | |
| result = subprocess.run( | |
| ["modal", "run", "modal_project/app.py::run_full_pipeline"], | |
| stdout=subprocess.PIPE, | |
| stderr=subprocess.STDOUT, | |
| encoding="utf-8", | |
| errors="replace", | |
| env=env, | |
| ) | |
| # Write to UTF-8 file (avoids console encoding issues) | |
| log_path = "C:/Users/yoann/AppData/Local/Temp/modal_output.txt" | |
| with open(log_path, "w", encoding="utf-8") as f: | |
| f.write(result.stdout) | |
| # Print sanitized summary to console | |
| lines = result.stdout.split("\n") | |
| for line in lines: | |
| # Sanitize: keep only ASCII-safe chars for console | |
| safe = line.encode("ascii", errors="replace").decode("ascii") | |
| print(safe) | |
| print(f"\nExit code: {result.returncode}") | |
| print(f"Full log: {log_path}") | |
| sys.exit(result.returncode) | |