hvoss-techfak commited on
Commit
d3ab058
·
1 Parent(s): ae7902f

fix logging

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -8,7 +8,7 @@ from sentry_sdk import capture_exception, push_scope, capture_message
8
  from sentry_sdk.integrations.logging import LoggingIntegration
9
  from sentry_sdk.integrations.starlette import StarletteIntegration
10
  from sentry_sdk.integrations.fastapi import FastApiIntegration
11
- import spaces
12
  dsn = os.getenv("SENTRY_DSN")
13
  if not dsn:
14
  print("WARNING: SENTRY_DSN not set – Sentry disabled")
@@ -310,7 +310,7 @@ if os.path.exists(DEFAULT_MATERIALS_CSV):
310
  else:
311
  initial_df.to_csv(DEFAULT_MATERIALS_CSV, index=False)
312
 
313
- @spaces.GPU(duration=90) # GPU reserved only for this call
314
  def run_autoforge_process(cmd, log_path):
315
  """
316
  Launch the external `autoforge` CLI.
@@ -567,7 +567,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
567
  )
568
  gr.Markdown(
569
  'Please note that huggingface enforces a maximum execution time of one minute. Depending on your configuration (especially iteration count) it is possible to exceed this time limit. In that case you will see a "GPU Task aborted" error.'
570
- 'If you need more time, take a look at the [Autoforge Github Page](https://github.com/hvoss-techfak/AutoForge) to see how you can run the program locally, or pull the docker container for this project (upper right corner -> three dots -> "run locally")'
571
  )
572
 
573
  with gr.Row():
@@ -836,7 +836,17 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
836
  worker.join() # make sure it’s done
837
  return_code = worker.returncode
838
 
 
 
 
 
 
 
 
 
 
839
  if return_code != 0:
 
840
  err = RuntimeError(f"Autoforge exited with code {return_code} \n {log_output}")
841
  capture_exception(err) # send to Sentry
842
  raise err # also fail the Gradio call
@@ -847,6 +857,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
847
  )
848
  log_str = " ".join(log_output)
849
 
 
 
850
  files_to_offer = [
851
  p
852
  for p in [
 
8
  from sentry_sdk.integrations.logging import LoggingIntegration
9
  from sentry_sdk.integrations.starlette import StarletteIntegration
10
  from sentry_sdk.integrations.fastapi import FastApiIntegration
11
+ #import spaces
12
  dsn = os.getenv("SENTRY_DSN")
13
  if not dsn:
14
  print("WARNING: SENTRY_DSN not set – Sentry disabled")
 
310
  else:
311
  initial_df.to_csv(DEFAULT_MATERIALS_CSV, index=False)
312
 
313
+ #@spaces.GPU(duration=90) # GPU reserved only for this call
314
  def run_autoforge_process(cmd, log_path):
315
  """
316
  Launch the external `autoforge` CLI.
 
567
  )
568
  gr.Markdown(
569
  'Please note that huggingface enforces a maximum execution time of one minute. Depending on your configuration (especially iteration count) it is possible to exceed this time limit. In that case you will see a "GPU Task aborted" error.'
570
+ ' If you need more time, take a look at the [Autoforge Github Page](https://github.com/hvoss-techfak/AutoForge) to see how you can run the program locally, or pull the docker container for this project (upper right corner -> three dots -> "run locally")'
571
  )
572
 
573
  with gr.Row():
 
836
  worker.join() # make sure it’s done
837
  return_code = worker.returncode
838
 
839
+ try:
840
+ sentry_sdk.add_attachment(
841
+ path=log_file,
842
+ filename="autoforge.log",
843
+ content_type="text/plain",
844
+ )
845
+ except Exception as e:
846
+ capture_exception(e)
847
+
848
  if return_code != 0:
849
+
850
  err = RuntimeError(f"Autoforge exited with code {return_code} \n {log_output}")
851
  capture_exception(err) # send to Sentry
852
  raise err # also fail the Gradio call
 
857
  )
858
  log_str = " ".join(log_output)
859
 
860
+
861
+
862
  files_to_offer = [
863
  p
864
  for p in [