Skip to content

Commit ef67864

Browse files
authored
fix: output streaming in case of fallback (#1071)
Signed-off-by: Louis Mandel <[email protected]>
1 parent 11484cd commit ef67864

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/pdl/pdl_interpreter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,12 @@ def process_advanced_block(
453453
if block.trace_error_on_retry:
454454
scope = set_error_to_scope_for_retry(scope, error, block.pdl__id)
455455
continue
456+
state = init_state.with_yield_result(
457+
init_state.yield_result and ContributeTarget.RESULT in block.contribute
458+
)
459+
state = state.with_yield_background(
460+
state.yield_background and context_in_contribute(block)
461+
)
456462
(
457463
result,
458464
background,

tests/test_fallback.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,15 @@ def test_type_checking_in_fallback():
7676
str(exc.value.message)
7777
== "Type errors during spec checking:\nline 4 - Error should be of type <class 'int'>"
7878
)
79+
80+
81+
def test_fallback_and_parser():
82+
prog_str = """
83+
model: "raise an error"
84+
parser: json
85+
spec: { xxx: string, age: integer}
86+
fallback:
87+
data: { "xxx": "rosa", "age": 3 }
88+
"""
89+
result = exec_str(prog_str)
90+
assert result == {"xxx": "rosa", "age": 3}

0 commit comments

Comments
 (0)