Skip to content

Commit 304bf83

Browse files
committed
Add documentation for the importer plugin mechanism
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
1 parent 0d1cc41 commit 304bf83

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

importers/README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Pyxis Importer Plugin
2+
3+
Pyxis supports an importer plugin mechanism to fetch squashfs files for container images. This
4+
mechanism allows administrators to customize how Docker images are imported, enabling features like
5+
caching, optimized storage, or integration with custom image registries.
6+
7+
## Configuration
8+
9+
To enable an importer plugin, configure pyxis with the `importer=` option in `plugstack.conf`:
10+
11+
```
12+
required pyxis.so importer=/path/to/importer/script.sh
13+
```
14+
15+
When an importer is configured, pyxis will use it instead of the built-in `enroot import` (or `enroot load`).
16+
17+
## Plugin Interface
18+
19+
An importer plugin is an executable that implements two operations: `get` and `release`.
20+
21+
### `get` Operation
22+
23+
The `get` operation is called to fetch a Docker image and produce a squashfs file.
24+
25+
**Usage:**
26+
```bash
27+
importer get IMAGE_URI
28+
```
29+
30+
**Arguments:**
31+
* `IMAGE_URI`: The image to fetch, in enroot URI format (e.g., `docker://ubuntu:24.04`)
32+
33+
**Output:**
34+
The plugin must write the absolute path to the squashfs file on stdout. Any progress messages or
35+
diagnostic output should be written to stderr. If the importer terminates with a non-zero exit code,
36+
pyxis will print the stderr log of the importer.
37+
38+
**Environment:**
39+
The plugin runs with the same environment variables available to enroot, plus:
40+
* `PYXIS_RUNTIME_PATH`: The `runtime_path` configured for pyxis
41+
* `PYXIS_VERSION`: The version of pyxis
42+
* Standard Slurm environment variables (`SLURM_JOB_UID`, `SLURM_JOB_ID`, `SLURM_STEP_ID`, etc.)
43+
44+
### `release` Operation
45+
46+
The `release` operation is called to clean up resources associated with the squashfs file.
47+
48+
**Usage:**
49+
```bash
50+
importer release
51+
```
52+
53+
**Important:** To handle cases where the job step receives `SIGKILL`. The `release` operation is often called **twice** during the lifecycle of a job:
54+
1. Once after the container is created
55+
2. Once during task cleanup
56+
57+
Implementations must be idempotent and handle being called multiple times safely. The plugin should not fail if resources have already been cleaned up.
58+
59+
**Environment:**
60+
The same environment variables as the `get` operation are available. The plugin should use these
61+
variables (e.g. `SLURM_JOB_ID` and `SLURM_STEP_ID`) to identify which resources to release.
62+
63+
## Example Implementations
64+
65+
Two example importer scripts are provided in this directory:
66+
67+
### `simple_importer.sh`
68+
69+
A straightforward implementation, similar to what pyxis is doing natively:
70+
* Uses `enroot import` to fetch images into a per-job squashfs file
71+
* Stores files in `${PYXIS_RUNTIME_PATH}/${SLURM_JOB_UID}/${SLURM_JOB_ID}.${SLURM_STEP_ID}.squashfs`
72+
* Removes the squashfs file on `release`
73+
74+
This implementation is suitable for basic use cases where each job gets its own image copy.
75+
76+
### `caching_importer.sh`
77+
78+
An example of a more advanced implementation that:
79+
* Uses image digests to enable sharing of squashfs files across jobs
80+
* Caches imported images in `/tmp/pyxis-cache-${SLURM_JOB_UID}` by digest
81+
* Enables squashfs compression (`zstd`) since cached files are long-lived
82+
* Only removes temporary files on `release`, keeping the cache intact for reuse
83+
84+
This implementation could be suitable for environments where multiple jobs use the same container
85+
images, as it avoids redundant downloads and storage. It does not handle locking of the cache
86+
directory so it might not be suitable for all filesystems.

0 commit comments

Comments
 (0)