Revise with include chain

Hi guys,

how do I make Revise work properly here?

File1:

using Revise
includet("testrevise1.jl")
using .testrevise1  

func()

File “testrevise1.jl”:

module testrevise1

export func

include("testrevise2.jl")

end

File “testrevise2.jl”:

function func()
    print("hello world! 4")
end

Does the second file have to load Revise as well?

This short thread addresses this, this is how includet is supposed to work: “include and track this file”. To automatically track a network of included files, you need to work on a package. I think you could technically replace nested includes with includet but you’d also have to temporarily import Revise in all your modules, and that’s not recommended over package work.

An aside, the other issue that thread addresses appears to have been patched by now.

2 Likes

I am a bit lost with packages… The docs are either too trivial or too difficult for me xD

Here is a test:
I create a package named “REVISETEST”, whose /src folder holds two files:
REVISETEST.jl

module REVISETEST

include("revise_include.jl")

end # module REVISETEST

and revise_include.jl

function this_is_sparta()
    print("This is SPARTA!!!!")
end

After Pkg.activate("REVISETEST"), I open some main file:

using REVISETEST

REVISETEST.this_is_sparta()

Note that I don’t even use Revise here. Yet, if I comment out the Sparta function in revise_include and save the file, and then re-run the main file (without restarting Julia), the function is gone. Are packages automatically “revised”, or what is going on here?

After editing a file in its package, rerunning using REVISETEST actually reevaluates and reimports it. Revise is designed to automatically make some small changes to live code when you edit the tracked source code, no need to do the big overhauls (rerunning include, using, import) and waste time reevaluating lines you didn’t change. You will have to do the big overhauls once in a while because small interactive changes out of order does not always have the same effect, but you can get a lot done with small changes.

1 Like

but it seems to work even if I comment using REVISETEST out. Is VScode doing some magic here?

What seems to work? The whole process you described above? Did you make sure to go through the process twice, once to make this_is_sparta exist in the session and once after commenting it out in the source? I don’t use VScode so I can’t really answer this, I’m just curious because it’s unexpected.

I just realized the VSCode Julia extension has a setting in which Revise is loaded by default. That will have disturbed my little experiments.

I deactivated it now and load Revise manually. I think everything works as expected then.
I simply have

using Revise
using REVISETEST

REVISETEST.this_is_sparta()

If I now modify the sparta function and save, I can immediately call the modified function, I don’t even have to re-run the using command.

Thanks for your help!

1 Like