LMODify: Create LMOD packages based on Singularity images for HPC environments
Project description
lmodify
A Python CLI tool for creating and managing LMOD modules from Singularity/Apptainer containers in HPC environments.
Features
- Automatic package name and version detection from Singularity image filenames
- Generate LMOD Lua module files
- Create wrapper scripts for containerized applications
- Manage multiple package versions
- Add commands to existing packages
- Interactive configuration setup
Installation
pip install -e .
For development:
pip install -e ".[dev]"
Quick Start
1. Initialize Configuration
First, create your configuration file:
lmodify init
This will prompt you for:
- Path to Singularity images
- Path for binary wrappers
- Path for LMOD Lua files
- Your metadata (name, email, organization)
The configuration is saved to ~/.config/lmodify.ini by default.
2. Create a Package
Create an LMOD module from a Singularity image:
lmodify create -s /path/to/seqfu__1.20.3.simg seqfu stats
This will:
- Parse the package name and version from the image filename
- Create a wrapper script in
{bin_path}/seqfu__1.20.3/singularity.exec - Create symlinks for the specified commands
- Generate an LMOD Lua file at
{lmod_path}/seqfu/1.20.3.lua
3. List Available Packages
View all available LMOD modules:
lmodify list
Filter by keyword:
lmodify list seqfu
Show only package names:
lmodify list -p
4. Add Commands to Existing Packages
Add a new command to an existing package:
lmodify add seqfu seqfu-stats
Add to a specific version:
lmodify add seqfu seqfu-stats --version 1.20.3
Supported Image Naming Patterns
lmodify automatically detects package names and versions from these patterns:
-
Galaxy Project depot pattern:
depot.galaxyproject.org-singularity-{name}-{version}--{build}.img depot.galaxyproject.org-singularity-kraken2-2.0.8_beta--pl526hc9558a2_2.img -
Colon pattern:
{name}:{version}--{build} checkv:1.0.3--pyhdfd78af_0 genomad:1.9.0--pyhdfd78af_1.simg -
Double underscore pattern:
{name}__{version}[.extension] seqfu__1.20.3 unicycler__0.5.1.simg
If automatic detection fails, you can specify manually:
lmodify create -s image.sif -p mypackage -v 1.0.0 mycommand
Commands
init
Create a configuration file with interactive prompts.
lmodify init [-o OUTPUT] [-f]
Options:
-o, --output: Output path for config file-f, --force: Overwrite existing config file
create
Create a new LMOD package from a Singularity image.
lmodify create [OPTIONS] [COMMANDS...]
Options:
-s, --singularity: Path to Singularity image (required)-p, --package: Package name (auto-detected if not provided)-v, --version: Package version (auto-detected if not provided)-l, --lmod-path: Override LMOD path from config-b, --bin-path: Override bin path from config-d, --description: Package description-C, --category: Package category (bio, chem, physics, tools, etc.)--force: Overwrite existing files--dry-run: Preview without making changes
list
List available LMOD packages.
lmodify list [KEYWORD] [-p]
Options:
KEYWORD: Filter packages (case-insensitive)-p, --packages-only: Show only package names, not versions-l, --lmod-path: Override LMOD path from config
add
Add a new command to an existing package.
lmodify add PACKAGE COMMAND [OPTIONS]
Options:
-v, --version: Add to specific version (default: all versions)-l, --lmod-path: Override LMOD path from config-b, --bin-path: Override bin path from config--force: Overwrite existing command--dry-run: Preview without making changes
Configuration File
Default location: ~/.config/lmodify.ini
[lmodify]
singularity_default_path = /opt/singularity
bin_path = /opt/bin
lmod_path = /opt/lmod
[metadata]
author = Your Name
email = your.email@example.com
organization = Your Organization
You can specify a custom config file with:
lmodify -c /path/to/config.ini <command>
How It Works
When you create a package, lmodify:
-
Creates a wrapper script (
singularity.exec) that executes commands inside the container:#!/bin/bash singularity exec "/path/to/image.simg" $(basename "$0") "$@"
-
Creates symlinks for each command pointing to the wrapper script:
seqfu -> singularity.exec stats -> singularity.exec
-
Generates an LMOD Lua module that adds the bin directory to PATH:
prepend_path("PATH", "/opt/bin/seqfu__1.20.3")
Users can then load the module:
module load seqfu/1.20.3
seqfu --version
Development
Run tests:
pytest
Run tests with coverage:
pytest --cov=lmodify
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lmodify-0.2.1.tar.gz.
File metadata
- Download URL: lmodify-0.2.1.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d1cac86bcdada6e452b07ab8fcb0d69c7b3dce49171a4ebd6f54ed34b10aecf
|
|
| MD5 |
51daf1fa5548bb27320cbd08a545cbc6
|
|
| BLAKE2b-256 |
e39c622f0246c9cea3466282cb71e95aa266d5f7a41b562cf1490e5182e45cbf
|
Provenance
The following attestation bundles were made for lmodify-0.2.1.tar.gz:
Publisher:
publish-pypi.yml on quadram-institute-bioscience/lmodify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lmodify-0.2.1.tar.gz -
Subject digest:
6d1cac86bcdada6e452b07ab8fcb0d69c7b3dce49171a4ebd6f54ed34b10aecf - Sigstore transparency entry: 667177878
- Sigstore integration time:
-
Permalink:
quadram-institute-bioscience/lmodify@84052d52201f5e5501fc6375db09936079e43657 -
Branch / Tag:
- Owner: https://github.com/quadram-institute-bioscience
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@84052d52201f5e5501fc6375db09936079e43657 -
Trigger Event:
release
-
Statement type:
File details
Details for the file lmodify-0.2.1-py3-none-any.whl.
File metadata
- Download URL: lmodify-0.2.1-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
090a542785f8693b3d4e589f39aa64016d43aacb3962a8a3dae4af5af624635e
|
|
| MD5 |
0df6e96a18ab2c2f2e1e5a28a3209878
|
|
| BLAKE2b-256 |
d3f9a2e2d7f24b1cc648aafa96744b9389f8bb90e5dd2a80e465fcc58f30c7da
|
Provenance
The following attestation bundles were made for lmodify-0.2.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on quadram-institute-bioscience/lmodify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lmodify-0.2.1-py3-none-any.whl -
Subject digest:
090a542785f8693b3d4e589f39aa64016d43aacb3962a8a3dae4af5af624635e - Sigstore transparency entry: 667177903
- Sigstore integration time:
-
Permalink:
quadram-institute-bioscience/lmodify@84052d52201f5e5501fc6375db09936079e43657 -
Branch / Tag:
- Owner: https://github.com/quadram-institute-bioscience
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@84052d52201f5e5501fc6375db09936079e43657 -
Trigger Event:
release
-
Statement type: