isabl-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- isabl_cli/VERSION +1 -0
- isabl_cli/__init__.py +25 -0
- isabl_cli/__main__.py +13 -0
- isabl_cli/api.py +815 -0
- isabl_cli/app.py +1926 -0
- isabl_cli/batch_systems/__init__.py +7 -0
- isabl_cli/batch_systems/local.py +44 -0
- isabl_cli/batch_systems/lsf.py +175 -0
- isabl_cli/batch_systems/sge.py +194 -0
- isabl_cli/batch_systems/slurm.py +180 -0
- isabl_cli/cli.py +91 -0
- isabl_cli/commands.py +480 -0
- isabl_cli/data/README.md +7 -0
- isabl_cli/data.py +1240 -0
- isabl_cli/exceptions.py +48 -0
- isabl_cli/factories.py +99 -0
- isabl_cli/options.py +407 -0
- isabl_cli/settings.py +315 -0
- isabl_cli/signals.py +23 -0
- isabl_cli/test/__init__.py +1 -0
- isabl_cli/test/utils.py +159 -0
- isabl_cli/utils.py +346 -0
- isabl_cli/validators.py +100 -0
- isabl_cli-0.1.0.dist-info/LICENSE.md +23 -0
- isabl_cli-0.1.0.dist-info/METADATA +40 -0
- isabl_cli-0.1.0.dist-info/RECORD +43 -0
- isabl_cli-0.1.0.dist-info/WHEEL +5 -0
- isabl_cli-0.1.0.dist-info/entry_points.txt +2 -0
- isabl_cli-0.1.0.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/conftest.py +26 -0
- tests/test_api.py +124 -0
- tests/test_app.py +1254 -0
- tests/test_batch_systems.py +87 -0
- tests/test_cli.py +34 -0
- tests/test_commands.py +341 -0
- tests/test_data.py +450 -0
- tests/test_options.py +28 -0
- tests/test_signals.py +59 -0
- tests/test_testutils.py +24 -0
- tests/test_utils.py +154 -0
- tests/test_validators.py +128 -0
- tests/test_version.py +8 -0
isabl_cli/exceptions.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Package exceptions."""
|
|
2
|
+
|
|
3
|
+
from click import UsageError
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class PackageBaseException(Exception):
|
|
7
|
+
|
|
8
|
+
"""A base exception for isabl_cli."""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ValidationError(PackageBaseException, UsageError, AssertionError):
|
|
12
|
+
|
|
13
|
+
"""A class to raise when a validation error occurs."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MissingRequirementError(PackageBaseException):
|
|
17
|
+
|
|
18
|
+
"""A class to raise when a requirement is missing."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class MissingOutputError(PackageBaseException):
|
|
22
|
+
|
|
23
|
+
"""A class to raise when a file that should exist is missing."""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ConfigurationError(PackageBaseException):
|
|
27
|
+
|
|
28
|
+
"""A class to raise when is not properly configured."""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ImplementationError(PackageBaseException):
|
|
32
|
+
|
|
33
|
+
"""A class to raise when is not properly implemented."""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class CantBeRunError(PackageBaseException):
|
|
37
|
+
|
|
38
|
+
"""A class to raise when a application just cannot be run."""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class MissingDataError(PackageBaseException):
|
|
42
|
+
|
|
43
|
+
"""A class to raise when data is missing."""
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class AutomationError(PackageBaseException):
|
|
47
|
+
|
|
48
|
+
"""A class to raise when automations fail."""
|
isabl_cli/factories.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""Instance factories used for testing."""
|
|
2
|
+
|
|
3
|
+
import string
|
|
4
|
+
|
|
5
|
+
from factory import fuzzy
|
|
6
|
+
import factory
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BaseFactory(factory.DictFactory):
|
|
10
|
+
notes = fuzzy.FuzzyText(length=100, chars=string.ascii_letters)
|
|
11
|
+
tags = [{"name": "tag 1"}, {"name": "tag 2"}]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class UserFactory(BaseFactory):
|
|
15
|
+
username = fuzzy.FuzzyText(length=6, chars=string.ascii_letters)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ProjectFactory(BaseFactory):
|
|
19
|
+
analyst = factory.Sequence(lambda n: f"analyst-{n}@test.com")
|
|
20
|
+
coordinator = factory.Sequence(lambda n: f"coordinator-{n}@test.com")
|
|
21
|
+
description = fuzzy.FuzzyText(length=20, chars=string.ascii_lowercase + " ")
|
|
22
|
+
owner = factory.Sequence(lambda n: f"owner-{n}@test.com")
|
|
23
|
+
principal_investigator = factory.Sequence(lambda n: f"pi-{n}@test.com")
|
|
24
|
+
title = fuzzy.FuzzyText(length=20, chars=string.ascii_lowercase + " ")
|
|
25
|
+
sharing = {"can_share": [], "can_read": [], "is_public": True}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CenterFactory(BaseFactory):
|
|
29
|
+
acronym = fuzzy.FuzzyText(length=3, chars=string.ascii_letters)
|
|
30
|
+
name = fuzzy.FuzzyText(length=6, chars=string.ascii_letters)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class PlatformFactory(BaseFactory):
|
|
34
|
+
manufacturer = fuzzy.FuzzyText(length=3, chars=string.ascii_letters)
|
|
35
|
+
system = fuzzy.FuzzyText(length=3, chars=string.ascii_letters)
|
|
36
|
+
version = fuzzy.FuzzyText(length=3, chars=string.ascii_letters)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class DiseaseFactory(BaseFactory):
|
|
40
|
+
acronym = factory.Sequence(lambda n: f"D-{n}")
|
|
41
|
+
name = fuzzy.FuzzyText(length=6, chars=string.ascii_letters)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class AssemblyFactory(BaseFactory):
|
|
45
|
+
name = "GRCh37"
|
|
46
|
+
reference_data = {}
|
|
47
|
+
species = fuzzy.FuzzyChoice(["HUMAN", "MOUSE"])
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class ApplicationFactory(BaseFactory):
|
|
51
|
+
description = fuzzy.FuzzyText(length=10, chars=string.ascii_letters)
|
|
52
|
+
name = fuzzy.FuzzyText(length=10, chars=string.ascii_letters)
|
|
53
|
+
version = fuzzy.FuzzyText(length=10, chars=string.ascii_letters)
|
|
54
|
+
assembly = factory.SubFactory(AssemblyFactory)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class AnalysisFactory(BaseFactory):
|
|
58
|
+
ran_by = "admin"
|
|
59
|
+
application = factory.SubFactory(ApplicationFactory)
|
|
60
|
+
targets = []
|
|
61
|
+
references = []
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class TechniqueFactory(BaseFactory):
|
|
65
|
+
reference_data = factory.SubFactory(factory.DictFactory)
|
|
66
|
+
name = fuzzy.FuzzyText(length=12, chars=string.hexdigits)
|
|
67
|
+
method = fuzzy.FuzzyChoice(choices=["CS", "TD", "WE", "WG", "MD", "TR", "WT"])
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class IndividualFactory(BaseFactory):
|
|
71
|
+
birth_year = fuzzy.FuzzyInteger(1800, 2100)
|
|
72
|
+
center = factory.SubFactory(CenterFactory)
|
|
73
|
+
gender = fuzzy.FuzzyChoice(["MALE", "FEMALE", "UNKNOWN"])
|
|
74
|
+
species = fuzzy.FuzzyChoice(["HUMAN", "MOUSE"])
|
|
75
|
+
identifier = fuzzy.FuzzyText(length=12, chars=string.hexdigits)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class SampleFactory(BaseFactory):
|
|
79
|
+
disease = factory.SubFactory(DiseaseFactory)
|
|
80
|
+
individual = factory.SubFactory(IndividualFactory)
|
|
81
|
+
pdx_id = fuzzy.FuzzyText(length=12, chars=string.hexdigits)
|
|
82
|
+
category = fuzzy.FuzzyChoice(["TUMOR", "NORMAL"])
|
|
83
|
+
identifier = fuzzy.FuzzyText(length=12, chars=string.hexdigits)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class ExperimentFactory(BaseFactory):
|
|
87
|
+
bam_files = factory.SubFactory(factory.DictFactory)
|
|
88
|
+
aliquot_id = None
|
|
89
|
+
identifier = fuzzy.FuzzyText(length=12, chars=string.hexdigits)
|
|
90
|
+
center = factory.SubFactory(CenterFactory)
|
|
91
|
+
raw_data = None
|
|
92
|
+
platform = factory.SubFactory(PlatformFactory)
|
|
93
|
+
sample = factory.SubFactory(SampleFactory)
|
|
94
|
+
technique = factory.SubFactory(TechniqueFactory)
|
|
95
|
+
|
|
96
|
+
@factory.lazy_attribute
|
|
97
|
+
def projects(self): # pylint: disable=no-self-use
|
|
98
|
+
"""Lazy method to return list of projects."""
|
|
99
|
+
return [ProjectFactory()]
|
isabl_cli/options.py
ADDED
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
"""Click options decorators."""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from isabl_cli import api
|
|
6
|
+
from isabl_cli import validators
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _get_experiments(filter_tuples):
|
|
10
|
+
return api.get_instances("experiments", **dict(filter_tuples))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
NULLABLE_IDENTIFIERS = click.argument("identifiers", nargs=-1, required=False)
|
|
14
|
+
|
|
15
|
+
IDENTIFIER = click.option(
|
|
16
|
+
"--identifier",
|
|
17
|
+
"-id",
|
|
18
|
+
show_default=True,
|
|
19
|
+
help=(
|
|
20
|
+
"experiment identifier field to be used (traverse with dot, e.g., "
|
|
21
|
+
"system_id, sample.system_id, sample.individual.identifier, etc.)"
|
|
22
|
+
),
|
|
23
|
+
callback=lambda _, __, i: i.split("."),
|
|
24
|
+
required=True,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
FIELDS = click.option(
|
|
28
|
+
"--field",
|
|
29
|
+
"-f",
|
|
30
|
+
show_default=True,
|
|
31
|
+
multiple=True,
|
|
32
|
+
help="fields to be retrieved (traverse with dot, e.g. `sample.disease`)",
|
|
33
|
+
callback=lambda _, __, i: [j.split(".") for j in i],
|
|
34
|
+
required=False,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
ANALYSIS_STATUS = click.option(
|
|
38
|
+
"--status",
|
|
39
|
+
show_default=True,
|
|
40
|
+
help="analysis status",
|
|
41
|
+
required=True,
|
|
42
|
+
type=click.Choice(
|
|
43
|
+
[
|
|
44
|
+
"CREATED",
|
|
45
|
+
"FAILED",
|
|
46
|
+
"FINISHED",
|
|
47
|
+
"IN_PROGRESS",
|
|
48
|
+
"STAGED",
|
|
49
|
+
"STARTED",
|
|
50
|
+
"SUBMITTED",
|
|
51
|
+
"SUCCEEDED",
|
|
52
|
+
"REJECTED",
|
|
53
|
+
]
|
|
54
|
+
),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
ENDPOINT = click.argument(
|
|
58
|
+
"endpoint",
|
|
59
|
+
required=True,
|
|
60
|
+
type=click.Choice(
|
|
61
|
+
[
|
|
62
|
+
"experiments",
|
|
63
|
+
"analyses",
|
|
64
|
+
"projects",
|
|
65
|
+
"techniques",
|
|
66
|
+
"samples",
|
|
67
|
+
"individuals",
|
|
68
|
+
"assemblies",
|
|
69
|
+
"diseases",
|
|
70
|
+
"centers",
|
|
71
|
+
"platforms",
|
|
72
|
+
"submissions",
|
|
73
|
+
"applications",
|
|
74
|
+
"groups",
|
|
75
|
+
]
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
ANALYSIS_PRIMARY_KEY = click.option(
|
|
80
|
+
"--key",
|
|
81
|
+
help="analysis primary key",
|
|
82
|
+
show_default=True,
|
|
83
|
+
type=click.INT,
|
|
84
|
+
required=True,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
TECHNIQUE_IDENTIFIER = click.option(
|
|
88
|
+
"--technique",
|
|
89
|
+
help="technique identifier",
|
|
90
|
+
show_default=True,
|
|
91
|
+
type=click.STRING,
|
|
92
|
+
required=True,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
BED_TYPE = click.option(
|
|
96
|
+
"--bed-type",
|
|
97
|
+
help="technique BED file type.",
|
|
98
|
+
show_default=True,
|
|
99
|
+
default="targets",
|
|
100
|
+
type=click.Choice(["targets", "baits"]),
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
COMMIT = click.option(
|
|
104
|
+
"--commit", help="commit results", show_default=True, is_flag=True
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
NO_HEADERS = click.option(
|
|
108
|
+
"--no-headers", help="do not output headers", show_default=True, is_flag=True
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
FILE_PATTERN = click.option(
|
|
112
|
+
"--pattern",
|
|
113
|
+
help="paths pattern to be matched",
|
|
114
|
+
default=None,
|
|
115
|
+
show_default=True,
|
|
116
|
+
type=click.STRING,
|
|
117
|
+
required=False,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
FILTERS = click.option(
|
|
121
|
+
"--filters",
|
|
122
|
+
"-fi",
|
|
123
|
+
multiple=True,
|
|
124
|
+
help="API filters",
|
|
125
|
+
show_default=True,
|
|
126
|
+
type=(str, str),
|
|
127
|
+
callback=lambda _, __, i: dict(i),
|
|
128
|
+
required=True,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
NULLABLE_FILTERS = click.option(
|
|
132
|
+
"--filters",
|
|
133
|
+
"-fi",
|
|
134
|
+
multiple=True,
|
|
135
|
+
help="API filters",
|
|
136
|
+
show_default=True,
|
|
137
|
+
type=(str, str),
|
|
138
|
+
callback=lambda _, __, i: dict(i),
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
ANALYSES = click.option(
|
|
142
|
+
"--analyses-filters",
|
|
143
|
+
"-fi",
|
|
144
|
+
multiple=True,
|
|
145
|
+
help="API filters analyses instances",
|
|
146
|
+
show_default=True,
|
|
147
|
+
type=(str, str),
|
|
148
|
+
callback=lambda _, __, i: api.get_instances("analyses", **dict(i)),
|
|
149
|
+
required=True,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
NORMAL_TARGETS = click.option(
|
|
153
|
+
"--normal-targets-filters",
|
|
154
|
+
"-fi",
|
|
155
|
+
"targets",
|
|
156
|
+
multiple=True,
|
|
157
|
+
help="API filters for NORMAL target experiments",
|
|
158
|
+
show_default=True,
|
|
159
|
+
type=(str, str),
|
|
160
|
+
callback=lambda _, __, i: _get_experiments(
|
|
161
|
+
list(i) + [("sample__category", "NORMAL")]
|
|
162
|
+
),
|
|
163
|
+
required=True,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
TARGETS = click.option(
|
|
167
|
+
"--targets-filters",
|
|
168
|
+
"-fi",
|
|
169
|
+
"targets",
|
|
170
|
+
multiple=True,
|
|
171
|
+
help="API filters for target experiments",
|
|
172
|
+
show_default=True,
|
|
173
|
+
type=(str, str),
|
|
174
|
+
callback=lambda _, __, i: _get_experiments(i),
|
|
175
|
+
required=True,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
REFERENCES = click.option(
|
|
179
|
+
"--references-filters",
|
|
180
|
+
"-rfi",
|
|
181
|
+
"references",
|
|
182
|
+
multiple=True,
|
|
183
|
+
help="API filters for references experiments",
|
|
184
|
+
show_default=True,
|
|
185
|
+
type=(str, str),
|
|
186
|
+
callback=lambda _, __, i: _get_experiments(i),
|
|
187
|
+
required=True,
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
NULLABLE_REFERENCES = click.option(
|
|
191
|
+
"--references-filters",
|
|
192
|
+
"-rfi",
|
|
193
|
+
"references",
|
|
194
|
+
multiple=True,
|
|
195
|
+
help="API filters for references experiments",
|
|
196
|
+
show_default=True,
|
|
197
|
+
type=(str, str),
|
|
198
|
+
callback=lambda _, __, i: _get_experiments(i) if i else [],
|
|
199
|
+
required=False,
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
PAIR = click.option(
|
|
203
|
+
"--pair",
|
|
204
|
+
"-p",
|
|
205
|
+
show_default=True,
|
|
206
|
+
type=(str, str),
|
|
207
|
+
callback=lambda _, __, i: validators.validate_pairs([i]),
|
|
208
|
+
help="Pass one tumor normal pair identifiers (e.g. -p 1 2).",
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
PAIRS = click.option(
|
|
212
|
+
"--pairs",
|
|
213
|
+
"-p",
|
|
214
|
+
show_default=True,
|
|
215
|
+
type=(str, str),
|
|
216
|
+
multiple=True,
|
|
217
|
+
callback=lambda _, __, i: validators.validate_pairs(i),
|
|
218
|
+
help="Pass one or more tumor normal pairs (e.g. -p 1 2 -p 3 4).",
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
PAIRS_FROM_FILE = click.option(
|
|
222
|
+
"--pairs-from-file",
|
|
223
|
+
"-pf",
|
|
224
|
+
show_default=True,
|
|
225
|
+
callback=validators.validate_pairs_from_file,
|
|
226
|
+
help="Tab separated file with 2 columns: tumor, normal system ids.",
|
|
227
|
+
type=click.Path(
|
|
228
|
+
exists=True, file_okay=True, dir_okay=False, writable=False, readable=True
|
|
229
|
+
),
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
DIRECTORIES = click.option(
|
|
233
|
+
"--directories",
|
|
234
|
+
"-di",
|
|
235
|
+
show_default=True,
|
|
236
|
+
multiple=True,
|
|
237
|
+
help="directories to be processed",
|
|
238
|
+
type=click.Path(
|
|
239
|
+
exists=True,
|
|
240
|
+
file_okay=False,
|
|
241
|
+
dir_okay=True,
|
|
242
|
+
writable=False,
|
|
243
|
+
readable=True,
|
|
244
|
+
resolve_path=True,
|
|
245
|
+
),
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
SYMLINK = click.option("--symlink", help="use symlink", show_default=True, is_flag=True)
|
|
249
|
+
|
|
250
|
+
REFERENCE_DATA_SOURCE = click.option(
|
|
251
|
+
"--data-src",
|
|
252
|
+
show_default=True,
|
|
253
|
+
type=click.Path(resolve_path=True, exists=True, readable=True),
|
|
254
|
+
help="path to reference data",
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
TARGETS_PATH = click.option(
|
|
258
|
+
"--targets-path",
|
|
259
|
+
show_default=True,
|
|
260
|
+
help="path to targets bedfile",
|
|
261
|
+
type=click.Path(
|
|
262
|
+
resolve_path=True,
|
|
263
|
+
exists=True,
|
|
264
|
+
file_okay=True,
|
|
265
|
+
dir_okay=False,
|
|
266
|
+
writable=False,
|
|
267
|
+
readable=True,
|
|
268
|
+
),
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
BAITS_PATH = click.option(
|
|
272
|
+
"--baits-path",
|
|
273
|
+
show_default=True,
|
|
274
|
+
help="path to baits bedfile",
|
|
275
|
+
type=click.Path(
|
|
276
|
+
resolve_path=True,
|
|
277
|
+
exists=True,
|
|
278
|
+
file_okay=True,
|
|
279
|
+
dir_okay=False,
|
|
280
|
+
writable=False,
|
|
281
|
+
readable=True,
|
|
282
|
+
),
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
FILES_DATA = click.option(
|
|
286
|
+
"--files-data",
|
|
287
|
+
help="a yaml file with extra annotation for imported files.",
|
|
288
|
+
show_default=True,
|
|
289
|
+
default=None,
|
|
290
|
+
type=click.Path(
|
|
291
|
+
resolve_path=True,
|
|
292
|
+
exists=True,
|
|
293
|
+
file_okay=True,
|
|
294
|
+
dir_okay=False,
|
|
295
|
+
writable=False,
|
|
296
|
+
readable=True,
|
|
297
|
+
),
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
QUIET = click.option(
|
|
301
|
+
"--quiet", help="Don't display verbose output", show_default=False, is_flag=True
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
VERBOSE = click.option(
|
|
305
|
+
"--verbose", help="Display verbose output", show_default=True, is_flag=True
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
FORCE = click.option(
|
|
309
|
+
"--force", help="Wipe unfinished analyses and start from scratch.", is_flag=True
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
RESTART = click.option(
|
|
313
|
+
"--restart",
|
|
314
|
+
help="Attempt restarting failed analyses from previous checkpoint.",
|
|
315
|
+
is_flag=True,
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
SKIP = click.option(
|
|
319
|
+
"--skip",
|
|
320
|
+
help="Run to skip validation of same panel technique for the pairs.",
|
|
321
|
+
is_flag=True,
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def get_analyses_filters_option(application_classes=None, **defaults):
|
|
326
|
+
"""Get analyses filters with `defaults`."""
|
|
327
|
+
msg = ""
|
|
328
|
+
application_classes = application_classes or []
|
|
329
|
+
|
|
330
|
+
if defaults:
|
|
331
|
+
msg += " - the following filters will also be included: "
|
|
332
|
+
msg += ", ".join(f"{i}={j}" for i, j in defaults.items())
|
|
333
|
+
|
|
334
|
+
if application_classes:
|
|
335
|
+
msg += " - analyses will be limited to the following applications: "
|
|
336
|
+
msg += ", ".join(map(str, application_classes))
|
|
337
|
+
|
|
338
|
+
def callback(tuples):
|
|
339
|
+
if application_classes:
|
|
340
|
+
analyses = []
|
|
341
|
+
for i in application_classes:
|
|
342
|
+
defaults["application__pk"] = str(i.primary_key)
|
|
343
|
+
click.secho(
|
|
344
|
+
f"Getting completed analyses for {i.NAME} {i.VERSION}:", fg="cyan"
|
|
345
|
+
)
|
|
346
|
+
analyses += api.get_instances(
|
|
347
|
+
"analyses", **{**dict(tuples), **defaults}
|
|
348
|
+
)
|
|
349
|
+
return analyses
|
|
350
|
+
if defaults.get("application__name"):
|
|
351
|
+
app_name = defaults['application__name']
|
|
352
|
+
app_version = defaults.get('application__version')
|
|
353
|
+
if app_version:
|
|
354
|
+
click.secho(
|
|
355
|
+
f"Getting completed analyses for {app_name} {app_version}:", fg="cyan"
|
|
356
|
+
)
|
|
357
|
+
else:
|
|
358
|
+
click.secho(
|
|
359
|
+
f"Getting completed analyses for {app_name}:", fg="cyan"
|
|
360
|
+
)
|
|
361
|
+
return api.get_instances("analyses", **{**dict(tuples), **defaults})
|
|
362
|
+
|
|
363
|
+
return click.option(
|
|
364
|
+
"--analyses-filters",
|
|
365
|
+
"-fi",
|
|
366
|
+
multiple=True,
|
|
367
|
+
help="API filters for analyses instances" + msg,
|
|
368
|
+
show_default=True,
|
|
369
|
+
type=(str, str),
|
|
370
|
+
callback=lambda _, __, i: callback(i),
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
def get_dependency_analyses_option(dependencies_results, **extra_filters):
|
|
374
|
+
"""Get dependencies from specified app pk or name [with version]."""
|
|
375
|
+
return [
|
|
376
|
+
*[
|
|
377
|
+
get_analyses_filters_option(
|
|
378
|
+
application__classes=i["app"],
|
|
379
|
+
**extra_filters,
|
|
380
|
+
)
|
|
381
|
+
for i in dependencies_results
|
|
382
|
+
if i.get("app")
|
|
383
|
+
],
|
|
384
|
+
*[
|
|
385
|
+
get_analyses_filters_option(
|
|
386
|
+
application__name=i["app_name"],
|
|
387
|
+
**extra_filters,
|
|
388
|
+
)
|
|
389
|
+
for i in dependencies_results
|
|
390
|
+
if i.get("app_name")
|
|
391
|
+
and (
|
|
392
|
+
not i.get("app_version")
|
|
393
|
+
or i.get("app_version") in {"latest", "any"}
|
|
394
|
+
)
|
|
395
|
+
],
|
|
396
|
+
*[
|
|
397
|
+
get_analyses_filters_option(
|
|
398
|
+
application__name=i["app_name"],
|
|
399
|
+
application__version=i["app_version"],
|
|
400
|
+
**extra_filters,
|
|
401
|
+
)
|
|
402
|
+
for i in dependencies_results
|
|
403
|
+
if i.get("app_name")
|
|
404
|
+
and i.get("app_version")
|
|
405
|
+
and i.get("app_version") not in {"latest", "any"}
|
|
406
|
+
]
|
|
407
|
+
]
|