Configure a Project which should run on different machines

Hello, I have a basic question about the usage of activate projects in julia 1.0.

I have a git repository for my research where I have modules and scripts written in julia.

The tree looks somethin like this:

.
├── folder1
│   └── subfolder1
│       ├── script1.jl
│       └── script2.jl
└── Modules
    ├── Module1.jl
    └── Module2.jl

I write the code on two different machines and I also want to be able to run it on different machines. To have as little differences in julia on the different machines as possible I would like to use the same environment.

Now, my idea was to activate a project in the root folder and then add `Pkg.activate(“path/to/root”) in each script. (I run the scripts from different levels of the directory tree separately).

Is this the right way to go?

I usually have the following directory layout for research code:

.
|--- paper
|
|--- ... other languages, eg stata, R
|
|--- slides
|
|--- ...
|
|--- julia
     |
     |- Project.toml
     |- src/ProjectModule.jl
     |- test/...
     |- scripts/...
     ...

ie with a single module, which contains a

"""
    $SIGNATURES

Root path of the project. Useful for organizing results, plots, data, etc.
"""
project_path(parts...) = normpath(joinpath(@__DIR__, "..", parts...))

or similar for relative paths.

I only activate the ./julia/ directory for the project.

Having multiple modules is tricky AFAIK. I use submodules.

1 Like

You could also reorganize the module files into actual packages, i.e. run Julia in the Modules directory and do

(v1.0) pkg> generate Module1

and likewise for the other modules. Copy Module1.jl to Modules/Module1/src. Then run Julia from the root directory of the project,

(v1.0) pkg> activate .

and then

(root) pkg> dev Modules/Module1

The Manifest.toml will just store a relative path:

[[Module1]]
path = "Modules/Module1"
uuid = "98c17f10-c264-11e8-1c5a-bd2cf0ea0803"
version = "0.1.0"

making this approach portable.

Thanks for the suggestions. I will try out and look what fits best to my needs :wink: