File: __init__.py

package info (click to toggle)
python-bioblend 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,096 kB
  • sloc: python: 7,596; sh: 219; makefile: 158
file content (124 lines) | stat: -rw-r--r-- 4,320 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""
Contains interactions dealing with Galaxy dependency resolvers.
"""
from typing import (
    Any,
    Dict,
    List,
    Optional,
    TYPE_CHECKING,
)

from typing_extensions import Literal

from bioblend.galaxy.client import Client

if TYPE_CHECKING:
    from bioblend.galaxy import GalaxyInstance


class ToolDependenciesClient(Client):
    module = "dependency_resolvers"

    def __init__(self, galaxy_instance: "GalaxyInstance") -> None:
        super().__init__(galaxy_instance)

    def summarize_toolbox(
        self,
        index: Optional[int] = None,
        tool_ids: Optional[List[str]] = None,
        resolver_type: Optional[str] = None,
        include_containers: bool = False,
        container_type: Optional[str] = None,
        index_by: Literal["requirements", "tools"] = "requirements",
    ) -> list:
        """
        Summarize requirements across toolbox (for Tool Management grid).

        :type index: int
        :param index: index of the dependency resolver with respect to
            the dependency resolvers config file

        :type tool_ids: list
        :param tool_ids: tool_ids to return when index_by=tools

        :type resolver_type: str
        :param resolver_type: restrict to specified resolver type

        :type include_containers: bool
        :param include_containers: include container resolvers in resolution

        :type container_type: str
        :param container_type: restrict to specified container type

        :type index_by: str
        :param index_by: By default results are grouped by requirements.  Set to 'tools'
          to return one entry per tool.

        :rtype: list of dicts
        :returns: dictified descriptions of the dependencies, with attribute
          `dependency_type: None` if no match was found.
          For example::

            [{'requirements': [{'name': 'galaxy_sequence_utils',
                                'specs': [],
                                'type': 'package',
                                'version': '1.1.4'},
                               {'name': 'bx-python',
                                'specs': [],
                                'type': 'package',
                                'version': '0.8.6'}],
              'status': [{'cacheable': False,
                          'dependency_type': None,
                          'exact': True,
                          'model_class': 'NullDependency',
                          'name': 'galaxy_sequence_utils',
                          'version': '1.1.4'},
                          {'cacheable': False,
                          'dependency_type': None,
                          'exact': True,
                          'model_class': 'NullDependency',
                          'name': 'bx-python',
                          'version': '0.8.6'}],
              'tool_ids': ['vcf_to_maf_customtrack1']}]

        .. note::
          This method works only on Galaxy 20.01 or later and if the user is a
          Galaxy admin. It relies on an experimental API particularly tied to
          the GUI and therefore is subject to breaking changes.
        """
        assert index_by in ["tools", "requirements"], "index_by must be one of 'tools' or 'requirements'."
        params = {
            "include_containers": str(include_containers),
            "index_by": index_by,
        }
        if index:
            params["index"] = str(index)
        if tool_ids:
            params["tool_ids"] = ",".join(tool_ids)
        if resolver_type:
            params["resolver_type"] = resolver_type
        if container_type:
            params["container_type"] = container_type

        url = "/".join((self._make_url(), "toolbox"))
        return self._get(url=url, params=params)

    def unused_dependency_paths(self) -> List[str]:
        """
        List unused dependencies
        """
        url = "/".join((self._make_url(), "unused_paths"))
        return self._get(url=url)

    def delete_unused_dependency_paths(self, paths: List[str]) -> None:
        """
        Delete unused paths

        :type paths: list
        :param paths: paths to delete

        """
        payload: Dict[str, Any] = {"paths": paths}
        url = "/".join((self._make_url(), "unused_paths"))
        self._put(url=url, payload=payload)