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

question
#1

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
end
#2

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

#3

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…

#4

I can reproduce:

julia> using Revise

(v1.0) pkg> activate mymodule

julia> using mymodule


julia> mymodule.NT
10

julia> mymodule.t
0.0:1.0:10.0

Now let’s update mymodule

julia> mymodule.NT
20

julia> mymodule.t
0.0:1.0:10.0

julia> mymodule.t1
11

julia> 
#5

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.

#6

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)
end

end
julia> using Revise

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

julia> mymodule.foo()
t1 = NT + 1 = 11
t = range(0.0, stop=NT, step=1.0) = 0.0:1.0:10.0
0.0:1.0:10.0

julia> # edit "mymodule.jl"

julia> mymodule.foo()
t1 = NT + 1 = 21
t = range(0.0, stop=NT, step=1.0) = 0.0:1.0:20.0
0.0:1.0:20.0

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

1 Like
#7

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