Skip to content
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

Method definition doesn't work in Pluto #1769

Closed
aplavin opened this issue Dec 19, 2021 · 10 comments
Closed

Method definition doesn't work in Pluto #1769

aplavin opened this issue Dec 19, 2021 · 10 comments

Comments

@aplavin
Copy link
Contributor

aplavin commented Dec 19, 2021

I'm trying to define a simple Table in Pluto, but it doesn't fully work:
image
Specifically, the Tables.columnaccess(::S) = true part: following the traceback, I see that the check at https://github.com/JuliaData/Tables.jl/blob/main/src/fallbacks.jl#L87 fails. Strangely, calling Tables.columnaccess(S()) is a Pluto cell correctly returns true.

Of course, everything is fine when I paste the same code into the regular Julia REPL:

Copy-pasted from notebook directly
julia> # ╔═╡ a82179a6-fcf5-4a95-9b11-e4e339b797ae
       using Tables

julia> # ╔═╡ 2b598cdf-9ffc-4757-a9ac-d30d23ce9eae


       # ╔═╡ 55cc8eb7-fd31-4950-bc24-8497043b0a4e
       struct S end

julia> # ╔═╡ 12587f04-d10d-466d-b7ac-98c29f32d75b
       Tables.istable(::S) = true

julia> # ╔═╡ 1375294c-ef18-4b5b-8828-bea28e1aa62c
       Tables.columnaccess(::S) = true

julia> # ╔═╡ 0d2b9f4d-0b82-464e-a343-1bfb26c8bf54
       Tables.columns(::S) = (a=rand(10),)

julia> # ╔═╡ c19ae837-47c0-493b-9441-3f6115a2be41


       # ╔═╡ 53e951f6-422e-4059-be7d-6321bd4e07d9
       columntable(S())
(a = [0.3178549471518519, 0.38500468343422634, 0.02408450590669209, 0.4329608204858352, 0.3292489991779296, 0.8779441338049941, 0.30372894506202464, 0.4989385634139504, 0.22188677189857553, 0.21967207407765788],)

julia> # ╔═╡ b1d60973-87b6-450b-a9a9-760b88e9dd45
       rowtable(S())
10-element Vector{NamedTuple{(:a,), Tuple{Float64}}}:
 (a = 0.13645275325585793,)
 (a = 0.07176155300992748,)
 (a = 0.9315739873393201,)
 (a = 0.8553309756585938,)
 (a = 0.16682906014240262,)
 (a = 0.4823154984291812,)
 (a = 0.15996004969244848,)
 (a = 0.5992253264750519,)
 (a = 0.5741887343881732,)
 (a = 0.36447483931345437,)

Not sure how to debug this Pluto issue further.

Notebook gist and binder

@fonsp
Copy link
Owner

fonsp commented Dec 22, 2021

I have no clue why this is happening 😳 maybe it's a world age problem...

@dralletje
Copy link
Collaborator

Works for me.. think Pluto runs the rowtable(S()) cell before it runs Table.columnaccess() = true.
Try re-running the last cell.

A solution, though not pretty, it putting struct S ... end and the method definitions in one cell :/

image

@Pangoraw how hard would it be to make Pluto prioritise method definitions even if we don't see a cell depending on it directly? This would also fix a lot of my No Base.show for XXX errors 😅

@Pangoraw
Copy link
Collaborator

I was not able to make it work 😬 @dralletje it works on the first run for you ?

image

@dralletje
Copy link
Collaborator

Noooo sorry, it specifically didn't run for me on first run either.

@Pangoraw

This comment has been minimized.

@fonsp
Copy link
Owner

fonsp commented Dec 22, 2021

To be clear, does it work if everything is in one big cell?

@Pangoraw
Copy link
Collaborator

It does not work even when everything is in one cell

image

@Pangoraw
Copy link
Collaborator

Ok, i found the issue which is the difference with the Tables.jl version (0.16.0 in the notebook) and the released version which is 0.16.1.

You either need to set

Tables.columnaccess(::Type{S}) = true

or update Tables.jl

on the left (0.16.1), on the right (0.16.0)
image

@Pangoraw
Copy link
Collaborator

There is however a real issue with tracking reactive dependencies between columnaccess() and rowtable() but we can open a fresh issue for that or use #326.

@fonsp
Copy link
Owner

fonsp commented Dec 22, 2021

Woah amazing Paul!

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

No branches or pull requests

4 participants