Skip to content

Conversation

@dahong67
Copy link
Owner

To resolve errors where BSON doesn't manage to reconstruct the DateTime.

To resolve errors where BSON doesn't manage to reconstruct the DateTime.
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4d8de84) to head (6a699bb).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #31   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           57        57           
=========================================
  Hits            57        57           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dahong67
Copy link
Owner Author

dahong67 commented Jan 19, 2026

In particular, observed the following behavior on CacheVariables v0.2.0:

(jl_gaMG15) pkg> st
Status `/private/var/folders/h_/3320nshd7t1bzbtcrj023bkr0000gn/T/jl_gaMG15/Project.toml`
  [9a355d7c] CacheVariables v0.2.0

julia> using CacheVariables

julia> cache("test.bson") do
           a = "a very time-consuming quantity to compute"
           b = "a very long simulation to run"
           return (; a = a, b = b)
       end
┌ Info: Saved cached values to test.bson.
│   Run Timestamp : 2026-01-19T14:59:26.331 UTC (run took 0.003582958 sec)
└   Julia Version : 1.12.4
(a = "a very time-consuming quantity to compute", b = "a very long simulation to run")

julia> cache("test.bson") do
           a = "a very time-consuming quantity to compute"
           b = "a very long simulation to run"
           return (; a = a, b = b)
       end
ERROR: UndefVarError: `Dates` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Hint: Dates is loaded but not imported in the active module Main.
Stacktrace:
[...]

Related to: #28

I think the issue here may be that Dates has been loaded in CacheVariables but that's (probably?) not the right module if we want things like #28 (i.e., DataFrames in Pluto) to work. Not sure... Tried a few fixes but didn't get something to work.

Anyway, the simple fix is probably to just store the date as a string in BSON.

@dahong67
Copy link
Owner Author

Notably, JLD2 seems to work fine! So, no need to switch to strings for that one.

julia> cache("test.jld2") do
           a = "a very time-consuming quantity to compute"
           b = "a very long simulation to run"
           return (; a = a, b = b)
       end
┌ Info: Saved cached values to test.jld2.
│   Run Timestamp : 2026-01-19T15:04:01.087 UTC (run took 0.007473458 sec)
└   Julia Version : 1.12.4
(a = "a very time-consuming quantity to compute", b = "a very long simulation to run")

julia> cache("test.jld2") do
           a = "a very time-consuming quantity to compute"
           b = "a very long simulation to run"
           return (; a = a, b = b)
       end
┌ Info: Loaded cached values from test.jld2.
│   Run Timestamp : 2026-01-19T15:04:01.087 UTC (run took 0.007473458 sec)
└   Julia Version : 1.12.4
(a = "a very time-consuming quantity to compute", b = "a very long simulation to run")

Once I've gotten to play around with JLD2 to get some more confidence in it, I think we should probably switch all the examples to use that (i.e., encourage that as the default rather than BSON).

@dahong67 dahong67 merged commit f4d8fc6 into master Jan 19, 2026
9 checks passed
@dahong67 dahong67 deleted the bson-dates branch January 19, 2026 15:19
@dahong67 dahong67 changed the title Save timestamp as string for BSON Fix BSON load error by saving timestamp as string Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants