CliMA / CalibrateEmulateSample.jl

Stochastic Optimization, Learning, Uncertainty and Sampling
https://clima.github.io/CalibrateEmulateSample.jl/dev
Apache License 2.0
84 stars 16 forks source link

UndefRefError on write with JDL2 #320

Open bornhoft opened 3 weeks ago

bornhoft commented 3 weeks ago

Hi all, I am new to CES, but I am interested in using it for a project. I am working through the tutorials and have come across the same error in both the Sinusoid and Lorenz examples. Specifically, when I run julia calibrate.jl I get the following error:


Error encountered while save FileIO.File{FileIO.DataFormat{:JLD2}, String}("/<userpath>/CalibrateEmulateSample.jl/examples/Sinusoid/output/calibrate_results.jld2").

Fatal error:
ERROR: LoadError: UndefRefError: access to undefined reference

Any assistance would be greatly appreciated. I may have an issue on my build, but thought this would be the best place to receive support.

odunbar commented 2 weeks ago

Hi @bornhoft thanks for getting in touch and for using the package! Sorry for the delayed response, i was on vacation and getting back into the swing of things. Basically I did not find your error to be reproducible here so I have a list of some things below and what i did to try to reproduce your error that perhaps you can compare to your own procedure!

Let me know whether this helps!

First impressions and things to try

My procedure of trying to reproduce issue (unsuccessfully)

julia version v1.10.5

  1. Clone CES

  2. Navigate cd CalibrateEmulateSample.jl/examples/Sinusoid/

  3. Call julia --project and then

    julia> ]
    (Sinusoid) > instantiate
  4. if PyCall has some issue then do (in-line with our installation instructions)

    julia> using Pkg
    julia> ENV["PYTHON"]=""
    julia> Pkg.build("PyCall")

    My package status then gives:

    julia> ]
    (Sinusoid) pkg> status
    Status `~/Dropbox/Caltech/CESjl/tmp/CalibrateEmulateSample.jl/examples/Sinusoid/Project.toml`
    [95e48a1f] CalibrateEmulateSample v0.5.3
    [31c24e10] Distributions v0.25.111
    ⌅ [aa8a2aa5] EnsembleKalmanProcesses v1.1.7
    [033835bb] JLD2 v0.5.3
    [91a5bcdd] Plots v1.40.8
  5. I then run the EKI calibration with

    julia> include("calibrate.jl")

    (equivalent to julia --project calibrate.jl) and get output:

    Observations:[6.1546719095984805, 6.422583812292371]
    Ensemble mean: [3.0513053859865864; 6.3689317470332725;;]
    True parameters: [3.0, 7.0]
    ┌ Warning: Attempting to store EnsembleKalmanProcesses.ParameterDistributions.var"#11#14"{Int64}.
    │ JLD2 only stores functions by name.
    │  This may not be useful for anonymous functions.
    └ @ JLD2 ~/.julia/packages/JLD2/gi4yM/src/data/writing_datatypes.jl:449
    ... # other warnings

    So it produces some kind of JLD2 warnings but runs through. Indeed I can then call

    julia> include("emulate.jl")
    ... # printouts
    julia> include("sample.jl")
    ... # printouts
bornhoft commented 2 weeks ago

Hi @odunbar, no worries at all. Thanks for the response!

After trying your first few suggestions, I rebuilt using your approach above directly. The only change I needed to make was to point the ENV[PYTHON]="<my conda python> to my specific conda python. This ended up working without issue.

The instructions I followed were found here. The ones you posted above are slightly different. Maybe this difference had something to do with it? Either way, I have successfully run the Sinusoid and Lorenz examples.

Thank you for the detailed assistance!