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

Unable to Revise a package using ParallelStencil.jl #821

Closed
jdm204 opened this issue Jun 17, 2024 · 3 comments
Closed

Unable to Revise a package using ParallelStencil.jl #821

jdm204 opened this issue Jun 17, 2024 · 3 comments

Comments

@jdm204
Copy link

jdm204 commented Jun 17, 2024

Hi, Revise is brilliant. I've ran into an issue revising package code that uses ParallelStencil.

ParallelStencil provides macros such as @parallel to annotate functions with, but before these annotations can be used, an initialisation macro must be run first, so I have this at the top level of my package:

using ParallelStencil
@init_parallel_stencil(Threads, Float64, 3);

before including other files with @parallel calls.

My development workflow involves activiating MyPackage environment, using MyPackage, and then testing out bits of code in the REPL, editing the package, Revise reloads, back to the REPL, etc.

The problem is, this workflow breaks when using Revise and ParallelStencil in combination, as upon the first code change in the session (not necessarily to any ParallelStencil-involved code), Revise does its thing, but I get an error:

NotInitializedError: no ParallelStencil macro or function can be called before @init_parallel_stencil in each module (missing call in MyPackage)

That I didn't call the init macro, despite it appearing before any other ParallelStencil macros in my package.

CC @omlins who thought this might be a Revise issue

@timholy
Copy link
Owner

timholy commented Sep 24, 2024

This does seem like a Revise bug. Can you give me a MWE? I've not used ParallelStencil before.

@jdm204
Copy link
Author

jdm204 commented Sep 25, 2024

RepexRevisePStencil.tar.gz

I think the bug requires a nested file structure in a project.

To reproduce:

  • activate the environment
  • run using CancerCellModels
  • open the included file src/stencil_explicit.jl and insert 2 + 2 before the return statement
  • save the file
  • run 2 + 2 in the REPL

@timholy
Copy link
Owner

timholy commented Sep 26, 2024

This is not a Revise issue. Put @init_parallel_stencil(Threads, Float64, 3) into an __init__() function in CancerCellModels. xref omlins/ParallelStencil.jl#167

The fundamental issue is that a package's src/*.jl files are best thought of as build scripts, and precompilation stores a snapshot of the resulting module. But ParallelStencil maintains its own storage for all relevant settings (it's not local to the module being compiled). During precompilation of CancelCellModels, all the important settings get stored in ParallelStencil, but ParallelStencil is not the one being compiled so those settings are discarded when the process doing the precompilation of CancerCellModels shuts down. Thus, with the current design of ParallelStencil, you'll have to repeat that work when CancerCellModels first gets loaded, and that's the job of __init__.

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

2 participants