comparison env/lib/python3.9/site-packages/galaxy/tool_util/deps/container_resolvers/__init__.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 """The module defines the abstract interface for resolving container images for tool execution."""
2 from abc import (
3 ABCMeta,
4 abstractmethod,
5 abstractproperty,
6 )
7
8
9 from galaxy.util.bunch import Bunch
10 from galaxy.util.dictifiable import Dictifiable
11
12
13 class ResolutionCache(Bunch):
14 """Simple cache for duplicated computation created once per set of requests (likely web request in Galaxy context).
15
16 This should not be assumed to be thread safe - resolution using a given cache should all occur
17 one resolution at a time in a single thread.
18 """
19
20
21 class ContainerResolver(Dictifiable, metaclass=ABCMeta):
22 """Description of a technique for resolving container images for tool execution."""
23
24 # Keys for dictification.
25 dict_collection_visible_keys = ['resolver_type', 'can_uninstall_dependencies', 'builds_on_resolution']
26 can_uninstall_dependencies = False
27 builds_on_resolution = False
28 read_only = True # not used for containers, but set for when they are used like dependency resolvers
29
30 def __init__(self, app_info=None, **kwds):
31 """Default initializer for ``ContainerResolver`` subclasses."""
32 self.app_info = app_info
33 self.resolver_kwds = kwds
34
35 def _get_config_option(self, key, default=None):
36 """Look in resolver-specific settings for option and then fallback to
37 global settings.
38 """
39 if self.app_info and hasattr(self.app_info, key):
40 return getattr(self.app_info, key)
41 else:
42 return default
43
44 @abstractmethod
45 def resolve(self, enabled_container_types, tool_info, resolution_cache=None, **kwds):
46 """Find a container matching all supplied requirements for tool.
47
48 The supplied argument is a :class:`galaxy.tool_util.deps.containers.ToolInfo` description
49 of the tool and its requirements.
50 """
51
52 @abstractproperty
53 def resolver_type(self):
54 """Short label for the type of container resolution."""
55
56 def _container_type_enabled(self, container_description, enabled_container_types):
57 """Return a boolean indicating if the specified container type is enabled."""
58 return container_description.type in enabled_container_types
59
60 def __str__(self):
61 return "%s[]" % self.__class__.__name__