Skip to content

[SymForce] Reject constant inputs in Codegen - #478

Open
devteamaegis wants to merge 1 commit into
symforce-org:mainfrom
devteamaegis:fix/codegen-reject-constant-inputs
Open

devteamaegis wants to merge 1 commit into
symforce-org:mainfrom
devteamaegis:fix/codegen-reject-constant-inputs

Conversation

@devteamaegis

Copy link
Copy Markdown

Fixes #170.

Codegen accepted inputs that weren't symbols, for example Values(a=sf.Rot3.from_storage([1, 2, 3, 4])), and generated a function whose argument has no effect. The constructor now checks that every storage element of every input is an sf.Symbol and raises ValueError: Inputs must be symbolic, found constants or expressions in: ['a'] otherwise. DataBuffers and None inputs store as empty lists, so they're unaffected.

Tests: added cases to test_invalid_codegen_raises for constant inputs, an expression input (x * y) and a vector mixing a symbol and a constant. They fail on main and pass with this change. The rest of the Python test suite gives the same results as on main, and ruff check / ruff format --check are clean.

Codegen accepted inputs whose elements were constants or expressions
rather than symbols, e.g. Values(a=sf.Rot3.from_storage([1, 2, 3, 4])),
and generated a function with an argument that is never used. Raise a
ValueError naming the offending input keys instead.

Fixes symforce-org#170
@devteamaegis

Copy link
Copy Markdown
Author

Friendly ping @aaron-skydio: this is ready for review whenever someone has time (fixes #170); happy to make changes.

This was investigated and written with an AI coding agent (Claude) working on my behalf.

This branch has not been deployed

No deployments
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.

codegen.Codegen accepts constants in input

1 participant