JuliaText / CorpusLoaders.jl

A variety of loaders for various NLP corpora.
Other
32 stars 13 forks source link

InitError: LoadError: Evaluation into closed module `CorpusLoaders` breaks #43

Closed AdarshKumar712 closed 3 years ago

AdarshKumar712 commented 3 years ago

I am trying to use CorpusLoaders.jl as a dependency in another package. But when precompiling, I get the following error:

T1) pkg> precompile
Precompiling project...
  Progress [========================================>]  1/1
  ✗ T1
0 dependencies successfully precompiled in 16 seconds (39 already precompiled)

ERROR: The following 1 direct dependency failed to precompile:

T1 [88852414-a7b6-4fb4-ac26-6b40a70986e8]

ERROR: LoadError: InitError: LoadError: Evaluation into the closed module `CorpusLoaders` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `CorpusLoaders` with `eval` during precompilation - don't do this.
Stacktrace:
  [1] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
  [2] include
    @ ~/.julia/packages/CorpusLoaders/w40jN/src/CorpusLoaders.jl:1 [inlined]
  [3] __init__()
    @ CorpusLoaders ~/.julia/packages/CorpusLoaders/w40jN/src/CorpusLoaders.jl:17
  [4] _include_from_serialized(path::String, depmods::Vector{Any})
    @ Base ./loading.jl:674
  [5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
    @ Base ./loading.jl:760
  [6] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:998
  [7] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:914
  [8] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:901
  [9] include
    @ ./Base.jl:386 [inlined]
 [10] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base ./loading.jl:1213
 [11] top-level scope
    @ none:1
 [12] eval
    @ ./boot.jl:360 [inlined]
 [13] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [14] top-level scope
    @ none:1
in expression starting at /home/adarshkumar712/.julia/packages/CorpusLoaders/w40jN/src/WikiCorpus_DataDeps.jl:1
during initialization of module CorpusLoaders
in expression starting at /home/adarshkumar712/Projects/Test/T1/src/T1.jl:1

T1.jl looks like this:

module T1
    using CorpusLoaders
end

Referring to https://github.com/JuliaLang/julia/issues/39648 , the reason for this is using @eval inside __init__() in CorpusLoaders.jl, but I wasn't able to locate any eval to cause this.

Can someone please have a look?

cc @oxinabox

oxinabox commented 3 years ago

That is annoying. I am pretty sure the eval is actually the use of include (include basically calls eval under the hood). which is all the includes here: https://github.com/JuliaText/CorpusLoaders.jl/blob/379ff7bf902a1d8e48153f3da53eb811afda00ac/src/CorpusLoaders.jl#L16-L27

The fix is to have them all defining a function e.g. init_WikiCorpus_DataDeps() or perhaps better: init_datadeps(::Type{WikiCorpus)) which does the definition of the datadep, and is called from the main __init__. that function can be defined in the main fule for that corpus, e.g. WikiCorpus.jl rather than being in it's own file.

AdarshKumar712 commented 3 years ago

Thanks for the reply. I will try it. And if it works, I will also create a PR for the same.