11import json
2- import logging
32import re
43import shlex
54import subprocess # nosec
103102 stringify ,
104103)
105104
106- logger = logging .getLogger (__name__ )
107-
108-
109105empty_scope : ScopeType = PdlDict ({"pdl_context" : PdlList ([])})
110106
111107
@@ -145,7 +141,6 @@ def with_pop(self: "InterpreterState") -> "InterpreterState":
145141
146142def generate (
147143 pdl_file : str | Path ,
148- log_file : Optional [str | Path ],
149144 state : Optional [InterpreterState ],
150145 initial_scope : ScopeType ,
151146 trace_file : Optional [str | Path ],
@@ -154,14 +149,10 @@ def generate(
154149
155150 Args:
156151 pdl_file: Program to execute.
157- log_file: File where the log is written. If `None`, use `log.txt`.
158152 initial_scope: Environment defining the variables in scope to execute the program.
159153 state: Initial state of the interpreter.
160154 trace_file: Indicate if the execution trace must be produced and the file to save it.
161155 """
162- if log_file is None :
163- log_file = "log.txt"
164- logging .basicConfig (filename = log_file , encoding = "utf-8" , format = "" , filemode = "w" )
165156 try :
166157 prog , loc = parse_file (pdl_file )
167158 if state is None :
@@ -271,7 +262,6 @@ def process_block(
271262 yield_background (background )
272263 if state .yield_result :
273264 yield_result (result .result (), BlockKind .DATA )
274- append_log (state , "pdl_context" , background )
275265 else :
276266 result , background , scope , trace = process_advanced_block_timed (
277267 state , scope , block , loc
@@ -653,8 +643,6 @@ def process_block_body(
653643 ) from exc
654644 match_case_trace = match_case .model_copy (update = {"then" : then_trace })
655645 cases .append (match_case_trace )
656- if not matched :
657- append_log (state , "Match" , "no match!" )
658646 block .with_ = cases
659647 trace = block
660648 case RepeatBlock ():
@@ -1264,18 +1252,12 @@ def get_transformed_inputs(kwargs):
12641252 litellm_params = params_to_model
12651253
12661254 litellm .input_callback = [get_transformed_inputs ]
1267- # append_log(state, "Model Input", messages_to_str(model_input))
12681255
12691256 msg , raw_result = generate_client_response (state , concrete_block , model_input )
1270- # if "input" in litellm_params:
1271- append_log (state , "Model Input" , litellm_params )
1272- # else:
1273- # append_log(state, "Model Input", messages_to_str(model_input))
12741257 background : LazyMessages = PdlList ([lazy_apply (lambda msg : msg | {"defsite" : block .id }, msg )]) # type: ignore
12751258 result = lazy_apply (
12761259 lambda msg : "" if msg ["content" ] is None else msg ["content" ], msg
12771260 )
1278- append_log (state , "Model Output" , result )
12791261 trace = block .model_copy (update = {"result" : result , "trace" : concrete_block })
12801262 if block .modelResponse is not None :
12811263 scope = scope | {block .modelResponse : raw_result }
@@ -1423,7 +1405,6 @@ def process_call_code(
14231405 loc ,
14241406 )
14251407 code_s = code_ .result ()
1426- append_log (state , "Code Input" , code_s )
14271408 match block .lang :
14281409 case "python" :
14291410 try :
@@ -1495,7 +1476,6 @@ def process_call_code(
14951476 loc = loc ,
14961477 trace = block .model_copy (),
14971478 )
1498- append_log (state , "Code Output" , result )
14991479 trace = block .model_copy (update = {"result" : result })
15001480 return result , background , scope , trace
15011481
@@ -1615,7 +1595,6 @@ def process_input(
16151595 try :
16161596 with open (file , encoding = "utf-8" ) as f :
16171597 s = f .read ()
1618- append_log (state , "Input from File: " + str (file ), s )
16191598 except Exception as exc :
16201599 if isinstance (exc , FileNotFoundError ):
16211600 msg = f"file { str (file )} not found"
@@ -1637,7 +1616,6 @@ def process_input(
16371616 message = "Enter/Paste your content. Ctrl-D to save it."
16381617 if block .multiline is False :
16391618 s = input (message )
1640- append_log (state , "Input from stdin: " , s )
16411619 else : # multiline
16421620 print (message )
16431621 contents = []
@@ -1648,7 +1626,6 @@ def process_input(
16481626 break
16491627 contents .append (line + "\n " )
16501628 s = "" .join (contents )
1651- append_log (state , "Input from stdin: " , s )
16521629 trace = block .model_copy (update = {"result" : s })
16531630 background : LazyMessages = PdlList (
16541631 [PdlDict ({"role" : state .role , "content" : s , "defsite" : block .id })] # type: ignore
@@ -1802,8 +1779,3 @@ def parse_result(parser: ParserType, text: str) -> JSONReturnType:
18021779
18031780def get_var (var : str , scope : ScopeType , loc : LocationType ) -> Any :
18041781 return process_expr (scope , f"{ EXPR_START_STRING } { var } { EXPR_END_STRING } " , loc )
1805-
1806-
1807- def append_log (state : InterpreterState , title , somestring ):
1808- logger .warning ("********** %s **********" , title )
1809- # logger.warning(str(somestring)) # XXX TODO: Logging without forcing lazy values
0 commit comments