Project management for a julia project

I wanted to know the correct way to run the tests and benchmarks included in a julia project. Specifically, I’m looking at this project. It includes some tests and benchmarks, but I can’t find any online resources regarding project management for julia projects.
Is there something equivalent to cargo for julia?

Package and project management in Julia are provided by the built-in Pkg tool. You can read all about Pkg in the manual here: 1. Introduction · Pkg.jl

For example, if you want to create a brand-new project, install the FunctionalCollections package within that project, and run its tests, you could do the following:

  1. create a new folder and cd into it
  2. Start julia, and run:
(v1.1) pkg> activate .

Note that I have pressed the ] key to switch the prompt from julia> to (v1.1) pkg> and thus entered “package mode”.

activate . tells Julia to use the project in your current directory. There’s nothing there yet, but that’s OK.

Next, you can do:

(project) pkg> add FunctionalCollections

which will do the following:

  • Download FunctionalCollections (and its deps)
  • Create Manifest.toml and Project.toml files which describe your current project and its packages

Then you can test the package with:

(project) pkg> test FunctionalCollections

All of this will happen only within your current package environment, so any packages you install here won’t affect any other projects you’re currently working on.

3 Likes

Thanks for reply. What about benchmarks? This project seems to use Benchmark package but it appears to be deprecated. The Pkg.jl documentation doesn’t say anything about benchmarks. Is the user expected to just setup the LOAD_PATH and include the respective benchmark sources?

I think you should look at BenchmarkTools GitHub - JuliaCI/BenchmarkTools.jl: A benchmarking framework for the Julia language

Manual here https://github.com/JuliaCI/BenchmarkTools.jl/blob/master/doc/manual.md

ALso - Sagar, if you are new to Julia we are all really friendly here. Keep on asking question. I do!

2 Likes

Thanks a lot.

Pkg itself doesn’t know about benchmark suites, but you can at least look up the correct path to the benchmark script. using FunctionalCollections; pathof(FunctionalCollections) will give you the path to the source file for that module, so you can automatically include the benchmark file (no matter where the package happens to be installed) with:

julia> include(joinpath(dirname(pathof(FunctionalCollections)), "..", "benchmark", "bench.jl"))

although, as you noted, that particular package happens to rely on the out-dated Benchmark.jl package. I’d suggest using BenchmarkTools.jl instead, since it’s nicer and actively maintained.