Skip to content

feat: issue #5674- improve wf parsing#6559

Open
srivatsa-av28 wants to merge 2 commits into
keephq:mainfrom
srivatsa-av28:main
Open

feat: issue #5674- improve wf parsing#6559
srivatsa-av28 wants to merge 2 commits into
keephq:mainfrom
srivatsa-av28:main

Conversation

@srivatsa-av28

@srivatsa-av28 srivatsa-av28 commented Jun 7, 2026

Copy link
Copy Markdown

Closes #5674

📑 Description

Added an in-process parse cache to WorkflowStore keyed on
(tenant_id, workflow_id), using the workflow's existing revision
field as the cache validity key.

  • Cache hit: returns the previously parsed Workflow object directly,
    skipping cyaml.safe_load() and Parser.parse() entirely
  • Cache miss: parses as normal and stores the result
  • Cache invalidation: invalidate_workflow_cache() is called from
    delete_workflow() to evict stale entries on deletion
  • Thread safety: a threading.Lock protects the cache dict
    (safe for the ThreadPoolExecutor used in WorkflowScheduler)

Changes

  • keep/workflowmanager/workflowstore.py
    • Added _CachedWorkflow dataclass to hold parsed workflow + revision
    • Added _parse_cache dict and _cache_lock to __init__
    • Updated get_workflow() to check cache before parsing
    • Added invalidate_workflow_cache() method
    • Called invalidate_workflow_cache() from delete_workflow()

Notes

  • No schema migration required
  • No behaviour change on the hot path — cache is purely additive
  • Fully backwards compatible
  • revision is already incremented by add_or_update_workflow() on
    every update, making it a reliable and zero-cost cache key

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 7, 2026
@CLAassistant

CLAassistant commented Jun 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot Bot added the Enhancement New feature or request label Jun 7, 2026
@srivatsa-av28 srivatsa-av28 reopened this Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[➕ Feature]: Improve the WF parsing

2 participants