Skip to content

Allows the caller to pass in argv to hl.main()#8937

Open
jiawen wants to merge 3 commits intomainfrom
jiawen-hl_main
Open

Allows the caller to pass in argv to hl.main()#8937
jiawen wants to merge 3 commits intomainfrom
jiawen-hl_main

Conversation

@jiawen
Copy link
Contributor

@jiawen jiawen commented Feb 7, 2026

No description provided.

@jiawen jiawen requested a review from abadams February 7, 2026 01:03
@jiawen jiawen assigned alexreinking and unassigned alexreinking Feb 7, 2026
@jiawen jiawen requested a review from alexreinking February 7, 2026 01:03
@jiawen
Copy link
Contributor Author

jiawen commented Feb 7, 2026

Any suggestions on how / where to put tests? A simple test would be to use something like SimplyPyGenerator and call it a few times with different values of -f. But then we'd need to verify what was written to disk.

if (result != 0) {
// Some paths in generate_filter_main() will fail with user_error or similar (which throws an exception
// due to how libHalide is built for Python), but some paths just return an error code. For consistency,
// handle both by throwing a C++ exception, which pybind11 turns into a Python exception.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this comment to be more clear.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be a noodge, but now that this hasn't been substantially changed, can we keep it inline? It will make the diff clearer.

@jiawen
Copy link
Contributor Author

jiawen commented Feb 10, 2026

Hold off on merging - it occurs to me that one can implement hl.main() entirely in Python - there's even a place for it. Then the pybind11 code won't be nearly as messy, using embed().

@mcourteaux mcourteaux marked this pull request as draft February 11, 2026 15:19
@jiawen jiawen marked this pull request as ready for review February 12, 2026 20:42
@jiawen
Copy link
Contributor Author

jiawen commented Feb 12, 2026

@alexreinking PTAL. Much cleaner I think.

@jiawen jiawen requested a review from alexreinking February 12, 2026 20:42
Copy link
Member

@alexreinking alexreinking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with one nitpick

if (result != 0) {
// Some paths in generate_filter_main() will fail with user_error or similar (which throws an exception
// due to how libHalide is built for Python), but some paths just return an error code. For consistency,
// handle both by throwing a C++ exception, which pybind11 turns into a Python exception.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be a noodge, but now that this hasn't been substantially changed, can we keep it inline? It will make the diff clearer.

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.

2 participants