Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set custom path with run_code #4110

Open
saulshanabrook opened this issue Apr 23, 2024 · 1 comment
Open

Set custom path with run_code #4110

saulshanabrook opened this issue Apr 23, 2024 · 1 comment

Comments

@saulshanabrook
Copy link
Contributor

Hello!

I was wondering if it might be possible to add a path parameter to run_code, so that it could create a code objection a different path than the default of "<string>\0". It could be an optional parameter that defaults to the current value. Alternatively, to not break the API, maybe another function called run_code_path could be created that is also public that run_code calls with that parameter?

Currently, I am keeping a duplicate of that function in my source with the parameter added, which adds some overhead when changes happen upstream.

I am doing arbitrary code execution, but I want the tracebacks to refer to line numbers that can be referenced, so I am creating a temporary file, writing the code to it, then evaling that code with that path:

https://github.com/egraphs-good/egglog-python/blob/59b04eaa4f87ac320385efe4b6d71e93db64a116/src/py_object_sort.rs#L351-L365

I am happy to make a PR to add this feature if it is desired. Thanks!

@davidhewitt
Copy link
Member

This would be welcome, see also #2281 where we wondered if it made sense to use a builder API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants