Warning

This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

galaxy.tool_util.deps package

Dependency management for tools.

galaxy.tool_util.deps.build_dependency_manager(app_config_dict: Dict[str, Any] | None = None, resolution_config_dict: Dict[str, Any] | None = None, conf_file: str | None = None, default_tool_dependency_dir: str | None = None) DependencyManager[source]

Build a DependencyManager object from app and/or resolution config.

If app_config_dict is specified, it should be application configuration information and configuration options are generally named to identify the context of dependency management (e.g. conda_prefix not prefix or use_cached_dependency_manager not cache). resolution_config_dict if specified is assumed to be the to_dict() version of a DependencyManager and should only contain dependency configuration options.

class galaxy.tool_util.deps.DependencyManager(default_base_path: str, conf_file: str | None = None, app_config: Dict[str, Any] | None = None)[source]

Bases: object

A DependencyManager attempts to resolve named and versioned dependencies by searching for them under a list of directories. Directories should be of the form:

$BASE/name/version/…

and should each contain a file ‘env.sh’ which can be sourced to make the dependency available in the current shell environment.

cached = False
__init__(default_base_path: str, conf_file: str | None = None, app_config: Dict[str, Any] | None = None) None[source]

Create a new dependency manager looking for packages under the paths listed in base_paths. The default base path is app.config.tool_dependency_dir.

set_enabled_container_types(container_types_to_destinations)[source]

Set the union of all enabled container types.

get_destination_info_for_container_type(container_type, destination_id=None)[source]
property enabled_container_types

Returns the union of enabled container types.

get_resolver_option(resolver, key, explicit_resolver_options=None)[source]

Look in resolver-specific settings for option and then fallback to global settings.

get_app_option(key, default=None)[source]
property precache
dependency_shell_commands(requirements: ToolRequirements, **kwds: Any) List[str][source]
requirements_to_dependencies(requirements, **kwds)[source]

Takes a list of requirements and returns a dictionary with requirements as key and dependencies as value caching these on the tool instance if supplied.

uses_tool_shed_dependencies()[source]
find_dep(name: str, version: str | None = None, type: str = 'package', **kwds)[source]
to_dict()[source]
class galaxy.tool_util.deps.CachedDependencyManager(default_base_path, **kwd)[source]

Bases: DependencyManager

cached = True
__init__(default_base_path, **kwd)[source]

Create a new dependency manager looking for packages under the paths listed in base_paths. The default base path is app.config.tool_dependency_dir.

build_cache(requirements, **kwds)[source]
dependency_shell_commands(requirements, **kwds)[source]

Runs a set of requirements through the dependency resolvers and returns a list of commands required to activate the dependencies. If dependencies are cacheable and the cache does not exist, will try to create it. If cached environment exists or is successfully created, will generate commands to activate it.

hash_dependencies(resolved_dependencies)[source]

Return hash for dependencies

get_hashed_dependencies_path(resolved_dependencies)[source]

Returns the path to the hashed dependencies directory (but does not evaluate whether the path exists).

Parameters:

resolved_dependencies (list) – list of resolved dependencies

Returns:

path

Return type:

str

class galaxy.tool_util.deps.NullDependencyManager(default_base_path=None, conf_file=None, app_config=None)[source]

Bases: DependencyManager

cached = False
__init__(default_base_path=None, conf_file=None, app_config=None)[source]

Create a new dependency manager looking for packages under the paths listed in base_paths. The default base path is app.config.tool_dependency_dir.

uses_tool_shed_dependencies()[source]
dependency_shell_commands(requirements, **kwds)[source]
find_dep(name, version=None, type='package', **kwds)[source]
to_dict()[source]

Subpackages

Submodules

galaxy.tool_util.deps.brew_exts module

class galaxy.tool_util.deps.brew_exts.BrewContext(args=None)[source]

Bases: object

__init__(args=None)[source]
class galaxy.tool_util.deps.brew_exts.RecipeContext(recipe, version, brew_context=None)[source]

Bases: object

static from_args(args, brew_context=None)[source]
__init__(recipe, version, brew_context=None)[source]
property cellar_path
property tap_path: str
galaxy.tool_util.deps.brew_exts.main()[source]
exception galaxy.tool_util.deps.brew_exts.CommandLineException(command, stdout, stderr)[source]

Bases: Exception

