@@ -179,6 +179,13 @@ async def send_shutdown_request_to_matlab(self):
179179 )
180180
181181 async def send_interrupt_request_to_matlab (self ):
182+ """Send an interrupt request to MATLAB to stop current execution.
183+
184+ The interrupt request is sent through the control channel using a specific message format.
185+
186+ Raises:
187+ HTTPError: If the interrupt request fails or matlab-proxy communication errors occur
188+ """
182189 self .logger .debug ("Sending interrupt request to MATLAB" )
183190 req_body = {
184191 "messages" : {
@@ -201,6 +208,24 @@ async def send_interrupt_request_to_matlab(self):
201208 resp .raise_for_status ()
202209
203210 async def _send_feval_request_to_matlab (self , http_client , fname , nargout , * args ):
211+ """Execute a MATLAB function call (feval) through the matlab-proxy.
212+
213+ Sends a function evaluation request to MATLAB, handling path setup and synchronous execution.
214+
215+ Args:
216+ http_client (aiohttp.ClientSession): HTTP client for sending the request
217+ fname (str): Name of the MATLAB function to call
218+ nargout (int): Number of output arguments expected
219+ *args: Variable arguments to pass to the MATLAB function
220+
221+ Returns:
222+ list: Results from the MATLAB function execution if successful
223+ Empty list if no outputs or nargout=0
224+
225+ Raises:
226+ MATLABConnectionError: If MATLAB connection is lost or response is invalid
227+ Exception: If function execution fails or is interrupted by user
228+ """
204229 self .logger .debug ("Sending FEval request to MATLAB" )
205230 # Add the MATLAB code shipped with kernel to the Path
206231 path = [str (pathlib .Path (__file__ ).parent / "matlab" )]
@@ -265,9 +290,35 @@ async def _send_feval_request_to_matlab(self, http_client, fname, nargout, *args
265290 raise resp .raise_for_status ()
266291
267292 async def send_eval_request_to_matlab (self , mcode ):
293+ """Send an evaluation request to MATLAB using the shell client.
294+
295+ Args:
296+ mcode (str): MATLAB code to be evaluated
297+
298+ Returns:
299+ dict: The evaluation response from MATLAB containing results or error information
300+
301+ Raises:
302+ MATLABConnectionError: If MATLAB connection is not available
303+ HTTPError: If there is an error in communication with matlab-proxy
304+ """
268305 return await self ._send_eval_request_to_matlab (self ._http_shell_client , mcode )
269306
270307 async def _send_eval_request_to_matlab (self , http_client , mcode ):
308+ """Internal method to send and process an evaluation request to MATLAB.
309+
310+ Args:
311+ http_client (aiohttp.ClientSession): HTTP client to use for the request
312+ mcode (str): MATLAB code to be evaluated
313+
314+ Returns:
315+ dict: The evaluation response containing results or error information
316+ from the MATLAB execution
317+
318+ Raises:
319+ MATLABConnectionError: If MATLAB connection is not available or response is invalid
320+ HTTPError: If there is an error in communication with matlab-proxy
321+ """
271322 self .logger .debug ("Sending Eval request to MATLAB" )
272323 # Add the MATLAB code shipped with kernel to the Path
273324 path = str (pathlib .Path (__file__ ).parent / "matlab" )
@@ -307,6 +358,20 @@ async def _send_eval_request_to_matlab(self, http_client, mcode):
307358 raise resp .raise_for_status ()
308359
309360 async def _send_jupyter_request_to_matlab (self , request_type , inputs , http_client ):
361+ """Process and send a Jupyter request to MATLAB using either feval or eval execution.
362+
363+ Args:
364+ request_type (str): Type of request (execute, complete, shutdown)
365+ inputs (list): List of input arguments for the request
366+ http_client (aiohttp.ClientSession): HTTP client to use for the request
367+
368+ Returns:
369+ dict: Response from MATLAB containing results of the request execution
370+
371+ Raises:
372+ MATLABConnectionError: If MATLAB connection is not available
373+ Exception: If request execution fails or is interrupted
374+ """
310375 execution_request_type = "feval"
311376
312377 inputs .insert (0 , request_type )
@@ -347,6 +412,18 @@ async def _send_jupyter_request_to_matlab(self, request_type, inputs, http_clien
347412 return resp
348413
349414 async def _read_eval_response_from_file (self , eval_response ):
415+ """Read and process MATLAB evaluation results from a response file.
416+
417+ Args:
418+ eval_response (dict): Response dictionary from MATLAB eval request containing
419+ file path and error information
420+
421+ Returns:
422+ dict: JSON decoded results from the response file
423+
424+ Raises:
425+ Exception: If evaluation failed or was interrupted by user
426+ """
350427 # If the eval request succeeded, return the json decoded result.
351428 if not eval_response ["isError" ]:
352429 result_filepath = eval_response ["responseStr" ].strip ()
0 commit comments