Skip to content

Commit

Permalink
Enable default responses and fix context rendering logic
Browse files Browse the repository at this point in the history
Simplified context rendering by directly returning non-string values and enabled forcing default responses for certain questions. This reduces unnecessary UI interactions and corrects the faulty rendering of expression values in contextual overlays.
  • Loading branch information
coordt committed Nov 10, 2024
1 parent ba65296 commit 4af116f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 7 additions & 1 deletion project_forge/context_builder/overlays.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ def process_overlay(overlay: Overlay, running_context: dict, question_ui: Callab
current_context = deepcopy(running_context)
pattern = overlay.pattern
current_context = merge_contexts(current_context, overlay.extra_context, pattern.extra_context)
force_default = not overlay.ask_questions

for question in pattern.questions:
if force_default:
question.force_default = True
current_context.update(
answer_question(
question=question,
Expand Down Expand Up @@ -65,5 +68,8 @@ def merge_contexts(
out_context = deepcopy(initial_context)
extra_context = {**pattern_context, **overlay_context}
for key, value in extra_context.items():
out_context[key] = render_expression(value, out_context)
if isinstance(value, str):
out_context[key] = render_expression(value, out_context)
else:
out_context[key] = value
return dict(out_context)
4 changes: 1 addition & 3 deletions project_forge/context_builder/questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def answer_question(
else:
default = render_expression(question.default, running_context) if question.default else None

force_default = render_bool_expression(question.force_default or "False", running_context)

if force_default:
if render_bool_expression(question.force_default or "False", running_context):
return {question.name: default}

answer = question_ui(
Expand Down

0 comments on commit 4af116f

Please sign in to comment.