Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should a Julia project have a Manifest AND Project file?

Tags:

julia

I am trying to understand when a Julia Project needs a Manifest AND Project file vs when it just needs a project file. What are the different situations that warrant each case? I am trying to make sure my own project is set up correctly(It has both files currently).

like image 207
logankilpatrick Avatar asked Nov 22 '19 14:11

logankilpatrick


People also ask

What is manifest toml?

toml. The manifest file is an absolute record of the state of the packages in the environment. It includes exact information about (direct and indirect) dependencies of the project.

How do I start a project in Julia?

Activating a Project Environment when starting Julia Once you have setup your project environment, you can start coding. I usually start my workflow from the Bash terminal. I go to the project directory and start Julia with julia --project=. to activate the project environment as specified in the files Project.

Where does Julia Look for packages?

Your package requirements are in the file ~/. julia/v0.


2 Answers

The Manifest.toml is a snapshot of the exact state of a Julia environment. It specifies all packages that are installed in the environment with version numbers - not just the ones that have been ] added but the entire dependency graph!

The Project.toml on the other hand just lists the direct dependencies, that is the packages that have been ] added explicitly, potentially with version bounds specified in a [compat] section.

By checking in both files (specifically the Manifest.toml), you make your project reproducible. Another user only has to ] instantiate and will have the exact same environment that you had when working on the project. This is great for application projects which might consist of multiple Julia scripts which are not intended for use by other Julia projects.

If you only check in the Project.toml you are specifying the dependency information more loosely and will leave room for Julias resolver to find appropriate package versions for all dependencies. This is what you should do when working on a Julia package since people will likely want to install your package next to other packages and overly restricting versions of dependencies will make your package incompatible.

Hence, I'd summarize as follows:

Application / "Project" -> Project.toml + Manifest.toml

Julia Package -> Only Project.toml

For more on applications and packages checkout the glossary of the Pkg.jl documentation.

(Not that there are exceptional cases (unregistered dependencies, for example) where you might have to check in a Manifest.toml for a Julia package.)

like image 167
carstenbauer Avatar answered Oct 02 '22 14:10

carstenbauer


In Julia 1.2 and above, you can have nested Project.toml files to express test-specific dependencies. Since you may have a Project.toml in your test folder, which you would need to activate, I would also suggest including a Manifest.toml, as a record of under which environment you for-sure know your package's test are passing.

In other words, I believe in the package/application dichotomy mentioned in crstnbr's answer, and the recommendation to include Manifest.toml with applications, and I would further say that the tests within a package are like an application. The same goes for performance benchmarks that you might have in your package.

I haven't practiced this myself, but it seems like it would be nice to have the CI tests run under both the "frozen" version of the test/Manifest.toml, and the latest versions that the package manager can find of each package. If the tests start failing, it would be easier to tease apart whether the breakage is caused by a change in a dependency.

like image 20
Gus Avatar answered Oct 02 '22 12:10

Gus