__init__(command, stdout, stderr)[source]
galaxy.tool_util.deps.brew_exts.versioned_install(recipe_context, package=None, version=None, installed_deps=None)[source]
galaxy.tool_util.deps.brew_exts.commit_for_version(recipe_context: RecipeContext, package, version)[source]
galaxy.tool_util.deps.brew_exts.print_versioned_deps(recipe_context, recipe, version)[source]
galaxy.tool_util.deps.brew_exts.load_versioned_deps(cellar_path, relaxed=None)[source]
galaxy.tool_util.deps.brew_exts.unversioned_install(package)[source]
galaxy.tool_util.deps.brew_exts.brew_execute(args, env=None)[source]
galaxy.tool_util.deps.brew_exts.build_env_statements_from_recipe_context(recipe_context, **kwds)[source]
galaxy.tool_util.deps.brew_exts.build_env_statements(cellar_root, cellar_path, relaxed=None, custom_only=False)[source]
galaxy.tool_util.deps.brew_exts.build_env_actions(deps, cellar_root, cellar_path, relaxed=None, custom_only=False)[source]
class galaxy.tool_util.deps.brew_exts.EnvAction(keg_root, action_description)[source]

Bases: object

__init__(keg_root, action_description)[source]
static build_env(env_actions)[source]
modify_environ(environ)[source]
to_statements()[source]
galaxy.tool_util.deps.brew_exts.brew_head_at_version(recipe_context, package, version)[source]
galaxy.tool_util.deps.brew_exts.brew_head_at_commit(commit, tap_path)[source]
galaxy.tool_util.deps.brew_exts.git_execute(args)[source]
galaxy.tool_util.deps.brew_exts.execute(cmds, env=None)[source]
galaxy.tool_util.deps.brew_exts.brew_deps(package)[source]
galaxy.tool_util.deps.brew_exts.brew_info(recipe)[source]
galaxy.tool_util.deps.brew_exts.extended_brew_info(recipe)[source]
galaxy.tool_util.deps.brew_exts.brew_versions_info(package, tap_path: str) List[Tuple[str, str, bool]][source]
galaxy.tool_util.deps.brew_exts.recipe_cellar_path(cellar_path, recipe, version)[source]
galaxy.tool_util.deps.brew_exts.ensure_brew_on_path(args)[source]
galaxy.tool_util.deps.brew_exts.which(file)[source]

galaxy.tool_util.deps.brew_util module

brew_exts defines generic extensions to Homebrew this file builds on those abstraction and provides Galaxy specific functionality not useful to the brew external commands.

class galaxy.tool_util.deps.brew_util.HomebrewRecipe(recipe, version, tap)[source]

Bases: object

__init__(recipe, version, tap)[source]
galaxy.tool_util.deps.brew_util.requirements_to_recipes(requirements)[source]
galaxy.tool_util.deps.brew_util.requirement_to_recipe(requirement)[source]
galaxy.tool_util.deps.brew_util.requirements_to_recipe_contexts(requirements, brew_context)[source]

galaxy.tool_util.deps.commands module

galaxy.tool_util.deps.conda_compat module

Compat. layer with conda_build/verify if Galaxy/galaxy-lib not installed through conda.

In general there are utilities available for Conda building and parsing that are high-quality and should be utilized when available but that are only available in conda channels and not in PyPI. This module serves as a PyPI capable interface to these utilities.

galaxy.tool_util.deps.conda_compat.MetaData

alias of _MetaData

galaxy.tool_util.deps.conda_compat.raw_metadata(recipe_dir)[source]

Evaluate Conda template if needed and return raw metadata for supplied recipe directory.

galaxy.tool_util.deps.conda_util module

class galaxy.tool_util.deps.conda_util.CondaContext(conda_prefix: str | None = None, conda_exec: str | None = None, shell_exec: Callable[[...], int] | None = None, debug: bool = False, ensure_channels: str | List[str] = '', condarc_override: str | None = None, use_path_exec: bool = False, copy_dependencies: bool = False, use_local: bool = False)[source]

Bases: InstallableContext

installable_description = 'Conda'
__init__(conda_prefix: str | None = None, conda_exec: str | None = None, shell_exec: Callable[[...], int] | None = None, debug: bool = False, ensure_channels: str | List[str] = '', condarc_override: str | None = None, use_path_exec: bool = False, copy_dependencies: bool = False, use_local: bool = False) None[source]
property conda_version: Version
property conda_build_available: bool
ensure_conda_build_installed_if_needed() int[source]
conda_info() Dict[str, Any][source]
is_conda_installed() bool[source]

Check if conda_exec exists

can_install_conda() bool[source]

