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

Autoreload #775

Closed
mileslucas opened this issue May 9, 2020 · 5 comments
Closed

Autoreload #775

mileslucas opened this issue May 9, 2020 · 5 comments

Comments

@mileslucas
Copy link

This is a feature request

I've recently been doing a lot of coding two packages in Julia and python side-by-side and have been sorely missing the %autoreload 2 magic from ipython. Is this something that can be incorporated into PyCall? The ideal usage I could image is something like

using PyCall
autoreload()
@stevengj
Copy link
Member

stevengj commented May 9, 2020

I think you could use IPython itself for this, at least from IJulia. Something like:

autoreload = pyimport("IPython.extensions.autoreload").AutoreloadMagics()
IJulia.push_preexecute_hook(() -> autoreload.pre_run_cell())
IJulia.push_postexecute_hook(() -> autoreload.post_execute_hook())

@mileslucas
Copy link
Author

I'll give that a try! I'm curious, though, if we can get the same functionality for use on the command line too. Our REPL is much closer to ipython REPL than the python REPL, so if we can make it work without having to use IJulia, that would be awesome!

@stevengj
Copy link
Member

stevengj commented May 15, 2020

Yes, in Julia 1.5 you can use the new REPL AST transformation feature to push a transformation that calls the IPython AutoreloadMagics pre/post execute hooks before the code that is executed.

This is very similar to what Revise.jl does. See timholy/Revise.jl#425

@stevengj
Copy link
Member

stevengj commented May 15, 2020

If you get this to work, I would suggest putting it in a PyRevise.jl package (analogous to Revise.jl), so that people who want this could run using PyRevise (or put that in their Julia startup files).

@mileslucas
Copy link
Author

Sounds good! I'll go ahead and close this considering your point about the auxiliary package. Thanks!

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