fix(pyast): tag @modal.batched with a distinguishable leak (calque#91) - #182
Merged
Conversation
@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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@modal.batched(...)(Modal's auto-batching decorator) had zero recognition intools/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_fnnow scans a function/method'sdecorator_listfor 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 samehelper_leakslist 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 newentry_kindvalue (unlike_SERVE_DECOS/_entry_kind) — the function still runs, just without Modal's request-coalescing behavior.internal/parse/parse.go's existing genericHelperLeaks -> KindUnhandledCasechannel 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.testdata/scripts/batched_function.py(no vendoring, matches this repo's fixture conventions).docs/modal-compatibility-matrix.md's@modal.batched/@app.batchedrows from ⬜ "not modeled" to 🟨 "recognized, not modeled."Test plan
go build ./...,gofmt -l .(no output),go vet ./...all cleango test -count=1 ./...— all packages passgolangci-lint run ./...— 0 issuesuvx ruff check .— all checks passedTestParseModalBatchedDecoratorLeaksininternal/parse/parse_test.go, run verbosely (-run TestParseModalBatchedDecoratorLeaks -v) — PASS: asserts the leak's Detail mentionsmodal.batched+ batching/coalescing, AND that the decorated function (process) still resolves normally viaapp.FindFunction(leak is additive, not a refusal to parse)