If conda_exec is set to a path outside of conda_prefix, there is no use installing conda into conda_prefix, since it can’t be used by galaxy. If conda_exec equals conda_prefix/bin/conda, we can install conda if either conda_prefix does not exist or is empty.

exec_command(operation: str, args: List[str], stdout_path: str | None = None) int[source]

Execute the requested command.

Return the process exit code (i.e. 0 in case of success).

is_package_installed(pkg_name: str, version: str | None = None) bool[source]
exec_create(args: Iterable[str], allow_local: bool = True, stdout_path: str | None = None) int[source]

Return the process exit code (i.e. 0 in case of success).

exec_remove(args: List[str]) int[source]

Remove a conda environment using conda env remove -y –name args.

Return the process exit code (i.e. 0 in case of success).

exec_install(args: Iterable[str], allow_local: bool = True, stdout_path: str | None = None) int[source]

Return the process exit code (i.e. 0 in case of success).

exec_clean(args: List[str] | None = None, quiet: bool = False) int[source]

Clean up after conda installation.

Return the process exit code (i.e. 0 in case of success).

Search conda channels for a package

Return the standard output of the conda process.

export_list(name: str, path: str) int[source]

Return the process exit code (i.e. 0 in case of success).

env_path(env_name: str) str[source]
property envs_path: str
has_env(env_name: str) bool[source]
get_conda_target_installed_path(conda_target: CondaTarget) str | None[source]
property deactivate: str
property activate: str
is_installed() bool[source]

Return bool indicating if the configured software is installed.

can_install() bool[source]

Check preconditions for installation.

property parent_path: str

Return parent path of the location the installable will be created within.

class galaxy.tool_util.deps.conda_util.CondaTarget(package: str, version: str | None = None, build: str | None = None, channel: str | None = None)[source]

Bases: object

__init__(package: str, version: str | None = None, build: str | None = None, channel: str | None = None) None[source]
property package_specifier: str

Return a package specifier as consumed by conda install/create.

property install_environment: str

The dependency resolution and installation frameworks will expect each target to be installed it its own environment with a fixed and predictable name given package and version. Since Galaxy 23.1 the package name is lowercased as all Conda package names must be lowercase.

property capitalized_install_environment: str

Same as install_environment() but using the original capitalized package name for backward compatibility with environments created before Galaxy 23.1 .

galaxy.tool_util.deps.conda_util.install_conda(conda_context: CondaContext, force_conda_build: bool = False) int[source]
galaxy.tool_util.deps.conda_util.install_conda_target(conda_target: CondaTarget, conda_context: CondaContext, skip_environment: bool = False) int[source]

Install specified target into a its own environment.

Return the process exit code (i.e. 0 in case of success).

galaxy.tool_util.deps.conda_util.requirements_to_conda_targets(requirements: Iterable[ToolRequirement]) List[CondaTarget][source]

galaxy.tool_util.deps.container_classes module

class galaxy.tool_util.deps.container_classes.ContainerProtocol(*args, **kwargs)[source]

Bases: Protocol

Helper class to allow typing for the HasDockerLikeVolumes mixin

property app_info: AppInfo
property tool_info: ToolInfo
property job_info: JobInfo | None
__init__(*args, **kwargs)
class galaxy.tool_util.deps.container_classes.Container(container_id: str, app_info: AppInfo, tool_info: ToolInfo, destination_info: Dict[str, Any], job_info: JobInfo | None, container_description: ContainerDescription | None, container_name: str | None = None)[source]

Bases: object

TODO The container resolvers currently initialize job_info as None, ContainerFinder.find_container fixes this by constructing a new container with job_info (see __destination_container)

container_type: str
__init__(container_id: str, app_info: AppInfo, tool_info: ToolInfo, destination_info: Dict[str, Any], job_info: JobInfo | None, container_description: ContainerDescription | None, container_name: str | None = None) None[source]
prop(name: str, default: Any) Any[source]
property resolve_dependencies: bool
property shell: str
property source_environment: str
abstract containerize_command(command: str) str[source]

Use destination supplied container configuration parameters, container_id, and command to build a new command that runs input command in container.

class galaxy.tool_util.deps.container_classes.Volume(rawstr: str, container_type: str)[source]

Bases: object

helper class to manage a container volume string

