Skip to content

Commit 47280a7

Browse files
authored
updated docs README, removed logger (#617)
* updated docs README, removed logger Signed-off-by: Mandana Vaziri <[email protected]> * telemetry Signed-off-by: Mandana Vaziri <[email protected]> --------- Signed-off-by: Mandana Vaziri <[email protected]>
1 parent 195ef01 commit 47280a7

File tree

8 files changed

+107
-137
lines changed

8 files changed

+107
-137
lines changed

docs/README.md

Lines changed: 106 additions & 84 deletions
Large diffs are not rendered by default.

docs/assets/telemetry.png

302 KB
Loading

docs/contrib.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ Follow the following instructions to set up a dev environment to get started wit
5454
Hello! How can I help you today?
5555
```
5656
57-
You are all set!
58-
5957
### Documentation updates
6058
6159
When you make changes to PDL, ensure to document any new features in the docs section. You can serve the docs locally to preview changes.

examples/hello/hello-def-use.pdl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ text:
44
# Define GEN to be the result of a Granite LLM using ollama
55
- model: ollama/granite-code:8b
66
parameters:
7-
# "greedy" sampling tells the LLM to use the most likely token at each step
8-
# decoding_method: greedy # Not used by Ollama
97
# Tell the LLM to stop after generating an exclamation point.
108
stop: ['!']
119
def: GEN

examples/notebooks/demo.ipynb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -436,16 +436,6 @@
436436
"\n"
437437
]
438438
},
439-
{
440-
"cell_type": "code",
441-
"execution_count": null,
442-
"id": "9b919506-79ed-4a13-ac1d-1fdfc3e4f9d9",
443-
"metadata": {},
444-
"outputs": [],
445-
"source": [
446-
"! cat log.txt"
447-
]
448-
},
449439
{
450440
"cell_type": "markdown",
451441
"id": "89438b62-29e4-472e-89ec-57c1626ffd44",

src/pdl/pdl.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import argparse
22
import json
3-
import logging
43
import sys
54
from pathlib import Path
65
from typing import Any, Literal, Optional, TypedDict
@@ -25,8 +24,6 @@
2524
from .pdl_runner import exec_docker
2625
from .pdl_utils import validate_scope
2726

28-
logger = logging.getLogger(__name__)
29-
3027

3128
class InterpreterConfig(TypedDict, total=False):
3229
"""Configuration parameters of the PDL interpreter."""
@@ -68,7 +65,6 @@ def exec_program(
6865
Returns:
6966
Return the final result if `output` is set to `"result"`. If set of `all`, it returns a dictionary containing, `result`, `scope`, and `trace`.
7067
"""
71-
logging.basicConfig(filename="log.txt", encoding="utf-8", format="", filemode="w")
7268
config = config or {}
7369
state = InterpreterState(**config)
7470
if not isinstance(scope, PdlDict):
@@ -189,11 +185,6 @@ def main():
189185
const="*_trace.json",
190186
help="output trace for live document and optionally specify the file name",
191187
)
192-
parser.add_argument(
193-
"-l",
194-
"--log",
195-
help="specify a name for the log file",
196-
)
197188
parser.add_argument(
198189
"--schema",
199190
action="store_true",
@@ -278,7 +269,6 @@ def main():
278269
)
279270
pdl_interpreter.generate(
280271
pdl_file,
281-
args.log,
282272
InterpreterState(**config),
283273
PdlDict(initial_scope),
284274
trace_file,

src/pdl/pdl_interpreter.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import logging
32
import re
43
import shlex
54
import subprocess # nosec
@@ -103,9 +102,6 @@
103102
stringify,
104103
)
105104

106-
logger = logging.getLogger(__name__)
107-
108-
109105
empty_scope: ScopeType = PdlDict({"pdl_context": PdlList([])})
110106

111107

@@ -145,7 +141,6 @@ def with_pop(self: "InterpreterState") -> "InterpreterState":
145141

146142
def 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

18031780
def 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

tests/test_line_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def do_test(t, capsys):
7-
generate(t["file"], None, None, empty_scope, None)
7+
generate(t["file"], None, empty_scope, None)
88
captured = capsys.readouterr()
99
output_string = captured.out + "\n" + captured.err
1010
output = output_string.split("\n")

0 commit comments

Comments
 (0)