@@ -210,12 +210,6 @@ def __init__(
210210
211211 if compile and self ._exe_file is None :
212212 self .compile (force = str (compile ).lower () == 'force' )
213- if self ._exe_file is None :
214- raise ValueError (
215- 'Unable to compile Stan model file: {}.' .format (
216- self ._stan_file
217- )
218- )
219213
220214 def __repr__ (self ) -> str :
221215 repr = 'CmdStanModel: name={}' .format (self ._name )
@@ -531,45 +525,26 @@ def compile(
531525 get_logger ().info (
532526 'compiled model executable: %s' , self ._exe_file
533527 )
534- if compilation_failed or 'Warning' in console :
528+ if 'Warning' in console :
535529 lines = console .split ('\n ' )
536530 warnings = [x for x in lines if x .startswith ('Warning' )]
537- syntax_errors = [
538- x for x in lines if x .startswith ('Syntax error' )
539- ]
540- semantic_errors = [
541- x for x in lines if x .startswith ('Semantic error' )
542- ]
543- exceptions = [
544- x
545- for x in lines
546- if 'Uncaught exception' in x or 'fatal error' in x
547- ]
548- if (
549- len (syntax_errors ) > 0
550- or len (semantic_errors ) > 0
551- or len (exceptions ) > 0
552- ):
553- get_logger ().error ('Stan program failed to compile:' )
554- get_logger ().warning (console )
555- elif len (warnings ) > 0 :
556- get_logger ().warning (
557- 'Stan compiler has produced %d warnings:' ,
558- len (warnings ),
559- )
560- get_logger ().warning (console )
561- elif (
562- 'PCH file' in console
563- or 'model_header.hpp.gch' in console
564- or 'precompiled header' in console
565- ):
531+ get_logger ().warning (
532+ 'Stan compiler has produced %d warnings:' ,
533+ len (warnings ),
534+ )
535+ get_logger ().warning (console )
536+ if compilation_failed :
537+ if 'PCH' in console or 'precompiled header' in console :
566538 get_logger ().warning (
567539 "CmdStan's precompiled header (PCH) files "
568540 "may need to be rebuilt."
569- "If your model failed to compile please run "
570- "cmdstanpy.rebuild_cmdstan().\n If the "
571- "issue persists please open a bug report"
541+ "Please run cmdstanpy.rebuild_cmdstan().\n "
542+ "If the issue persists please open a bug report"
572543 )
544+ raise ValueError (
545+ f"Failed to compile Stan model '{ self ._stan_file } '. "
546+ f"Console:\n { console } "
547+ )
573548
574549 def optimize (
575550 self ,
0 commit comments