__init__(rawstr: str, container_type: str)[source]
static parse_volume_str(rawstr: str) Tuple[str, str, str][source]
>>> Volume.parse_volume_str('A:B:rw')
('A', 'B', 'rw')
>>> Volume.parse_volume_str('A : B: ro')
('A', 'B', 'ro')
>>> Volume.parse_volume_str('A:B')
('A', 'B', 'rw')
>>> Volume.parse_volume_str('A:ro')
('A', 'A', 'ro')
>>> Volume.parse_volume_str('A:z')
('A', 'A', 'z')
>>> Volume.parse_volume_str('A:Z')
('A', 'A', 'Z')
>>> Volume.parse_volume_str('A')
('A', 'A', 'rw')
>>> Volume.parse_volume_str(' ')
Traceback (most recent call last):
...
Exception: Unparsable volumes string in configuration [ ]
>>> Volume.parse_volume_str('A:B:C:D')
Traceback (most recent call last):
...
Exception: Unparsable volumes string in configuration [A:B:C:D]
galaxy.tool_util.deps.container_classes.preprocess_volumes(volumes_raw_str: str, container_type: str) List[str][source]

Process Galaxy volume specification string to either Docker or Singularity specification.

Galaxy allows the mount try “default_ro” which translates to ro for Docker and ro for Singularity iff no subdirectories are rw (Singularity does not allow ro parent directories with rw subdirectories).

Removes volumes that have the same target directory which is not allowed (for docker and singularity). Volumes that are specified later in the volumes_raw_str are favoured which allows admins to overwrite defaults.

>>> preprocess_volumes("", DOCKER_CONTAINER_TYPE)
[]
>>> preprocess_volumes("/a/b", DOCKER_CONTAINER_TYPE)
['/a/b:rw']
>>> preprocess_volumes("/a/b:ro,/a/b/c:rw", DOCKER_CONTAINER_TYPE)
['/a/b:ro', '/a/b/c:rw']
>>> preprocess_volumes("/a/b:/a:ro,/a/b/c:/a/b:rw", DOCKER_CONTAINER_TYPE)
['/a/b:/a:ro', '/a/b/c:/a/b:rw']
>>> preprocess_volumes("/a/b:default_ro,/a/b/c:rw", DOCKER_CONTAINER_TYPE)
['/a/b:ro', '/a/b/c:rw']
>>> preprocess_volumes("/a/b:default_ro,/a/b/c:ro", SINGULARITY_CONTAINER_TYPE)
['/a/b:ro', '/a/b/c:ro']
>>> preprocess_volumes("/a/b:default_ro,/a/b/c:rw", SINGULARITY_CONTAINER_TYPE)
['/a/b', '/a/b/c']
>>> preprocess_volumes("/x:/a/b:default_ro,/y:/a/b/c:ro", SINGULARITY_CONTAINER_TYPE)
['/x:/a/b:ro', '/y:/a/b/c:ro']
>>> preprocess_volumes("/x:/a/b:default_ro,/y:/a/b/c:rw", SINGULARITY_CONTAINER_TYPE)
['/x:/a/b', '/y:/a/b/c']
>>> preprocess_volumes("/x:/x,/y:/x", SINGULARITY_CONTAINER_TYPE)
['/y:/x']
class galaxy.tool_util.deps.container_classes.HasDockerLikeVolumes[source]

Bases: object

Mixin to share functionality related to Docker volume handling.

Singularity seems to have a fairly compatible syntax for volume handling.

class galaxy.tool_util.deps.container_classes.DockerContainer(container_id: str, app_info: AppInfo, tool_info: ToolInfo, destination_info: Dict[str, Any], job_info: JobInfo | None, container_description: ContainerDescription | None, container_name: str | None = None)[source]

Bases: Container, HasDockerLikeVolumes

container_type: str = 'docker'
property docker_host_props: Dict[str, Any]
property connection_configuration: Dict[str, Any]
build_pull_command() List[str][source]
containerize_command(command: str) str[source]

Use destination supplied container configuration parameters, container_id, and command to build a new command that runs input command in container.

container_info: Dict[str, Any]
galaxy.tool_util.deps.container_classes.docker_cache_path(cache_directory: str, container_id: str) str[source]
class galaxy.tool_util.deps.container_classes.SingularityContainer(container_id: str, app_info: AppInfo, tool_info: ToolInfo, destination_info: Dict[str, Any], job_info: JobInfo | None, container_description: ContainerDescription | None, container_name: str | None = None)[source]

Bases: Container, HasDockerLikeVolumes

container_type: str = 'singularity'
get_singularity_target_kwds() Dict[str, Any][source]
property connection_configuration: Dict[str, Any]
build_mulled_singularity_pull_command(cache_directory: str, namespace: str = 'biocontainers') List[str][source]
build_singularity_pull_command(cache_path: str) List[str][source]
containerize_command(command: str) str[source]

