@@ -48,15 +48,20 @@ async def get_k8s_resource_limits(self) -> Dict[str, Any]:
4848 "cpu_request" : self .settings .K8S_POD_CPU_REQUEST ,
4949 "memory_request" : self .settings .K8S_POD_MEMORY_REQUEST ,
5050 "execution_timeout" : self .settings .K8S_POD_EXECUTION_TIMEOUT ,
51- "supported_python_versions " : self .settings .SUPPORTED_PYTHON_VERSIONS ,
51+ "supported_runtimes " : self .settings .SUPPORTED_RUNTIMES ,
5252 }
5353
5454 async def _start_k8s_execution (
55- self , execution_id_str : str , script : str , python_version : str
55+ self , execution_id_str : str ,
56+ script : str ,
57+ lang : str ,
58+ lang_version : str
5659 ) -> None :
5760 try :
5861 # Python-specific configuration
59- image = f"python:{ python_version } -slim"
62+ image = f"{ lang } :{ lang_version } -slim"
63+
64+ # TODO: decouple from file format smh
6065 command = ["python" , "/scripts/script.py" ]
6166 config_map_data = {
6267 "script.py" : script
@@ -169,36 +174,44 @@ async def _try_finalize_execution(self, execution: ExecutionInDB) -> Optional[Ex
169174 raise IntegrationException (status_code = 500 , detail = "Failed to retrieve execution after update." )
170175
171176 status_label = "success" if updated_execution .status == ExecutionStatus .COMPLETED else "error"
172- SCRIPT_EXECUTIONS .labels (status = status_label , python_version = updated_execution .python_version ).inc ()
177+ SCRIPT_EXECUTIONS .labels (status = status_label ,
178+ lang_and_version = execution .lang + "-" + execution .lang_version ).inc ()
173179 if status_label == "error" :
174180 ERROR_COUNTER .labels (error_type = "ScriptExecutionError" ).inc ()
175181
176182 return updated_execution
177183
178184 async def execute_script (
179- self , script : str , python_version : str = "3.11"
185+ self , script : str ,
186+ lang : str = "python" ,
187+ lang_version : str = "3.11"
180188 ) -> ExecutionInDB :
181189 ACTIVE_EXECUTIONS .inc ()
182190 start_time = time ()
183191 inserted_oid = None
184192
185193 try :
186- if python_version not in self .settings .SUPPORTED_PYTHON_VERSIONS :
187- raise IntegrationException (status_code = 400 , detail = f"Unsupported Python version: { python_version } " )
194+ if lang not in self .settings .SUPPORTED_RUNTIMES .keys ():
195+ raise IntegrationException (status_code = 400 , detail = f"Language '{ lang } ' not supported." )
196+
197+ if lang_version not in self .settings .SUPPORTED_RUNTIMES [lang ]:
198+ raise IntegrationException (status_code = 400 , detail = f"Language version '{ lang_version } ' not supported." )
188199
189200 execution_create = ExecutionCreate (
190201 script = script ,
191- python_version = python_version ,
202+ lang = lang ,
203+ lang_version = lang_version ,
192204 status = ExecutionStatus .QUEUED ,
193205 )
194206 execution_to_insert = ExecutionInDB (** execution_create .model_dump ())
195207 inserted_oid = await self .execution_repo .create_execution (execution_to_insert )
196208 logger .info (f"Created execution record { inserted_oid } with status QUEUED." )
197209
198210 await self ._start_k8s_execution (
199- inserted_oid , script , python_version
211+ execution_id_str = inserted_oid , script = script ,
212+ lang = lang , lang_version = lang_version
200213 )
201- SCRIPT_EXECUTIONS .labels (status = "initiated" , python_version = python_version ).inc ()
214+ SCRIPT_EXECUTIONS .labels (status = "initiated" , lang_and_version = lang + "-" + lang_version ).inc ()
202215 await asyncio .sleep (0.1 )
203216
204217 final_execution_state = await self .execution_repo .get_execution (inserted_oid )
@@ -218,7 +231,7 @@ async def execute_script(
218231 detail = f"Internal server error during script execution request: "
219232 f"{ str (e )} " ) from e
220233 finally :
221- EXECUTION_DURATION .labels (python_version = python_version ).observe (time () - start_time )
234+ EXECUTION_DURATION .labels (lang_and_version = lang + "-" + lang_version ).observe (time () - start_time )
222235 ACTIVE_EXECUTIONS .dec ()
223236
224237 async def get_execution_result (self , execution_id : str ) -> ExecutionInDB :
0 commit comments