1111import requests
1212from IPython .core .interactiveshell import ExecutionInfo , ExecutionResult
1313
14- from .get_webapp_url import get_webapp_url
14+ from .get_webapp_url import get_absolute_userpod_api_url
1515from .logging import LoggerManager
1616
1717
@@ -34,7 +34,7 @@ def __init__(
3434 timeout_seconds: Seconds after which to consider execution stuck (default: 300s = 5min)
3535 enable_auto_interrupt: Whether to automatically interrupt stuck executions (default: False)
3636 """
37- self .logger = LoggerManager .get_logger ("execution_timeout" )
37+ self .logger = LoggerManager () .get_logger ()
3838 self .warning_threshold = warning_threshold_seconds
3939 self .timeout_threshold = timeout_seconds
4040 self .enable_auto_interrupt = enable_auto_interrupt
@@ -152,19 +152,8 @@ def _report_to_webapp(
152152 warning: Whether this is a warning (True) or timeout (False)
153153 """
154154 try :
155- webapp_url = get_webapp_url ()
156- project_id = os .getenv ("DEEPNOTE_PROJECT_ID" )
157-
158- if not webapp_url or not project_id :
159- self .logger .debug (
160- "Webapp URL or project ID not available, skipping report"
161- )
162- return
163-
164- endpoint = (
165- "warning" if warning else "timeout"
166- )
167- url = f"{ webapp_url } /userpod-api/{ project_id } /execution/{ endpoint } "
155+ endpoint = "warning" if warning else "timeout"
156+ url = get_absolute_userpod_api_url (f"execution/{ endpoint } " )
168157
169158 payload = {
170159 "duration" : duration ,
@@ -209,7 +198,7 @@ def setup_execution_timeout_monitor(
209198
210199 ip = get_ipython ()
211200 if ip is None :
212- LoggerManager .get_logger ("execution_timeout" ).warning (
201+ LoggerManager () .get_logger ().warning (
213202 "IPython instance not available, skipping timeout monitor setup"
214203 )
215204 return
@@ -224,14 +213,14 @@ def setup_execution_timeout_monitor(
224213 ip .events .register ("pre_execute" , _timeout_monitor .on_pre_execute )
225214 ip .events .register ("post_execute" , _timeout_monitor .on_post_execute )
226215
227- LoggerManager .get_logger ("execution_timeout" ).info (
216+ LoggerManager () .get_logger ().info (
228217 "Execution timeout monitor initialized: warning=%ds, timeout=%ds, auto_interrupt=%s" ,
229218 warning_threshold_seconds ,
230219 timeout_seconds ,
231220 enable_auto_interrupt ,
232221 )
233222
234223 except Exception as e : # pylint: disable=broad-exception-caught
235- LoggerManager .get_logger ("execution_timeout" ).error (
224+ LoggerManager () .get_logger ().error (
236225 "Failed to set up timeout monitor: %s" , e
237226 )
0 commit comments