Use destination supplied container configuration parameters, container_id, and command to build a new command that runs input command in container.

container_info: Dict[str, Any]

galaxy.tool_util.deps.container_volumes module

class galaxy.tool_util.deps.container_volumes.ContainerVolume(path: str, host_path: str | None = None, mode: str | None = None)[source]

Bases: object

valid_modes = frozenset({'Z', 'ro', 'rw', 'z'})
__init__(path: str, host_path: str | None = None, mode: str | None = None)[source]
abstract from_str(as_str: str) ContainerVolume[source]

Classmethod to convert from this container type’s string representation.

Parameters:

as_str (str) – string representation of volume

property mode_is_valid: bool
class galaxy.tool_util.deps.container_volumes.DockerVolume(path: str, host_path: str | None = None, mode: str | None = None)[source]

Bases: ContainerVolume

classmethod from_str(as_str: str) DockerVolume[source]

Construct an instance from a string as would be passed to docker run –volume.

A string in the format <host_path>:<mode> is supported for legacy purposes even though it is not valid Docker volume syntax.

galaxy.tool_util.deps.containers module

class galaxy.tool_util.deps.containers.ResolvedContainerDescription(container_resolver, container_description)

Bases: tuple

container_description

Alias for field number 1

container_resolver

Alias for field number 0

class galaxy.tool_util.deps.containers.ContainerFinder(app_info: AppInfo, mulled_resolution_cache: Cache | None = None)[source]

Bases: object

__init__(app_info: AppInfo, mulled_resolution_cache: Cache | None = None) None[source]
find_best_container_description(enabled_container_types: Container[str], tool_info: ToolInfo, **kwds) ContainerDescription | None[source]

Regardless of destination properties - find best container for tool.

Given container types and container.ToolInfo description of the tool.

resolve(enabled_container_types: Container[str], tool_info: ToolInfo, **kwds) ResolvedContainerDescription | None[source]

Regardless of destination properties - find ResolvedContainerDescription for tool.

find_container(tool_info: ToolInfo, destination_info: Dict[str, Any], job_info: JobInfo) Container | None[source]
resolution_cache() ResolutionCache[source]
class galaxy.tool_util.deps.containers.NullContainerFinder[source]

Bases: object

find_container(tool_info: ToolInfo, destination_info: Dict[str, Any], job_info: JobInfo) None[source]
class galaxy.tool_util.deps.containers.ContainerRegistry(app_info: AppInfo, destination_info: Dict[str, Any] | None = None, mulled_resolution_cache: Cache | None = None)[source]

Bases: object

Loop through enabled ContainerResolver plugins and find first match.

__init__(app_info: AppInfo, destination_info: Dict[str, Any] | None = None, mulled_resolution_cache: Cache | None = None) None[source]
get_resolution_cache() ResolutionCache[source]
find_best_container_description(enabled_container_types: Container[str], tool_info: ToolInfo, **kwds: Any) ContainerDescription | None[source]

Yield best container description of supplied types matching tool info.

resolve(enabled_container_types: Container[str], tool_info: ToolInfo, index: int | None = None, resolver_type: str | None = None, install: bool = True, resolution_cache: ResolutionCache | None = None, session: Session | None = None) ResolvedContainerDescription | None[source]

galaxy.tool_util.deps.dependencies module

class galaxy.tool_util.deps.dependencies.AppInfo(galaxy_root_dir: str | None = None, default_file_path: str | None = None, tool_data_path: str | None = None, galaxy_data_manager_data_path: str | None = None, shed_tool_data_path: str | None = None, outputs_to_working_directory: bool = False, container_image_cache_path: str | None = None, library_import_dir: str | None = None, enable_mulled_containers: bool = False, container_resolvers_config_file: str | None = None, container_resolvers_config_dict: Dict[str, Any] | None = None, involucro_path: str | None = None, involucro_auto_init: bool = True, mulled_channels: List[str] = ['conda-forge', 'bioconda'])[source]

Bases: object

__init__(galaxy_root_dir: str | None = None, default_file_path: str | None = None, tool_data_path: str | None = None, galaxy_data_manager_data_path: str | None = None, shed_tool_data_path: str | None = None, outputs_to_working_directory: bool = False, container_image_cache_path: str | None = None, library_import_dir: str | None = None, enable_mulled_containers: bool = False, container_resolvers_config_file: str | None = None, container_resolvers_config_dict: Dict[str, Any] | None = None, involucro_path: str | None = None, involucro_auto_init: bool = True, mulled_channels: List[str] = ['conda-forge', 'bioconda']) None[source]
class galaxy.tool_util.deps.dependencies.ToolInfo(container_descriptions: List[ContainerDescription] | None = None, requirements: ToolRequirements | List[ToolRequirement] | None = None, requires_galaxy_python_environment: bool = False, env_pass_through=None, guest_ports=None, tool_id: str | None = None, tool_version: str | None = None, profile: float = -1)[source]

