feat(coordination): accept a callable key generator in the KV API - #43435
Conversation
CoordinationService.get_value / set_value / delete_value took a plain key string; the caller always built the key eagerly. For parity with Superset's other cache-key helpers (e.g. memoized_func(key=...)), the KV ops now also accept a () -> str key *generator*, resolved at call time via a shared _resolve_key helper (a non-string result raises TypeError). A literal string still passes through unchanged, so this is backward-compatible and additive. Note this is scoped to the general-purpose coordinator KV only — the GTF task_key stays a fixed literal (it is the dedup identity resolved synchronously at submit time, feeding the dedup lock + dedup_key).
|
Bito Automatic Review Skipped - Branch Excluded |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## gaq-to-gtf #43435 +/- ##
===========================================
Coverage 78.84% 78.84%
===========================================
Files 2880 2880
Lines 164425 164459 +34
Branches 37995 38003 +8
===========================================
+ Hits 129636 129673 +37
+ Misses 32346 32341 -5
- Partials 2443 2445 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
SUMMARY
Small, additive ergonomics improvement to the coordination service, part of the GAQ→GTF epic (targets
gaq-to-gtf).CoordinationService.get_value/set_value/delete_valuepreviously took a plainkey: str, so every caller had to build the key string eagerly. For parity with Superset's other cache-key helpers (e.g.memoized_func(key=...)), the KV ops now also accept a() -> strkey generator, resolved at call time via a shared_resolve_keyhelper. A literal string still passes through unchanged, so the change is backward-compatible and purely additive;delete_value(*keys)accepts a mix of literals and generators.A generator that returns a non-string raises
TypeError(fail fast, before touching the backend).Scope note: this is intentionally limited to the general-purpose coordinator KV. The GTF
task_keystays a fixed literal — it is the dedup identity resolved synchronously at submit time (it feeds the dedup lock +dedup_key), so it must not become callable/mutable.TESTING INSTRUCTIONS
pytest tests/unit_tests/coordination/test_service.py tests/unit_tests/distributed_lock/— 27 passed. New coverage: a callable key resolved per-op for get/set/delete (incl. a literal+callable mix), and the non-string-keyTypeErrorguard.mypy/ruff/pylintclean on changed files.ADDITIONAL INFORMATION