I’m missing something as far as how to work with multiple files.
I have a directory where I keep two *.jl files, say “core.jl” and “scripts.jl” One has most of the core analytical code, the other has some very project specific scripts. At the top of scripts.jl, I have:
using DataFrames, Distributions, StatsBase, MyModule
where MyModule is in core.jl. If I run scripts.jl without running core.jl first, I get:
LoadError: ArgumentError: Module MyModule not found in current path.
I tried putting the following code at the top of scripts.jl (path edited for brevity):
if length(findin("C:\\MyProject17",LOAD_PATH)) == 0
push!(LOAD_PATH,"C:\\MyProject17")
end
This had no effect.
If I run core.jl first, everything works fine, so this is more of an annoyance. In the off-chance this is an actual issue, happy to post there, but I figure I am most likely just missing something on how to properly link the files. I’m using Julia 0.6/Atom/Juno if it makes a difference.
Just to further explain this point: if you put include("core.jl") in your script file, then each time you edit and reload the script file, the core routines will also get recompiled. That may or may not be desirable depending on the relative size of the files and how often each needs editing.
It is a rather large module, so it would be ideal to not recompile each time. Also, when I do include("core.jl") I get the following error: .
LoadError: UndefVarError: dropNullsFromDF not defined
Where dropNullsFromDF is an exported function in core.jl and MyModule. I’d rather not write out MyModule.dropNullsFromDF or whatever function I am calling each time I use a function from MyModule.
I see, thank you. Just to be clear, the only way to avoid the warnings is to have a package? Is there any way to do this without setting something up on git?
I’m just looking for a light-weight way to work with multiple files without having to go through the overhead of registering it all on git and its version control (this is a mostly solo project).
Also, I noticed wrapping scripts.jl in a module of its own breaks this approach. Just to be clear, this is what I am running:
module myScript
if length(findin(pwd(),LOAD_PATH)) == 0
push!(LOAD_PATH,pwd())
end
include("core.jl")
using DataFrames, StatsBase, Distributions, MyModule
println(myMethod())
end
Error:
LoadError: ArgumentError: Module MyModule not found in current path.
Run `Pkg.add("MyModule")` to install the MyModule package.
while loading C:\Users\Clinton\Dropbox\Projects\JuliaTest\scripts.jl, in expression starting on line 11
in require at base\loading.jl:398
in _require at base\loading.jl:428
I think I got it- I put everything into the same module name as in some of the examples at https://docs.julialang.org/en/stable/manual/modules/#modules-1. I think the similarities and differences between the C++ namespace and class construct and the module construct in Julia were throwing me off.