Question about Revise.jl and its alternatives (if any)


I tried to use Revise.jl to make some parameter tuning faster. However, it sometimes doesn’t work well for me, because it would not recompile the code after the modified line. Even when these code may use the variable(e.g. NT1=NT+1, or range statement based on it).

For now, I must include the file again. Is there a way to avoid the problem w/o include the file again? Or is there a Revise-like package to do the something like this?

module mymodule
NT=10 #\change NT to 20, Revise would modify this line in the background,  from 10 to 20
t1=NT+1# t1 is NOT updated, still 11
t=range(0.0,stop=NT,step=1.0) # t is NOT updated

Stupid question but how did you test that other variables are not updated?


I load submodules by pushing directory to load path and using submodule. I run it in Atom console.
Tune value of NT in atom, and check by console .submodule.NT. Maybe some settings of Revise.jl are not right…


I can reproduce:

julia> using Revise

(v1.0) pkg> activate mymodule

julia> using mymodule

julia> mymodule.NT

julia> mymodule.t

Now let’s update mymodule

julia> mymodule.NT

julia> mymodule.t

julia> mymodule.t1


Yes, it frustrated me sometimes. So to avoid this, I disable Revise, always rerun “include(”./submodel.jl"); using .subomodel" after I modified anything. Though I wonder if it is the recommended way?
I guess it is due to efficiency - the subsequent code may need long time to execute.


Could you put the code depending on you parameter inside a function? Revise will update the value of the parameter as you edit the file, and re-running the function will give you the correct values:

module mymodule

NT=20 #\change NT to 20

function foo()
    @show t1=NT+1
    @show t=range(0.0,stop=NT,step=1.0)

julia> using Revise

julia> includet("/path/to/mymodule.jl") #or "using mymodule" if the project is correctly activated

t1 = NT + 1 = 11
t = range(0.0, stop=NT, step=1.0) = 0.0:1.0:10.0

julia> # edit "mymodule.jl"

t1 = NT + 1 = 21
t = range(0.0, stop=NT, step=1.0) = 0.0:1.0:20.0

Would such a workflow be suitable for the task at hand?

1 Like

Thanks. It works for simple modification, though not very convenient.