-
-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Loading BSON variable with unit #301
Comments
Could you try this and see if the error is still there? ### A Pluto.jl notebook ###
# v0.11.6
using Markdown
using InteractiveUtils
# ╔═╡ 665ea77a-e065-11ea-00f6-4bd4c96dd01e
begin
using Unitful, BSON
Core.eval(Main, :(using Unitful))
end
# ╔═╡ 343a3f00-e067-11ea-0087-578bfebddeb2
ufoo = 3.0u"m/s"
# ╔═╡ 4725579e-e067-11ea-0fee-dbf660902683
BSON.@save "test.bson" ufoo
# ╔═╡ 4f79588c-e067-11ea-13eb-3bf5069dbf64
function get_ufoo()
BSON.@load "test.bson" ufoo
return ufoo
end
# ╔═╡ 5a2ccdea-e067-11ea-0169-712307d8649d
ubaz = get_ufoo() # This throws with "Unitful not defined"
# ╔═╡ Cell order:
# ╠═665ea77a-e065-11ea-00f6-4bd4c96dd01e
# ╠═343a3f00-e067-11ea-0087-578bfebddeb2
# ╠═4725579e-e067-11ea-0fee-dbf660902683
# ╠═4f79588c-e067-11ea-13eb-3bf5069dbf64
# ╠═5a2ccdea-e067-11ea-0169-712307d8649d |
It looks like BSON.jl has the limitation that it needs packages to be defined in the Main scope - it does not work inside modules when using external packages: https://gist.github.com/fonsp/caef46b11c417014d0d1698b6b70607f#file-bsonunitful-jl https://gist.github.com/fonsp/caef46b11c417014d0d1698b6b70607f#file-bsonunitful2-jl
Pluto runs your code inside 'workspace modules' so the line |
I don't know how |
So this needs JuliaIO/BSON.jl#52 to be fixed |
Thanks @fonsp! Maybe it's worth mentioning that this can happen in the FAQ? (And include the |
No I think that this issue is a good enough resource on its own. But maybe I should start making a big list of packages and their workarounds... |
Another option is to detect that a goofy package is being used, and show the link to the workaround inside the editor |
I also encountered this problem recently, and yes the workaround with Just writing this here, because this issue was the first link when searching for this BSON related problem in conjunction with Pluto. |
Here is a MWE Pluto notebook
that throws
I'm not wure why, since this works perfectly outside of Pluto, and it also works when using BSON but not Unitful... What's happening here? (FWIW, 'm trying to use Pluto with some data I have stored in BSON files with units.)
The text was updated successfully, but these errors were encountered: