3. References¶
Image and Binary handlers. |
|
The Damona configuration |
3.1. admin module¶
3.2. builders module¶
3.3. common module¶
Image and Binary handlers. Provide also a Damona manager
- class BinaryReader(filename)[source]¶
Manage a single binary
>>> from damona.common import BinaryReader >>> br = BinaryReader("~/.config/damona/envs/base/bin/fastqc") >>> br.get_image() 'fastqc:0.11.9' >>> br.is_image_available() True
constructor
- Parameters:
filename (str) -- the input name of the binary file
Can be use to check whether the binary is not orphan and its image is still available.
- class Damona[source]¶
Global manager to get information about environments, binaries, images.
- property config_path¶
Get the Damona config file location
- damona_path¶
This attribute stored the path where images and environments are stored
- property environments_path¶
Get the Damona environments directory location
- find_orphan_binaries()[source]¶
Find binaries in all environments that are orphans
By orphans, we mean that their image is not present anymore for some reasons (e.g., users delete it manually).
- property images_directory¶
Get the Damona images directory location
- class DamonaInit[source]¶
Class to create images/bin directory for DAMONA
This is called each time damona is started to make sure the required config file are present.
This class simply create the ~/.config/damona/envs and images directories. It also checks whether DAMONA_PATH and DAMONA_SINGULARITY_OPTIONS variables are defined in the environment.
- SHELL_CONFIGS = {'bash': {'manual_cmd': 'echo "source ~/.config/damona/damona.sh" >> ~/.bashrc', 'rc_file': '~/.bashrc', 'source_line': 'source ~/.config/damona/damona.sh'}, 'fish': {'manual_cmd': 'echo "source ~/.config/damona/damona.fish" >> ~/.config/fish/config.fish', 'rc_file': '~/.config/fish/config.fish', 'source_line': 'source ~/.config/damona/damona.fish'}, 'zsh': {'manual_cmd': 'echo "source ~/.config/damona/damona.zsh" >> ~/.zshrc', 'rc_file': '~/.zshrc', 'source_line': 'source ~/.config/damona/damona.zsh'}}¶
- class ImageReader(name)[source]¶
Manage a single Singularity image
Constructor
- Parameters:
name -- the input name of the image (fullpath)
>>> from damona.common import ImageReader >>> ir = ImageReader("~/.config/damona/images/fastqc_0.11.9.img") >>> ir.md5 >>> ir.is_orphan() >>> ir.name >>> print(ir.shortname) 'fastqc_0.11.9.img' >>> print(ir.version) '0.11.9'
- delete()[source]¶
Delete the image file from disk if it is no longer used by any environment.
If the image is still referenced by at least one binary alias the deletion is skipped and a warning is logged instead.
- property guessed_executable¶
Guess the executable from the filename
- is_orphan()[source]¶
Return
Trueif no environment binary currently points to this image.An image is considered an orphan when it exists in the images directory but no binary alias in any environment references it.
- Returns:
Truewhen no binary uses this image,Falseotherwise.- Return type:
- property md5¶
compute and return the md5 of the file
- property shortname¶
Get the filename (NAME_X.Y.Z.img)
- property version¶
Get the version
- get_container_cmd()[source]¶
Return the available container command (
singularityorapptainer).singularityis preferred for backward compatibility. When onlyapptaineris present on the system that command is returned instead.- Returns:
"singularity"or"apptainer", orNonewhen neither is found.- Return type:
str or None
3.4. config module¶
The Damona configuration
- class Config(name='damona', urls={'damona': 'https://biomics.pasteur.fr/salsa/damona/registry.txt'})[source]¶
A place holder to store our configuration file and shell scripts
This class is called each time damona is started. The config file, if not present is created, otherwise nothing happens. Same for the bash and fish shell configuration files
The damona configuration file looks like:
[general] quiet=False [zenodo] token=APmm6p.... orcid=0000-0001 name='Cokelaer, Thomas' affiliation='Institut Pasteur' [sandbox.zenodo] token=FFmbAEhQbb... orcid=0000-0001 name='Cokelaer, Thomas' affiliation='Institut Pasteur'
Where the urls section can be used to store aliases to external registry. When installing software using:
damona install example --url damona
if the alias damona is in the [urls] section, it is replaced by its real value (https://...) the URL must end with the expected registry name registry.txt
The zenodo section is not save by default since it is for developpers only.
Constructor
Creates
~/.config/damona/damona.cfgand the shell initialisation scripts the first time it is called; subsequent calls are no-ops for files that already exist and are up-to-date.- Parameters:
- add_bash()[source]¶
Copy the Bash shell init script to the user config directory.
- Returns:
Trueif the file was created or updated,Falseotherwise.- Return type:
- add_fish()[source]¶
Copy the Fish shell init script to the user config directory.
- Returns:
Trueif the file was created or updated,Falseotherwise.- Return type: