Skip to content

fix(pyast): tag @modal.batched with a distinguishable leak (calque#91) - #182

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/modal-batched-leak-tag
Aug 15, 2026
Merged

fix(pyast): tag @modal.batched with a distinguishable leak (calque#91)#182
scttfrdmn merged 1 commit into
mainfrom
feat/modal-batched-leak-tag

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

  • Part of Lower-priority/rare Modal constructs: Dict/Queue, @modal.batched, NetworkFileSystem, CloudBucketMount, Cron/Period objects #91. @modal.batched(...) (Modal's auto-batching decorator) had zero recognition in tools/pyast/pyast.py — unlike its four sibling rare constructs (Dict/Queue/NetworkFileSystem.from_name(...), CloudBucketMount(...)), which already get a distinguishable leak tag via _unsupported_construct_from_name/_unsupported_construct_call. This one fell through completely unnoticed: no leak at all.
  • _describe_fn now scans a function/method's decorator_list for a trailing "batched" name (mirrors the existing _decorator_name(d).rsplit(".", 1)[-1] == "function" style already used elsewhere) and appends a "modal.batched" leak to the same helper_leaks list the other four constructs use. It's a MODIFIER on top of whatever shape the function already has, so it deliberately does NOT become a new entry_kind value (unlike _SERVE_DECOS/_entry_kind) — the function still runs, just without Modal's request-coalescing behavior.
  • No Go-side code changes needed: internal/parse/parse.go's existing generic HelperLeaks -> KindUnhandledCase channel picks up the new leak automatically (same mechanism Resolve real per-env images for a module-level for-loop of decorated functions (blocks #178 verification) #179's for-loop-expansion leak used with zero Go changes) — verified by actually running the new test.
  • New minimal synthetic fixture testdata/scripts/batched_function.py (no vendoring, matches this repo's fixture conventions).
  • Updated docs/modal-compatibility-matrix.md's @modal.batched/@app.batched rows from ⬜ "not modeled" to 🟨 "recognized, not modeled."
  • Real batching execution (coalescing N concurrent calls into one list-valued call) remains explicitly out of scope — matches this project's "fake behind the seam, leak the gap" posture for rare (~2/212) constructs.

Test plan

  • go build ./..., gofmt -l . (no output), go vet ./... all clean
  • go test -count=1 ./... — all packages pass
  • golangci-lint run ./... — 0 issues
  • uvx ruff check . — all checks passed
  • New TestParseModalBatchedDecoratorLeaks in internal/parse/parse_test.go, run verbosely (-run TestParseModalBatchedDecoratorLeaks -v) — PASS: asserts the leak's Detail mentions modal.batched + batching/coalescing, AND that the decorated function (process) still resolves normally via app.FindFunction (leak is additive, not a refusal to parse)

@modal.batched(...) had zero recognition in pyast.py: unlike its four
sibling rare constructs (Dict/Queue/NetworkFileSystem.from_name(...) and
CloudBucketMount(...)), which already got a distinguishable leak tag via
_unsupported_construct_from_name/_unsupported_construct_call, this decorator
fell through completely unnoticed -- no leak at all.

_describe_fn now scans a function/method's decorator_list for a trailing
"batched" name and appends a "modal.batched" leak to the same helper_leaks
list the other four constructs use. It's a MODIFIER stacked on whatever
shape the function already has, so it does not become a new entry_kind
value (unlike _SERVE_DECOS/_entry_kind) -- the function still runs, just
without Modal's request-coalescing behavior. No Go-side changes needed:
parse.go's existing generic HelperLeaks -> KindUnhandledCase channel picks
up the new leak automatically, verified via the new
TestParseModalBatchedDecoratorLeaks test against a new synthetic fixture
(testdata/scripts/batched_function.py). Real batching execution remains
explicitly out of scope, matching this project's "fake behind the seam,
leak the gap" posture for rare (~2/212) constructs.
@scttfrdmn
scttfrdmn merged commit 32b978a into main Aug 15, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the feat/modal-batched-leak-tag branch August 15, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant