@@ -25,6 +25,18 @@ async def _set_live_status_async(job_id: str, status: str) -> None:
2525 return
2626
2727
28+ async def _set_status_async (job_id : str , status : str ) -> None :
29+ """Async helper to set the high-level job status."""
30+ try :
31+ job = await Job .get (job_id )
32+ if job is None :
33+ return
34+ await job .update_status (status )
35+ except Exception :
36+ # This helper should never cause the wrapped command to fail.
37+ return
38+
39+
2840def _set_live_status (status : str ) -> None :
2941 """Set live_status on the current remote job, if _TFL_JOB_ID is available."""
3042 job_id = os .environ .get ("_TFL_JOB_ID" )
@@ -47,6 +59,26 @@ def _set_live_status(status: str) -> None:
4759 return
4860
4961
62+ def _set_status (status : str ) -> None :
63+ """Set high-level job status for the current remote job, if _TFL_JOB_ID is available."""
64+ job_id = os .environ .get ("_TFL_JOB_ID" )
65+ if not job_id :
66+ return
67+
68+ try :
69+ asyncio .run (_set_status_async (job_id , status ))
70+ except RuntimeError :
71+ # Fallback in case an event loop already exists.
72+ try :
73+ loop = asyncio .get_event_loop ()
74+ if loop .is_running ():
75+ loop .create_task (_set_status_async (job_id , status ))
76+ else :
77+ loop .run_until_complete (_set_status_async (job_id , status ))
78+ except Exception :
79+ return
80+
81+
5082async def _write_provider_logs_async (job_id : str , logs_text : str ) -> None :
5183 """
5284 Best-effort helper to write combined stdout/stderr logs to the job directory.
@@ -124,6 +156,7 @@ def main(argv: List[str] | None = None) -> int:
124156
125157 # Mark job as started.
126158 _set_live_status ("started" )
159+ _set_status ("RUNNING" )
127160
128161 # Run the original command in the shell so it behaves exactly as submitted.
129162 # Capture stdout/stderr so we can save a copy to provider_logs.txt while still
0 commit comments