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

PlutoDependencyExplorer not understanding importing local modules #25

Open
MasonProtter opened this issue Nov 7, 2024 · 6 comments
Open
Labels
good first issue Good for newcomers

Comments

@MasonProtter
Copy link

Here's an MWE:

using PlutoDependencyExplorer
const PDE = PlutoDependencyExplorer;
struct SimpleCell <: PDE.AbstractCell
    code
end
julia> let notebook = SimpleCell.(["mod = expr", "using .mod"])
               empty_topology = PDE.NotebookTopology{SimpleCell}();
               topology = PDE.updated_topology(
                  empty_topology,
                  notebook, notebook;
                  get_code_str = c -> c.code,
                  get_code_expr = c -> Meta.parse(c.code))
               order = PDE.topological_order(topology);
               order.runnable
       end
SimpleCell[]

Ideally this should return

2-element Vector{SimpleCell}:
 SimpleCell("mod = expr")
 SimpleCell("using .mod")

This is manifesting in errors in Pluto when I try to import a locally defined module.

@fonsp
Copy link
Member

fonsp commented Nov 8, 2024

Thanks! Is this also an issue in Pluto?

@fonsp
Copy link
Member

fonsp commented Nov 8, 2024

julia> order.errable
Dict{SimpleCell, PlutoDependencyExplorer.ReactivityError} with 2 entries:
  SimpleCell("using .mod") => MultipleDefinitionsError(Set([:mod]))
  SimpleCell("mod = expr") => MultipleDefinitionsError(Set([:mod]))

@MasonProtter
Copy link
Author

MasonProtter commented Nov 8, 2024

Ah right, sorry I should have given the example without the name clashes:

julia> let notebook = SimpleCell.(["mod = expr", "using .mod: x"])
               empty_topology = PDE.NotebookTopology{SimpleCell}();
               topology = PDE.updated_topology(
                  empty_topology,
                  notebook, notebook;
                  get_code_str = c -> c.code,
                  get_code_expr = c -> Meta.parse(c.code))
               order = PDE.topological_order(topology);
               order.runnable
       end
2-element Vector{SimpleCell}:
 SimpleCell("using .mod: x")
 SimpleCell("mod = expr")

This makes it so that Pluto tries to import x from .mod before the module mod is defined. I suspect this is because Pluto wants to put all using statements first, but here it's apparently not realizing that the module needs to be defined before it can be used.

And yes, this is also an issue in Pluto, I just figured that since it was due to the dependancy tracker, that I should open the issue here, but I can move the issue there if you prefer.

@fonsp
Copy link
Member

fonsp commented Nov 8, 2024

I think that mod should be seen as a reference of import .mod, it's currently not detected:

Image

@fonsp fonsp added the good first issue Good for newcomers label Nov 8, 2024
@fonsp
Copy link
Member

fonsp commented Nov 8, 2024

(This is an issue with ExpressionExplorer)

@fonsp fonsp transferred this issue from JuliaPluto/PlutoDependencyExplorer.jl Nov 8, 2024
@fonsp
Copy link
Member

fonsp commented Nov 8, 2024

Let's implement it, and see if it breaks anything :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants