@@ -387,12 +387,18 @@ def execute(self, command: str):
387387
388388 return self .sendExpression (command , parsed = False )
389389
390- def sendExpression (self , expr : str , parsed : bool = True ) -> Any :
390+ def sendExpression (self , expr : str , parsed : bool = True , raise_on_error : bool = True ) -> Any :
391391 """
392392 Send an expression to the OMC server and return the result.
393393
394394 The complete error handling of the OMC result is done within this method using 'getMessagesStringInternal()'.
395395 Caller should only check for OMSessionException.
396+
397+ Some OMC API calls (e.g. buildModel) can emit 'error'-level diagnostics that are recoverable and don't
398+ actually prevent the call from succeeding (e.g. a structurally singular initialization system that OMC
399+ resolves via a fallback). Callers who have their own, more precise way of verifying success (such as
400+ checking that the resulting files/executable actually exist) can pass raise_on_error=False to have such
401+ messages logged instead of raised as an exception.
396402 """
397403
398404 if self ._omc_zmq is None :
@@ -509,8 +515,11 @@ def sendExpression(self, expr: str, parsed: bool = True) -> Any:
509515 msg_long_list .append (msg_long )
510516 if has_error :
511517 msg_long_str = '\n ' .join (f"{ idx :02d} : { msg } " for idx , msg in enumerate (msg_long_list ))
512- raise OMSessionException (f"OMC error occurred for 'sendExpression(expr={ expr } , parsed={ parsed } ):\n "
513- f"{ msg_long_str } " )
518+ if raise_on_error :
519+ raise OMSessionException (
520+ f"OMC error occurred for 'sendExpression(expr={ expr } , parsed={ parsed } ):\n { msg_long_str } " )
521+ logger .warning ("OMC reported 'error'-level messages for 'sendExpression(expr=%s, parsed=%s)', but "
522+ "raise_on_error=False was requested; continuing:\n %s" , expr , parsed , msg_long_str )
514523
515524 if not parsed :
516525 return result
@@ -866,17 +875,20 @@ def _docker_omc_start(
866875 loop = self ._timeout_loop (timestep = 0.1 )
867876 while next (loop ):
868877 try :
869- with open (file = docker_cid_file , mode = "r" , encoding = "utf-8" ) as fh :
878+ with open (docker_cid_file , "r" , encoding = "utf-8" ) as fh :
870879 docker_cid = fh .read ().strip ()
871880 except IOError :
872- pass
873- if docker_cid is not None :
881+ continue
882+
883+ if docker_cid :
874884 break
875885
876- if docker_cid is None :
877- raise OMSessionException (f"Docker did not start (timeout={ self ._timeout :.2f} s might be too short "
878- "especially if you did not docker pull the image before this command). "
879- f"Log-file says:\n { self .get_log ()} " )
886+ if not docker_cid :
887+ raise OMSessionException (
888+ f"Docker did not start (timeout={ self ._timeout :.2f} s might be too short "
889+ "especially if you did not docker pull the image before this command). "
890+ f"Log-file says:\n { self .get_log ()} "
891+ )
880892
881893 docker_process = self ._docker_process_get (docker_cid = docker_cid )
882894 if docker_process is None :
0 commit comments