Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -334,28 +334,24 @@ if os.path.exists(DEFAULT_MATERIALS_CSV):
|
|
334 |
else:
|
335 |
initial_df.to_csv(DEFAULT_MATERIALS_CSV, index=False)
|
336 |
|
337 |
-
@spaces.GPU(duration=90)
|
338 |
def run_autoforge_process(cmd, log_path):
|
339 |
-
"""
|
340 |
-
Launch the external `autoforge` CLI.
|
341 |
-
All stdout/stderr lines are appended (line-buffered) to *log_path*.
|
342 |
-
Returns the CLI's exit-code.
|
343 |
-
"""
|
344 |
_check_quota(90)
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
return
|
359 |
|
360 |
|
361 |
# Helper for creating an empty 10-tuple for error returns
|
|
|
334 |
else:
|
335 |
initial_df.to_csv(DEFAULT_MATERIALS_CSV, index=False)
|
336 |
|
337 |
+
@spaces.GPU(duration=90)
|
338 |
def run_autoforge_process(cmd, log_path):
|
339 |
+
"""Run AutoForge in-process and stream its console output to *log_path*."""
|
|
|
|
|
|
|
|
|
340 |
_check_quota(90)
|
341 |
+
|
342 |
+
cli_args = cmd[1:] # skip the literal "autoforge"
|
343 |
+
autoforge_main = importlib.import_module("autoforge.__main__")
|
344 |
+
|
345 |
+
exit_code = 0
|
346 |
+
with open(log_path, "w", buffering=1, encoding="utf-8") as log_f, \
|
347 |
+
redirect_stdout(log_f), redirect_stderr(log_f):
|
348 |
+
try:
|
349 |
+
sys.argv = ["autoforge"] + cli_args
|
350 |
+
autoforge_main.main() # runs until completion
|
351 |
+
except SystemExit as e: # AutoForge calls sys.exit()
|
352 |
+
exit_code = e.code
|
353 |
+
|
354 |
+
return exit_code
|
355 |
|
356 |
|
357 |
# Helper for creating an empty 10-tuple for error returns
|