Bases: object

__init__(container_descriptions: List[ContainerDescription] | None = None, requirements: ToolRequirements | List[ToolRequirement] | None = None, requires_galaxy_python_environment: bool = False, env_pass_through=None, guest_ports=None, tool_id: str | None = None, tool_version: str | None = None, profile: float = -1)[source]
class galaxy.tool_util.deps.dependencies.JobInfo(working_directory, tool_directory, job_directory, tmp_directory, home_directory, job_directory_type)[source]

Bases: object

__init__(working_directory, tool_directory, job_directory, tmp_directory, home_directory, job_directory_type)[source]
class galaxy.tool_util.deps.dependencies.DependenciesDescription(requirements=None, installed_tool_dependencies=None)[source]

Bases: object

Capture (in a readily serializable way) context related a tool dependencies - both the tool’s listed requirements and the tool shed related context required to resolve dependencies via the ToolShedPackageDependencyResolver.

This is meant to enable remote resolution of dependencies, by the Pulsar or other potential remote execution mechanisms.

__init__(requirements=None, installed_tool_dependencies=None)[source]
to_dict()[source]
classmethod from_dict(as_dict)[source]

galaxy.tool_util.deps.docker_util module

Utilities for building up Docker commands…

…using common defaults and configuration mechanisms.

galaxy.tool_util.deps.docker_util.kill_command(container: str, signal: str | None = None, **kwds) List[str][source]
galaxy.tool_util.deps.docker_util.logs_command(container: str, **kwds) List[str][source]
galaxy.tool_util.deps.docker_util.build_command(image: str, docker_build_path: str, **kwds) List[str][source]
galaxy.tool_util.deps.docker_util.build_save_image_command(image: str, destination: str, **kwds) List[str][source]
galaxy.tool_util.deps.docker_util.build_pull_command(tag: str, **kwds) List[str][source]
galaxy.tool_util.deps.docker_util.build_docker_cache_command(image: str, **kwds) str[source]
galaxy.tool_util.deps.docker_util.build_docker_images_command(truncate=True, **kwds) str | List[str][source]
galaxy.tool_util.deps.docker_util.build_docker_load_command(**kwds) str | List[str][source]
galaxy.tool_util.deps.docker_util.build_docker_simple_command(command: str, docker_cmd: str = 'docker', sudo: bool = False, sudo_cmd: str = 'sudo', container_name: str | None = None, **kwd) str[source]
galaxy.tool_util.deps.docker_util.build_docker_run_command(container_command: str, image: str, interactive: bool = False, terminal: bool = False, tag: str | None = None, volumes: List[DockerVolume] | None = None, volumes_from: str | None = None, memory: str | None = None, env_directives: List[str] | None = None, working_directory: str | None = None, name: str | None = None, net: str | None = None, run_extra_arguments: str | None = None, docker_cmd: str = 'docker', sudo: bool = False, sudo_cmd: str = 'sudo', auto_rm: bool = True, set_user: str | None = '$UID', host: str | None = None, guest_ports: bool | str | List[str] = False, container_name: str | None = None) str[source]
galaxy.tool_util.deps.docker_util.command_list(command: str, command_args: List[str] | None = None, **kwds) List[str][source]

Return Docker command as an argv list.

galaxy.tool_util.deps.docker_util.command_shell(command: str, command_args: List[str] | None = None, **kwds) str | List[str][source]

Return Docker command as a string for a shell or command-list.

galaxy.tool_util.deps.docker_util.parse_port_text(port_text)[source]
>>> slurm_ports = parse_port_text("8888/tcp -> 0.0.0.0:32769")
>>> slurm_ports[8888]['host']
'0.0.0.0'
>>> ports = parse_port_text("5432/tcp -> :::5432")
>>> len(ports)
0
>>> ports_new = parse_port_text("5432/tcp -> [::]:5432")
>>> len(ports_new)
0

galaxy.tool_util.deps.dockerfiles module

galaxy.tool_util.deps.dockerfiles.docker_host_args(**kwds)[source]
galaxy.tool_util.deps.dockerfiles.dockerfile_build(path, dockerfile=None, error=<bound method Logger.error of <CBLogger galaxy.tool_util.deps.dockerfiles (DEBUG)>>, **kwds)[source]

