Precompile custom module fails but program still working

I am trying to formalize my code in a more julian style and I have sepparated a lot of routines from a Jupyter Notebook to a Julia sort of script with all that I could put on a functions module in another file. I am also using another custom module that I created for solving another problem in the past. This older module is called by one of the new modules only. In the header of the new module I have something equivalent to these instructions:

push!(LOAD_PATH, "../TheOtherProblem/")
using ArrayToSetTools # my older module

In the main file also I have the push! part, but I guess is superfluous as I don’t really call anything from the other directory here.

When I ran the program with the standar julia main.jl args it takes some 20 seconds to start giving messages and then I get these:

┌ Warning: The call to compilecache failed to create a usable precompiled cache file for Aglomerar [top-level]
│   exception = Required dependency ArraySetTools [top-level] failed to load from a cache file.
â”” @ Base loading.jl:969
┌ Warning: The call to compilecache failed to create a usable precompiled cache file for AglomeraAuxiliar [top-level]
│   exception = Required dependency ArraySetTools [top-level] failed to load from a cache file.
â”” @ Base loading.jl:969
┌ Warning: The call to compilecache failed to create a usable precompiled cache file for Aglomerar [top-level]
│   exception = Required dependency ArraySetTools [top-level] failed to load from a cache file.
â”” @ Base loading.jl:969

This takes around 3 minutes every time. Its allways the ArraySetTools module that is on the other directory the one that seems to generate the mess.

As I am testing continously the code with different parameters, its very tedious, and I do not seem to grasp what is wrong… ¿could it be that Julia needs to have all the code in the same directory by some reason?

Why are you mucking around with LOAD_PATH? I would suggest just creating packages and using the package manager.

1 Like

Wpkzz, I don’t know what your background is, but when I started using Julia after having done quite a bit with Python+numpy, code organization was a difficult thing for me. Some people here love Julia but have that one feature that they miss from Python; my missed feature is that the Python import keyword Just Works almost no matter how you use it. Julia’s takes a little more time to get used to and has some issues; ex. https://github.com/JuliaLang/julia/issues/4600.

If you make your code into a package, as Kristoffer suggested, all of the worries about the import and using keywords go away and using ArrayToSetTools will do exactly what you expect. You can probably just do ] dev ArrayToSetTools and copy your code to the ArrayToSetTools.jl file created in .julia/dev/ArrayToSetTools

1 Like

Okey, I have absolutely no idea what you are talking about… Is it not, then, ordering the code in modules essentially preparing a Package? Or what is “creating a package”? Also I forgot to mention this: in my unordered code in a Jupyter Notebook I have not this issue, I can simply extend the path and load the older module in less than a second and it flows. But then the code has all the definition of functions inside and, to my taste, is like a scrapbook or the like.

No, modules are just namespaces (but packages do use modules).

https://docs.julialang.org/en/latest/manual/modules/

https://julialang.github.io/Pkg.jl/dev/creating-packages/

but I would recommend reading the whole manual from the beginning

I still find it very weird that on Jupyter I have no such issue but in the standalone script i do.