Skip to content

Commit 67289f7

Browse files
jaantollanderJaan Tollander de Balschjoonas-somerorkronberg
authored
Improved Julia documentation (#1705)
* multinode multi process and hybrid jobs * julia minor and major version, fixes * activate project when spawning new worker process * improved threads code, restructuring * improved description, web interface * restructuring titles * restructuring * improvements * added julia tutorial to list, title and description * moved pkg.instantiate to batch scripts * restructuring * improvement * fix * Fixed misspelling of 'everywhere' * added julia web interface documentation * grammar * refactoring, julia on lumi available * refactoring, LUMI examples * changed gpu example * single node mahti example using interactive partition * fixed typo * improvements * threading, mkl, linear algebra * glossary, grammar * glossary * fixed sbatch option --------- Co-authored-by: Jaan Tollander de Balsch <jaan.tollander.de.balsch@csc.fi> Co-authored-by: Joonas Somero <joonas.somero@csc.fi> Co-authored-by: Rasmus Kronberg <43936697+rkronberg@users.noreply.github.com> Co-authored-by: Joonas Somero <50655931+joonas-somero@users.noreply.github.com>
1 parent 49767ad commit 67289f7

File tree

3 files changed

+693
-376
lines changed

3 files changed

+693
-376
lines changed

csc-overrides/assets/glossaries/hpc.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@
5252
*[HTTP]: Hypertext Transfer Protocol
5353
*[HTTPS]: Hypertext Transfer Protocol Secure
5454
*[SQL]: Structured Query Language
55+
*[REPL]: Read–Eval–Print Loop
5556
*[GCD]: Graphics Compute Die
56-
*[PME]: Particle-Mesh Ewald
57+
*[PME]: Particle-Mesh Ewald

docs/apps/julia.md

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
22
tags:
33
- Free
44
---
@@ -16,7 +16,15 @@ Julia language is licensed under free and open source [MIT license](https://gith
1616

1717

1818
## Available
19-
Julia language is available on Puhti and Mahti using the [module system](../computing/modules.md).
19+
Julia language is available on Puhti, Mahti, and LUMI using the [module system](../computing/modules.md).
20+
On Puhti and Mahti, the Julia module is included on the module path by default.
21+
On LUMI, we must add the module files under CSC's local directory to the module path as follows.
22+
23+
```bash
24+
module use /appl/local/csc/modulefiles
25+
```
26+
27+
We can check the available versions as follows.
2028

2129
```bash
2230
module avail julia
@@ -55,31 +63,56 @@ Julia's REPL and Pkg, the package manager, are two important packages within the
5563
The [Pkg documentation](https://pkgdocs.julialang.org/) provides more information on how to use Julia's package manager.
5664

5765

66+
### More information
67+
We can print details about paths and environment variables set by the Julia module as follows.
68+
69+
```bash
70+
module show julia
71+
```
72+
73+
We can also print useful information about the Julia version, platform and environment in the REPL as follows.
74+
75+
```julia
76+
using InteractiveUtils # automatically load in the REPL
77+
versioninfo()
78+
```
79+
80+
5881
### Using environments
5982
Julia manages dependencies of projects using environments.
6083
An environment consists of two files, `Project.toml` and `Manifest.toml`, which specify dependencies for the environment.
61-
We define project metadata, dependencies, and compatibility constraints in `Project.toml` file.
84+
We define project metadata, dependencies, and compatibility constraints in the `Project.toml` file.
6285
Adding or removing packages using the package manager manipulates the `Project.toml` file in the active environment.
63-
Furthermore, the package manager maintains a full list of dependencies in `Manifest.toml` file.
86+
Furthermore, the package manager maintains a full list of dependencies in the `Manifest.toml` file.
6487
It creates both of these files if they don't exist.
6588
Let's consider a Julia project structured as follows.
6689

6790
```
68-
project
91+
project/
6992
├── script.jl
7093
├── Project.toml
7194
└── Manifest.toml
7295
```
7396

74-
We can activate an environment using the `--project` option when starting Julia or use the `Pkg.activate` function in existing Julia session.
97+
We can activate an environment using the `--project` option when starting Julia or use the `Pkg.activate` function in the existing Julia session.
7598
For example, we can open the Julia REPL with the project's environment active as follows:
7699

77100
```bash
78101
julia --project=.
79102
```
80103

104+
We can call the `Base.active_project()` function to retrieve a path to the active project, that is, `Project.toml` file.
105+
81106
Activating an environment does not automatically install the packages defined by `Manifest.toml` or `Project.toml`.
82-
For that, we need to invoke the `Pkg.instantiate` function with the project's environment active as follows:
107+
For that, we need to instantiate the project as follows:
108+
109+
```julia
110+
using Pkg
111+
Pkg.activate(".")
112+
Pkg.instantiate()
113+
```
114+
115+
Alternatively, we can use the following one-liner:
83116

84117
```bash
85118
julia --project=. -e 'using Pkg; Pkg.instantiate()'
@@ -92,7 +125,7 @@ julia --project=. script.jl
92125
```
93126

94127
Julia will activate the default environment if we don't specify an environment.
95-
We should always use a unique environment for Julia projects instead of the default environment.
128+
Preferably, we should use a unique environment for Julia projects instead of the default environment.
96129
That way, we can manage the dependencies of different Julia projects separately.
97130

98131

@@ -103,8 +136,14 @@ On the Julia REPL, we can use the package manager by importing it.
103136
using Pkg
104137
```
105138

139+
We can activate a Julia environment on the current working directory as follows.
140+
141+
```julia
142+
Pkg.activate(".")
143+
```
144+
106145
We can add packages to the active environment using the `Pkg.add` function.
107-
For example, we can add `ArgParse` package as follows.
146+
For example, we can add the `ArgParse` package as follows.
108147

109148
```julia
110149
Pkg.add("ArgParse")
@@ -124,34 +163,35 @@ Pkg.compat("julia", "1.8")
124163
```
125164

126165

127-
### Depot and load paths
166+
### Code loading and the shared environment
128167
The Julia constants [`Base.DEPOT_PATH`](https://docs.julialang.org/en/v1/base/constants/#Base.DEPOT_PATH) and [`Base.LOAD_PATH`](https://docs.julialang.org/en/v1/base/constants/#Base.LOAD_PATH) constants control the directories where Julia loads code.
129168
To set them via the shell, we use the `JULIA_DEPOT_PATH` and `JULIA_LOAD_PATH` environment variables.
169+
We can call the `Base.load_path()` function to retrieve the expanded load path.
130170
The Julia module automatically appends the default depot and load paths to ensure the standard library and shared depots are available.
131-
The CSC-specific shared depots are installed in the `JULIA_CSC_DEPOT` directory, and the shared environment is in the `JULIA_CSC_ENVIRONMENT` directory.
132-
We can look up the shared packages and their versions using the package manager as follows:
171+
172+
The first directory on the depot path controls where Julia stores installed packages, compiled files, log files, and other depots.
173+
We can change the directory by prepending the `JULIA_DEPOT_PATH` with a different directory.
174+
For example, we can use the following by replacing the `<project>` with your CSC project.
133175

134176
```bash
135-
julia --project="$JULIA_CSC_ENVIRONMENT" -e 'using Pkg; Pkg.status()'
177+
export JULIA_DEPOT_PATH="/projappl/<project>/$USER/.julia:$JULIA_DEPOT_PATH"
136178
```
137179

138-
The first directory on the depot path controls where Julia stores installed packages, compiled files, log files, and other depots.
139-
140-
!!! warning "Changing the default depot directory"
141-
The default depot directory is `$HOME/.julia`.
180+
!!! warning "Changing the default depot directory."
181+
By default, the first depot directory in the depot path is `$HOME/.julia`.
142182
However, the home directory has a fixed quota for Puhti and Mahti.
143-
Therefore, we recommend changing the directory to a directory under Projappl or Scratch to avoid running out of quota because some packages install a large amounts of files.
144-
Afterwards, you can safely remove the default depot directory using `rm -r $HOME/.julia`.
183+
Therefore, we recommend changing the directory to a directory under Projappl or Scratch to avoid running out of quota because some packages install a large number of files.
184+
Afterward, you can safely remove the default depot directory using `rm -r $HOME/.julia`.
145185

146-
We can change the directory by prepending the `JULIA_DEPOT_PATH` with a different directory.
147-
For example, we can use the following by replacing the `<project>` with your CSC project.
186+
The CSC-specific shared depots are installed in the `CSC_JULIA_DEPOT_DIR` directory, and the shared environment is in the `CSC_JULIA_ENVIRONMENT_DIR` directory.
187+
We can look up the shared packages and their versions using the package manager as follows:
148188

149189
```bash
150-
export JULIA_DEPOT_PATH="/projappl/<project>/$USER/.julia:$JULIA_DEPOT_PATH"
190+
julia --project="$CSC_JULIA_ENVIRONMENT_DIR" -e 'using Pkg; Pkg.status()'
151191
```
152192

153193

154-
### Creating a package with command line interface
194+
### Creating a package with a command line interface
155195
We should package the code as a code base grows instead of running standalone scripts.
156196
A Julia package includes a module file, such as `src/Hello.jl`, and the `Project.toml` file.
157197
Including a command line interface in your program, such as `src/cli.jl`, is also wise.
@@ -195,7 +235,7 @@ export say
195235
end
196236
```
197237

198-
We can use `ArgParse` package to create a command line interface `src/cli.jl` for the package.
238+
We can use the `ArgParse` package to create a command line interface `src/cli.jl` for the package.
199239
For example, the command line interface below defines an option `--say` whose value is parsed into a string and supplied to the `say` function imported from the `Hello` module.
200240

201241
```julia
@@ -221,8 +261,8 @@ julia --project=. src/cli.jl --say "Hello world"
221261
We should define and use a command line interface because it is more flexible than hard-coding values to the scripts.
222262

223263

224-
### Running Julia jobs on Puhti and Mahti
225-
We explain how to run serial, parallel and GPU jobs with Julia on Puhti and Mahti in the [**Running Julia jobs on Puhti and Mahti clusters**](../support/tutorials/julia.md) section.
264+
### Running Julia jobs on Puhti, Mahti, and LUMI clusters
265+
We explain how to run serial, parallel, and GPU jobs with Julia on Puhti, Mahti, and LUMI in the [**Running Julia jobs on Puhti, Mahti, and LUMI clusters**](../support/tutorials/julia.md) tutorial.
226266

227267

228268
### Using Julia on Jupyter and VSCode

0 commit comments

Comments
 (0)