galaxy.tool_util.deps.installable module

Abstractions for installing local software managed and required by Galaxy/galaxy-lib.

class galaxy.tool_util.deps.installable.InstallableContext[source]

Bases: object

Represent a directory/configuration of something that can be installed.

abstract is_installed()[source]

Return bool indicating if the configured software is installed.

abstract can_install()[source]

Check preconditions for installation.

abstract property installable_description

Short description of thing being installed for log statements.

abstract property parent_path

Return parent path of the location the installable will be created within.

galaxy.tool_util.deps.installable.ensure_installed(installable_context, install_func, auto_init)[source]

Make sure target is installed - handle multiple processes potentially attempting installation.

galaxy.tool_util.deps.requirements module

class galaxy.tool_util.deps.requirements.ToolRequirement(name: str, type: str | None = None, version: str | None = None, specs: Iterable[RequirementSpecification] | None = None)[source]

Bases: object

Represents an external requirement that must be available for the tool to run (for example, a program, package, or library). Requirements can optionally assert a specific version.

__init__(name: str, type: str | None = None, version: str | None = None, specs: Iterable[RequirementSpecification] | None = None) None[source]
to_dict() Dict[str, Any][source]
copy() ToolRequirement[source]
classmethod from_dict(d: Dict[str, Any]) ToolRequirement[source]
class galaxy.tool_util.deps.requirements.RequirementSpecification(uri: str, version: str | None = None)[source]

Bases: object

Refine a requirement using a URI.

__init__(uri: str, version: str | None = None) None[source]
property specifies_version: bool
property short_name: str
to_dict() Dict[str, Any][source]
classmethod from_dict(dict: Dict) RequirementSpecification[source]
class galaxy.tool_util.deps.requirements.ToolRequirements(tool_requirements: List[ToolRequirement | Dict[str, Any]] | None = None)[source]

Bases: object

Represents all requirements (packages, env vars) needed to run a tool.

__init__(tool_requirements: List[ToolRequirement | Dict[str, Any]] | None = None) None[source]
classmethod from_list(requirements: List[ToolRequirement | Dict[str, Any]]) ToolRequirements[source]
property resolvable: ToolRequirements
property packages: ToolRequirements
to_list()[source]
append(requirement: ToolRequirement | Dict[str, Any]) None[source]
to_dict() List[Dict[str, Any]][source]
exception galaxy.tool_util.deps.requirements.ToolRequirementsException[source]

Bases: Exception

class galaxy.tool_util.deps.requirements.ContainerDescription(identifier: str, type: str = 'docker', resolve_dependencies: bool = False, shell: str = '/bin/sh')[source]

Bases: object

__init__(identifier: str, type: str = 'docker', resolve_dependencies: bool = False, shell: str = '/bin/sh') None[source]
to_dict(*args, **kwds) Dict[str, Any][source]
classmethod from_dict(dict: Dict[str, Any]) ContainerDescription[source]
class galaxy.tool_util.deps.requirements.ResourceRequirement(value_or_expression: int | float | str, resource_type: typing_extensions.Literal[cores_min, cores_max, ram_min, ram_max, tmpdir_min, tmpdir_max, cuda_version_min, cuda_compute_capability, gpu_memory_min, cuda_device_count_min, cuda_device_count_max, shm_size])[source]

Bases: object

__init__(value_or_expression: int | float | str, resource_type: typing_extensions.Literal[cores_min, cores_max, ram_min, ram_max, tmpdir_min, tmpdir_max, cuda_version_min, cuda_compute_capability, gpu_memory_min, cuda_device_count_min, cuda_device_count_max, shm_size]) None[source]
to_dict() Dict[str, Any][source]
get_value(runtime: Dict | None = None, js_evaluator: Callable | None = None) float[source]
galaxy.tool_util.deps.requirements.resource_requirements_from_list(requirements: Iterable[Dict[str, Any]]) List[ResourceRequirement][source]
galaxy.tool_util.deps.requirements.parse_requirements_from_lists(software_requirements: List[ToolRequirement | Dict[str, Any]], containers: Iterable[Dict[str, Any]], resource_requirements: Iterable[Dict[str, Any]]) Tuple[ToolRequirements, List[ContainerDescription], List[ResourceRequirement]][source]
galaxy.tool_util.deps.requirements.parse_requirements_from_xml(xml_root, parse_resources: bool = False)[source]

Parses requirements, containers and optionally resource requirements from Xml tree.

