DrWatson Common Code as Module Issue

TI36XPro
Wed, 05 Jun 2024 02:31:00 +0000
General Usage

Hello,

I am trying to use the functionality of DrWatson described here. But I can’t get it to work.

Here is what I have. I’ve got a very basic project that looks like this.

./
../
.git/
.gitignore
Manifest.toml
Project.toml
README.md
analysis1/
analysis2/
main.jl
src/

Here are the packages I am using. I am also using Julia 1.10. My project environment is called MyProject. I’m doing all my coding via the Julia extension in VSCode.

[13f3f980] CairoMakie v0.11.4
[634d3b9d] DrWatson v2.15.0
[f67ccb44] HDF5 v0.17.2
[a7d1346e] MyLocalPackage v0.4.0 `src/MyLocalPackage.jl`
[189a3867] Reexport v1.2.2

I have some common code defined in files within src/ I’d like to have run at the beginning of each analysis. So I’d like to put that into a module. I could of course just do

begin
    includet(srcdir("helpers1.jl"))
    includet(srcdir("helpers2.jl"))
end

But I’d rather take advantage of DrWatson to the fullest extent possible.

So following the example from the link above, inside src/ I’ve created a file called MyProject.jl and it contains the following.

module MyProject

using Reexport
@reexport using HDF5, MyLocalPackage, CairoMakie

export helper1, helper2, helper3, helper4

include(srcdir("helpers1.jl"))
include(srcdir("helpers2.jl"))

end # module

Then I try to use this in the manner shown in the DrWatson pages like so.

# analysis1/analysis1.jl
using DrWatson
@quickactivate :MyProject

# more code here...

When I do shift+enter in VScode to evaluate the second line I get the following error.

ERROR: ArgumentError: Package MyProject not found in current path.

Has anyone gotten this to work? Could it be something wrong with VSCode? Any suggestions?

12 posts - 4 participants