>>> from galaxy.util import parse_xml_string
>>> def load_requirements(contents, parse_resources=False):
...     contents_document = '''<tool><requirements>%s</requirements></tool>'''
...     root = parse_xml_string(contents_document % contents)
...     return parse_requirements_from_xml(root, parse_resources=parse_resources)
>>> reqs, containers = load_requirements('''<requirement>bwa</requirement>''')
>>> reqs[0].name
'bwa'
>>> reqs[0].version is None
True
>>> reqs[0].type
'package'
>>> reqs, containers = load_requirements('''<requirement type="binary" version="1.3.3">cufflinks</requirement>''')
>>> reqs[0].name
'cufflinks'
>>> reqs[0].version
'1.3.3'
>>> reqs[0].type
'binary'
galaxy.tool_util.deps.requirements.resource_from_element(resource_elem) ResourceRequirement[source]
galaxy.tool_util.deps.requirements.container_from_element(container_elem) ContainerDescription[source]

galaxy.tool_util.deps.singularity_util module

galaxy.tool_util.deps.singularity_util.build_singularity_run_command(container_command: str, image: str, volumes: List[DockerVolume] | None = None, env: List[Tuple[str, str]] | None = None, working_directory: str | None = None, singularity_cmd: str = 'singularity', run_extra_arguments: str | None = None, sudo: bool = False, sudo_cmd: str = 'sudo', guest_ports: bool | List[str] = False, container_name: str | None = None, cleanenv: bool = True, no_mount: List[str] | None = ['tmp']) str[source]
galaxy.tool_util.deps.singularity_util.pull_mulled_singularity_command(docker_image_identifier: str, cache_directory: str, namespace: str | None = None, singularity_cmd: str = 'singularity', sudo: bool = False, sudo_cmd: str = 'sudo') List[str][source]
galaxy.tool_util.deps.singularity_util.pull_singularity_command(image_identifier: str, cache_path: str, singularity_cmd: str = 'singularity', sudo: bool = False, sudo_cmd: str = 'sudo') List[str][source]

galaxy.tool_util.deps.views module

class galaxy.tool_util.deps.views.DependencyResolversView(app)[source]

Bases: object

Provide a RESTfulish/JSONy interface to a galaxy.tool_util.deps.DependencyResolver object. This can be adapted by the Galaxy web framework or other web apps.

__init__(app)[source]
index()[source]
show(index)[source]
reload()[source]
manager_requirements()[source]
resolver_requirements(index)[source]
manager_dependency(**kwds)[source]
resolver_dependency(index, **kwds)[source]
show_dependencies(tool_requirements_d, installed_tool_dependencies=None, **kwd)[source]

Resolves dependencies to build a requirements status in the admin panel/API

uninstall_dependencies(index=None, resolver_type=None, container_type=None, **payload)[source]

Attempt to uninstall requirements. Returns 0 if successfull, else None.

property unused_dependency_paths

List dependencies that are not currently installed.

remove_unused_dependency_paths(envs)[source]

Remove dependencies that are not currently used.

Returns a list of all environments that have been successfully removed.

install_dependencies(requirements, **kwds)[source]
install_dependency(index=None, **payload)[source]

Installs dependency using highest priority resolver that supports dependency installation (Currently only the conda resolver supports this). If index is given, attempt installation directly using the corresponding resolver. Returns True on success, False on failure. payload is dictionary that must container name, version and type, e.g. {‘name’: ‘numpy’, version=’1.9.1’, type=’package’}

property installable_resolvers

List index for all active resolvers that have the ‘install_dependency’ attribute.

property uninstallable_resolvers

List index for all active resolvers that can uninstall dependencies that have been installed through this resolver.

property tool_ids_by_requirements

Dictionary with requirements as keys, and tool_ids as values.

property toolbox_requirements_status
summarize_requirements(**kwds)[source]
summarize_tools(**kwds)[source]
get_requirements_status(tool_requirements_d, installed_tool_dependencies=None, **kwd)[source]
clean(index=None, **kwds)[source]
class galaxy.tool_util.deps.views.ContainerResolutionView(app: StructuredApp)[source]

Bases: object

__init__(app: StructuredApp)[source]
index() List[Dict[str, Any]][source]
show(index: str) Dict[str, Any][source]
resolve(index: str | None = None, **kwds) Dict[str, Any][source]
resolve_toolbox(**kwds) List[Dict[str, Any]][source]
galaxy.tool_util.deps.views.pop_tool_ids(kwds: Dict[str, Any]) List[str] | None[source]