pyxetabase 4.0.0.dev0__py3-none-any.whl → 4.0.0.dev2__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.
Potentially problematic release.
This version of pyxetabase might be problematic. Click here for more details.
- pyxetabase/rest_clients/admin_client.py +1 -1
- pyxetabase/rest_clients/clinical_analysis_client.py +112 -5
- pyxetabase/rest_clients/file_client.py +15 -2
- pyxetabase/rest_clients/job_client.py +1 -1
- pyxetabase/rest_clients/study_client.py +2 -1
- pyxetabase/rest_clients/user_tool_client.py +459 -0
- pyxetabase/rest_clients/workflow_client.py +1 -1
- {pyxetabase-4.0.0.dev0.dist-info → pyxetabase-4.0.0.dev2.dist-info}/METADATA +1 -1
- pyxetabase-4.0.0.dev2.dist-info/RECORD +36 -0
- pyopencga/__init__.py +0 -0
- pyopencga/commons.py +0 -347
- pyopencga/exceptions.py +0 -8
- pyopencga/opencga_client.py +0 -334
- pyopencga/opencga_config.py +0 -211
- pyopencga/rest_clients/__init__.py +0 -0
- pyopencga/rest_clients/_parent_rest_clients.py +0 -110
- pyopencga/rest_clients/admin_client.py +0 -172
- pyopencga/rest_clients/alignment_client.py +0 -373
- pyopencga/rest_clients/clinical_analysis_client.py +0 -1279
- pyopencga/rest_clients/cohort_client.py +0 -338
- pyopencga/rest_clients/disease_panel_client.py +0 -352
- pyopencga/rest_clients/family_client.py +0 -355
- pyopencga/rest_clients/file_client.py +0 -698
- pyopencga/rest_clients/ga4gh_client.py +0 -86
- pyopencga/rest_clients/individual_client.py +0 -435
- pyopencga/rest_clients/job_client.py +0 -415
- pyopencga/rest_clients/meta_client.py +0 -85
- pyopencga/rest_clients/organization_client.py +0 -216
- pyopencga/rest_clients/project_client.py +0 -128
- pyopencga/rest_clients/sample_client.py +0 -446
- pyopencga/rest_clients/study_client.py +0 -461
- pyopencga/rest_clients/user_client.py +0 -192
- pyopencga/rest_clients/variant_client.py +0 -1378
- pyopencga/rest_clients/variant_operation_client.py +0 -745
- pyopencga/rest_clients/workflow_client.py +0 -263
- pyopencga/rest_response.py +0 -220
- pyopencga/retry.py +0 -57
- pyxetabase-4.0.0.dev0.dist-info/RECORD +0 -63
- {pyxetabase-4.0.0.dev0.dist-info → pyxetabase-4.0.0.dev2.dist-info}/WHEEL +0 -0
- {pyxetabase-4.0.0.dev0.dist-info → pyxetabase-4.0.0.dev2.dist-info}/licenses/LICENSE +0 -0
- {pyxetabase-4.0.0.dev0.dist-info → pyxetabase-4.0.0.dev2.dist-info}/top_level.txt +0 -0
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
WARNING: AUTOGENERATED CODE
|
|
3
|
-
|
|
4
|
-
This code was generated by a tool.
|
|
5
|
-
|
|
6
|
-
Manual changes to this file may cause unexpected behavior in your application.
|
|
7
|
-
Manual changes to this file will be overwritten if the code is regenerated.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from pyopencga.rest_clients._parent_rest_clients import _ParentRestClient
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class Workflow(_ParentRestClient):
|
|
14
|
-
"""
|
|
15
|
-
This class contains methods for the 'Workflows' webservices
|
|
16
|
-
PATH: /{apiVersion}/workflows
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
def __init__(self, configuration, token=None, login_handler=None, *args, **kwargs):
|
|
20
|
-
super(Workflow, self).__init__(configuration, token, login_handler, *args, **kwargs)
|
|
21
|
-
|
|
22
|
-
def update_acl(self, members, action, data=None, **options):
|
|
23
|
-
"""
|
|
24
|
-
Update the set of workflow permissions granted for the member.
|
|
25
|
-
PATH: /{apiVersion}/workflows/acl/{members}/update
|
|
26
|
-
|
|
27
|
-
:param dict data: JSON containing the parameters to update the
|
|
28
|
-
permissions. (REQUIRED)
|
|
29
|
-
:param str action: Action to be performed [ADD, SET, REMOVE or RESET].
|
|
30
|
-
Allowed values: ['SET ADD REMOVE RESET'] (REQUIRED)
|
|
31
|
-
:param str members: Comma separated list of user or group ids.
|
|
32
|
-
(REQUIRED)
|
|
33
|
-
:param str study: Study [[organization@]project:]study where study and
|
|
34
|
-
project can be either the ID or UUID.
|
|
35
|
-
"""
|
|
36
|
-
|
|
37
|
-
options['action'] = action
|
|
38
|
-
return self._post(category='workflows', resource='update', subcategory='acl', second_query_id=members, data=data, **options)
|
|
39
|
-
|
|
40
|
-
def create(self, data=None, **options):
|
|
41
|
-
"""
|
|
42
|
-
Create a workflow.
|
|
43
|
-
PATH: /{apiVersion}/workflows/create
|
|
44
|
-
|
|
45
|
-
:param dict data: JSON containing workflow information. (REQUIRED)
|
|
46
|
-
:param str include: Fields included in the response, whole JSON path
|
|
47
|
-
must be provided.
|
|
48
|
-
:param str exclude: Fields excluded in the response, whole JSON path
|
|
49
|
-
must be provided.
|
|
50
|
-
:param str study: Study [[organization@]project:]study where study and
|
|
51
|
-
project can be either the ID or UUID.
|
|
52
|
-
:param bool include_result: Flag indicating to include the created or
|
|
53
|
-
updated document result in the response.
|
|
54
|
-
"""
|
|
55
|
-
|
|
56
|
-
return self._post(category='workflows', resource='create', data=data, **options)
|
|
57
|
-
|
|
58
|
-
def distinct(self, field, **options):
|
|
59
|
-
"""
|
|
60
|
-
Workflow distinct method.
|
|
61
|
-
PATH: /{apiVersion}/workflows/distinct
|
|
62
|
-
|
|
63
|
-
:param str field: Comma separated list of fields for which to obtain
|
|
64
|
-
the distinct values. (REQUIRED)
|
|
65
|
-
:param str study: Study [[organization@]project:]study where study and
|
|
66
|
-
project can be either the ID or UUID.
|
|
67
|
-
:param str id: Comma separated list of workflow IDs up to a maximum of
|
|
68
|
-
100. Also admits basic regular expressions using the operator '~',
|
|
69
|
-
i.e. '~{perl-regex}' e.g. '~value' for case sensitive, '~/value/i'
|
|
70
|
-
for case insensitive search.
|
|
71
|
-
:param str name: Comma separated list of workflow names up to a
|
|
72
|
-
maximum of 100. Also admits basic regular expressions using the
|
|
73
|
-
operator '~', i.e. '~{perl-regex}' e.g. '~value' for case
|
|
74
|
-
sensitive, '~/value/i' for case insensitive search.
|
|
75
|
-
:param str uuid: Comma separated list of workflow UUIDs up to a
|
|
76
|
-
maximum of 100.
|
|
77
|
-
:param str tags: Comma separated list of tags.
|
|
78
|
-
:param bool draft: Boolean field indicating whether the workflow is a
|
|
79
|
-
draft or not.
|
|
80
|
-
:param str internal.registration_user_id: UserId that created the
|
|
81
|
-
workflow.
|
|
82
|
-
:param str manager.id: Id of the workflow system (Allowed values:
|
|
83
|
-
NEXTFLOW).
|
|
84
|
-
:param str type: Workflow type. Allowed types:
|
|
85
|
-
[CLINICAL_INTERPRETATION, SECONDARY_ANALYSIS, RESEARCH or OTHER].
|
|
86
|
-
:param str creation_date: Creation date. Format: yyyyMMddHHmmss.
|
|
87
|
-
Examples: >2018, 2017-2018, <201805.
|
|
88
|
-
:param str modification_date: Modification date. Format:
|
|
89
|
-
yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805.
|
|
90
|
-
:param str acl: Filter entries for which a user has the provided
|
|
91
|
-
permissions. Format: acl={user}:{permissions}. Example:
|
|
92
|
-
acl=john:WRITE,WRITE_ANNOTATIONS will return all entries for which
|
|
93
|
-
user john has both WRITE and WRITE_ANNOTATIONS permissions. Only
|
|
94
|
-
study owners or administrators can query by this field. .
|
|
95
|
-
:param str release: Release when it was created.
|
|
96
|
-
:param int snapshot: Snapshot value (Latest version of the entry in
|
|
97
|
-
the specified release).
|
|
98
|
-
:param bool deleted: Boolean to retrieve deleted entries.
|
|
99
|
-
"""
|
|
100
|
-
|
|
101
|
-
options['field'] = field
|
|
102
|
-
return self._get(category='workflows', resource='distinct', **options)
|
|
103
|
-
|
|
104
|
-
def import_workflow(self, data=None, **options):
|
|
105
|
-
"""
|
|
106
|
-
Import a workflow.
|
|
107
|
-
PATH: /{apiVersion}/workflows/import
|
|
108
|
-
|
|
109
|
-
:param dict data: Repository parameters. (REQUIRED)
|
|
110
|
-
:param str study: Study [[organization@]project:]study where study and
|
|
111
|
-
project can be either the ID or UUID.
|
|
112
|
-
"""
|
|
113
|
-
|
|
114
|
-
return self._post(category='workflows', resource='import', data=data, **options)
|
|
115
|
-
|
|
116
|
-
def run(self, data=None, **options):
|
|
117
|
-
"""
|
|
118
|
-
Execute a workflow analysis.
|
|
119
|
-
PATH: /{apiVersion}/workflows/run
|
|
120
|
-
|
|
121
|
-
:param dict data: NextFlow run parameters. (REQUIRED)
|
|
122
|
-
:param str study: Study [[organization@]project:]study where study and
|
|
123
|
-
project can be either the ID or UUID.
|
|
124
|
-
:param str job_id: Job ID. It must be a unique string within the
|
|
125
|
-
study. An ID will be autogenerated automatically if not provided.
|
|
126
|
-
:param str job_description: Job description.
|
|
127
|
-
:param str job_depends_on: Comma separated list of existing job IDs
|
|
128
|
-
the job will depend on.
|
|
129
|
-
:param str job_tags: Job tags.
|
|
130
|
-
:param str job_scheduled_start_time: Time when the job is scheduled to
|
|
131
|
-
start.
|
|
132
|
-
:param str job_priority: Priority of the job.
|
|
133
|
-
:param bool job_dry_run: Flag indicating that the job will be executed
|
|
134
|
-
in dry-run mode. In this mode, OpenCGA will validate that all
|
|
135
|
-
parameters and prerequisites are correctly set for successful
|
|
136
|
-
execution, but the job will not actually run.
|
|
137
|
-
"""
|
|
138
|
-
|
|
139
|
-
return self._post(category='workflows', resource='run', data=data, **options)
|
|
140
|
-
|
|
141
|
-
def search(self, **options):
|
|
142
|
-
"""
|
|
143
|
-
Workflow search method.
|
|
144
|
-
PATH: /{apiVersion}/workflows/search
|
|
145
|
-
|
|
146
|
-
:param str include: Fields included in the response, whole JSON path
|
|
147
|
-
must be provided.
|
|
148
|
-
:param str exclude: Fields excluded in the response, whole JSON path
|
|
149
|
-
must be provided.
|
|
150
|
-
:param int limit: Number of results to be returned.
|
|
151
|
-
:param int skip: Number of results to skip.
|
|
152
|
-
:param bool count: Get the total number of results matching the query.
|
|
153
|
-
Deactivated by default.
|
|
154
|
-
:param str study: Study [[organization@]project:]study where study and
|
|
155
|
-
project can be either the ID or UUID.
|
|
156
|
-
:param str id: Comma separated list of workflow IDs up to a maximum of
|
|
157
|
-
100. Also admits basic regular expressions using the operator '~',
|
|
158
|
-
i.e. '~{perl-regex}' e.g. '~value' for case sensitive, '~/value/i'
|
|
159
|
-
for case insensitive search.
|
|
160
|
-
:param str name: Comma separated list of workflow names up to a
|
|
161
|
-
maximum of 100. Also admits basic regular expressions using the
|
|
162
|
-
operator '~', i.e. '~{perl-regex}' e.g. '~value' for case
|
|
163
|
-
sensitive, '~/value/i' for case insensitive search.
|
|
164
|
-
:param str uuid: Comma separated list of workflow UUIDs up to a
|
|
165
|
-
maximum of 100.
|
|
166
|
-
:param str tags: Comma separated list of tags.
|
|
167
|
-
:param bool draft: Boolean field indicating whether the workflow is a
|
|
168
|
-
draft or not.
|
|
169
|
-
:param str internal.registration_user_id: UserId that created the
|
|
170
|
-
workflow.
|
|
171
|
-
:param str manager.id: Id of the workflow system (Allowed values:
|
|
172
|
-
NEXTFLOW).
|
|
173
|
-
:param str type: Workflow type. Allowed types:
|
|
174
|
-
[CLINICAL_INTERPRETATION, SECONDARY_ANALYSIS, RESEARCH or OTHER].
|
|
175
|
-
:param str creation_date: Creation date. Format: yyyyMMddHHmmss.
|
|
176
|
-
Examples: >2018, 2017-2018, <201805.
|
|
177
|
-
:param str modification_date: Modification date. Format:
|
|
178
|
-
yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805.
|
|
179
|
-
:param str acl: Filter entries for which a user has the provided
|
|
180
|
-
permissions. Format: acl={user}:{permissions}. Example:
|
|
181
|
-
acl=john:WRITE,WRITE_ANNOTATIONS will return all entries for which
|
|
182
|
-
user john has both WRITE and WRITE_ANNOTATIONS permissions. Only
|
|
183
|
-
study owners or administrators can query by this field. .
|
|
184
|
-
:param str release: Release when it was created.
|
|
185
|
-
:param int snapshot: Snapshot value (Latest version of the entry in
|
|
186
|
-
the specified release).
|
|
187
|
-
:param bool deleted: Boolean to retrieve deleted entries.
|
|
188
|
-
"""
|
|
189
|
-
|
|
190
|
-
return self._get(category='workflows', resource='search', **options)
|
|
191
|
-
|
|
192
|
-
def update(self, workflow_id, data=None, **options):
|
|
193
|
-
"""
|
|
194
|
-
Update some workflow attributes.
|
|
195
|
-
PATH: /{apiVersion}/workflows/{workflowId}/update
|
|
196
|
-
|
|
197
|
-
:param str workflow_id: Comma separated list workflow IDs or UUIDs up
|
|
198
|
-
to a maximum of 100. (REQUIRED)
|
|
199
|
-
:param str include: Fields included in the response, whole JSON path
|
|
200
|
-
must be provided.
|
|
201
|
-
:param str exclude: Fields excluded in the response, whole JSON path
|
|
202
|
-
must be provided.
|
|
203
|
-
:param str study: Study [[organization@]project:]study where study and
|
|
204
|
-
project can be either the ID or UUID.
|
|
205
|
-
:param bool include_result: Flag indicating to include the created or
|
|
206
|
-
updated document result in the response.
|
|
207
|
-
:param dict data: body.
|
|
208
|
-
"""
|
|
209
|
-
|
|
210
|
-
return self._post(category='workflows', resource='update', query_id=workflow_id, data=data, **options)
|
|
211
|
-
|
|
212
|
-
def acl(self, workflows, **options):
|
|
213
|
-
"""
|
|
214
|
-
Returns the acl of the workflows. If member is provided, it will only
|
|
215
|
-
return the acl for the member.
|
|
216
|
-
PATH: /{apiVersion}/workflows/{workflows}/acl
|
|
217
|
-
|
|
218
|
-
:param str workflows: Comma separated list workflow IDs or UUIDs up to
|
|
219
|
-
a maximum of 100. (REQUIRED)
|
|
220
|
-
:param str study: Study [[organization@]project:]study where study and
|
|
221
|
-
project can be either the ID or UUID.
|
|
222
|
-
:param str member: User or group id.
|
|
223
|
-
:param bool silent: Boolean to retrieve all possible entries that are
|
|
224
|
-
queried for, false to raise an exception whenever one of the
|
|
225
|
-
entries looked for cannot be shown for whichever reason.
|
|
226
|
-
"""
|
|
227
|
-
|
|
228
|
-
return self._get(category='workflows', resource='acl', query_id=workflows, **options)
|
|
229
|
-
|
|
230
|
-
def delete(self, workflows, **options):
|
|
231
|
-
"""
|
|
232
|
-
Delete workflows.
|
|
233
|
-
PATH: /{apiVersion}/workflows/{workflows}/delete
|
|
234
|
-
|
|
235
|
-
:param str workflows: Comma separated list workflow IDs or UUIDs up to
|
|
236
|
-
a maximum of 100. (REQUIRED)
|
|
237
|
-
:param str study: Study [[organization@]project:]study where study and
|
|
238
|
-
project can be either the ID or UUID.
|
|
239
|
-
"""
|
|
240
|
-
|
|
241
|
-
return self._delete(category='workflows', resource='delete', query_id=workflows, **options)
|
|
242
|
-
|
|
243
|
-
def info(self, workflows, **options):
|
|
244
|
-
"""
|
|
245
|
-
Get workflow information.
|
|
246
|
-
PATH: /{apiVersion}/workflows/{workflows}/info
|
|
247
|
-
|
|
248
|
-
:param str workflows: Comma separated list sample IDs or UUIDs up to a
|
|
249
|
-
maximum of 100. (REQUIRED)
|
|
250
|
-
:param str include: Fields included in the response, whole JSON path
|
|
251
|
-
must be provided.
|
|
252
|
-
:param str exclude: Fields excluded in the response, whole JSON path
|
|
253
|
-
must be provided.
|
|
254
|
-
:param str study: Study [[organization@]project:]study where study and
|
|
255
|
-
project can be either the ID or UUID.
|
|
256
|
-
:param str version: Comma separated list of workflow versions. 'all'
|
|
257
|
-
to get all the workflow versions. Not supported if multiple
|
|
258
|
-
workflow ids are provided.
|
|
259
|
-
:param bool deleted: Boolean to retrieve deleted entries.
|
|
260
|
-
"""
|
|
261
|
-
|
|
262
|
-
return self._get(category='workflows', resource='info', query_id=workflows, **options)
|
|
263
|
-
|
pyopencga/rest_response.py
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import pandas as pd
|
|
3
|
-
|
|
4
|
-
from pyopencga.commons import deprecated
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class RestResponse:
|
|
8
|
-
def __init__(self, response):
|
|
9
|
-
self.apiVersion = response.get('apiVersion')
|
|
10
|
-
self.time = response.get('time')
|
|
11
|
-
self.events = response.get('events')
|
|
12
|
-
self.params = response.get('params')
|
|
13
|
-
self.responses = response.get('responses')
|
|
14
|
-
|
|
15
|
-
# TODO: Remove deprecated response in future release. Added for backwards compatibility
|
|
16
|
-
self.response = response.get('responses')
|
|
17
|
-
|
|
18
|
-
# TODO: Remove deprecated result. Added for backwards compatibility
|
|
19
|
-
for query_result in self.responses:
|
|
20
|
-
if 'results' in query_result:
|
|
21
|
-
query_result['result'] = query_result['results']
|
|
22
|
-
|
|
23
|
-
@deprecated
|
|
24
|
-
def first(self):
|
|
25
|
-
return self.responses[0]
|
|
26
|
-
|
|
27
|
-
def get_results(self, response_pos=0):
|
|
28
|
-
"""
|
|
29
|
-
Return the list of results of the response_pos response.
|
|
30
|
-
"""
|
|
31
|
-
return self.responses[response_pos]['results']
|
|
32
|
-
|
|
33
|
-
def get_result(self, result_pos, response_pos=0):
|
|
34
|
-
"""
|
|
35
|
-
Return the result 'result_pos' of the response 'response_pos'.
|
|
36
|
-
"""
|
|
37
|
-
return self.responses[response_pos]['results'][result_pos]
|
|
38
|
-
|
|
39
|
-
def get_responses(self):
|
|
40
|
-
"""
|
|
41
|
-
Return the list of responses
|
|
42
|
-
"""
|
|
43
|
-
return self.responses
|
|
44
|
-
|
|
45
|
-
def get_response(self, response_pos=0):
|
|
46
|
-
"""
|
|
47
|
-
Return the response_pos response.
|
|
48
|
-
"""
|
|
49
|
-
return self.responses[response_pos]
|
|
50
|
-
|
|
51
|
-
def result_iterator(self, response_pos=None):
|
|
52
|
-
"""
|
|
53
|
-
Return all results from all responses as an iterator
|
|
54
|
-
"""
|
|
55
|
-
if response_pos is None:
|
|
56
|
-
for response in self.responses:
|
|
57
|
-
for result in response['results']:
|
|
58
|
-
yield result
|
|
59
|
-
else:
|
|
60
|
-
for result in self.responses[response_pos]['results']:
|
|
61
|
-
yield result
|
|
62
|
-
|
|
63
|
-
@staticmethod
|
|
64
|
-
def _get_param_value(result, field):
|
|
65
|
-
items = field.split('.')
|
|
66
|
-
result2 = result
|
|
67
|
-
is_list = False
|
|
68
|
-
for item in items:
|
|
69
|
-
if item in result2:
|
|
70
|
-
if isinstance(result2[item], list):
|
|
71
|
-
if is_list:
|
|
72
|
-
return '.'
|
|
73
|
-
is_list = True
|
|
74
|
-
result2 = result2[item]
|
|
75
|
-
else:
|
|
76
|
-
if is_list:
|
|
77
|
-
if len(result2) == 0 or isinstance(result2[0][item], list):
|
|
78
|
-
return '.'
|
|
79
|
-
result2 = [r[item] for r in result2 if item in r]
|
|
80
|
-
else:
|
|
81
|
-
return '.'
|
|
82
|
-
if is_list:
|
|
83
|
-
if len(result2) == 0 or isinstance(result2[0], (list, dict)):
|
|
84
|
-
return '{} items'.format(len(result2))
|
|
85
|
-
return ','.join(map(str, set(result2)))
|
|
86
|
-
else:
|
|
87
|
-
return result2
|
|
88
|
-
|
|
89
|
-
def print_results(self, fields=None, response_pos=None, limit=None, separator='\t', title=None,
|
|
90
|
-
metadata=True, outfile=None):
|
|
91
|
-
outfhand = sys.stdout if outfile is None else open(outfile, 'w')
|
|
92
|
-
if title is not None:
|
|
93
|
-
outfhand.write(title + '\n' + '-'*(len(title)+5) + '\n')
|
|
94
|
-
if metadata:
|
|
95
|
-
for event_type in ['INFO', 'WARNING', 'ERROR']:
|
|
96
|
-
for event in self.get_response_events(event_type):
|
|
97
|
-
msg = '#{}: {}'.format(event['type'], event['description'])
|
|
98
|
-
if 'id' in event:
|
|
99
|
-
msg += ' ({})'.format(event['id'])
|
|
100
|
-
outfhand.write(msg + '\n')
|
|
101
|
-
outfhand.write('#Time: {}\n'.format(self.time))
|
|
102
|
-
outfhand.write('#Num matches: {}\n'.format(self.get_num_matches(response_pos)))
|
|
103
|
-
outfhand.write('#Num results: {}\n'.format(self.get_num_results(response_pos)))
|
|
104
|
-
outfhand.write('#Num inserted: {}\n'.format(self.get_num_inserted(response_pos)))
|
|
105
|
-
outfhand.write('#Num updated: {}\n'.format(self.get_num_updated(response_pos)))
|
|
106
|
-
outfhand.write('#Num deleted: {}\n'.format(self.get_num_deleted(response_pos)))
|
|
107
|
-
|
|
108
|
-
responses = [self.get_response(response_pos)] if response_pos is not None else self.get_responses()
|
|
109
|
-
for response in responses:
|
|
110
|
-
if fields:
|
|
111
|
-
fields = fields.split(',')
|
|
112
|
-
elif 'include' in self.params:
|
|
113
|
-
fields = self.params['include'].split(',')
|
|
114
|
-
else:
|
|
115
|
-
if response['results']:
|
|
116
|
-
fields = response['results'][0].keys()
|
|
117
|
-
|
|
118
|
-
limit = limit if limit is not None else len(response['results'])
|
|
119
|
-
if limit:
|
|
120
|
-
outfhand.write('#{}\n'.format(separator.join(fields)))
|
|
121
|
-
for result in response['results'][:limit]:
|
|
122
|
-
values = [self._get_param_value(result, field) for field in fields]
|
|
123
|
-
outfhand.write(separator.join(map(str, values)) + '\n')
|
|
124
|
-
|
|
125
|
-
def to_data_frame(self, response_pos=None):
|
|
126
|
-
responses = [self.get_response(response_pos)] if response_pos is not None else self.get_responses()
|
|
127
|
-
return pd.concat([pd.json_normalize(result) for response in responses
|
|
128
|
-
for result in response['results']]).reset_index(drop=True)
|
|
129
|
-
|
|
130
|
-
def get_response_events(self, event_type=None):
|
|
131
|
-
"""
|
|
132
|
-
Return response events by name
|
|
133
|
-
"""
|
|
134
|
-
event_names = ['INFO', 'WARNING', 'ERROR']
|
|
135
|
-
if event_type is None or self.events is None:
|
|
136
|
-
return self.events or []
|
|
137
|
-
elif event_type in event_names:
|
|
138
|
-
return [event for event in self.events if event['type'] == event_type]
|
|
139
|
-
else:
|
|
140
|
-
msg = 'Argument "type" must be one of the following values: "{}"'
|
|
141
|
-
raise ValueError(msg.format(', '.join(event_names)))
|
|
142
|
-
|
|
143
|
-
def get_result_events(self, event_type=None, response_pos=0):
|
|
144
|
-
"""Return result events by name and position"""
|
|
145
|
-
event_names = ['INFO', 'WARNING', 'ERROR']
|
|
146
|
-
response = self.responses[response_pos]
|
|
147
|
-
if event_type is None:
|
|
148
|
-
return response['events'] \
|
|
149
|
-
if 'events' in response and response['events'] else []
|
|
150
|
-
elif event_type in event_names:
|
|
151
|
-
return [event for event in response['events'] if event['type'] == event_type] \
|
|
152
|
-
if 'events' in response and response['events'] else []
|
|
153
|
-
else:
|
|
154
|
-
msg = 'Argument "type" must be one of the following values: "{}"'
|
|
155
|
-
raise ValueError(msg.format(', '.join(event_names)))
|
|
156
|
-
|
|
157
|
-
def get_num_matches(self, response_pos=None):
|
|
158
|
-
"""
|
|
159
|
-
Return number of matches
|
|
160
|
-
"""
|
|
161
|
-
if response_pos is not None:
|
|
162
|
-
return self.responses[response_pos]['numMatches']
|
|
163
|
-
else:
|
|
164
|
-
num_matches = 0
|
|
165
|
-
for query_result in self.responses:
|
|
166
|
-
if 'numMatches' in query_result:
|
|
167
|
-
num_matches += query_result['numMatches']
|
|
168
|
-
return num_matches
|
|
169
|
-
|
|
170
|
-
def get_num_results(self, response_pos=None):
|
|
171
|
-
"""
|
|
172
|
-
Return number of results
|
|
173
|
-
"""
|
|
174
|
-
if response_pos is not None:
|
|
175
|
-
return self.responses[response_pos]['numResults']
|
|
176
|
-
else:
|
|
177
|
-
num_results = 0
|
|
178
|
-
for query_result in self.responses:
|
|
179
|
-
if 'numResults' in query_result:
|
|
180
|
-
num_results += query_result['numResults']
|
|
181
|
-
return num_results
|
|
182
|
-
|
|
183
|
-
def get_num_inserted(self, response_pos=None):
|
|
184
|
-
"""
|
|
185
|
-
Return number of inserted
|
|
186
|
-
"""
|
|
187
|
-
if response_pos is not None:
|
|
188
|
-
return self.responses[response_pos]['numInserted']
|
|
189
|
-
else:
|
|
190
|
-
num_inserted = 0
|
|
191
|
-
for query_result in self.responses:
|
|
192
|
-
if 'numInserted' in query_result:
|
|
193
|
-
num_inserted += query_result['numInserted']
|
|
194
|
-
return num_inserted
|
|
195
|
-
|
|
196
|
-
def get_num_updated(self, response_pos=None):
|
|
197
|
-
"""
|
|
198
|
-
Return number of updated
|
|
199
|
-
"""
|
|
200
|
-
if response_pos is not None:
|
|
201
|
-
return self.responses[response_pos]['numUpdated']
|
|
202
|
-
else:
|
|
203
|
-
num_updated = 0
|
|
204
|
-
for query_result in self.responses:
|
|
205
|
-
if 'numUpdated' in query_result:
|
|
206
|
-
num_updated += query_result['numUpdated']
|
|
207
|
-
return num_updated
|
|
208
|
-
|
|
209
|
-
def get_num_deleted(self, response_pos=None):
|
|
210
|
-
"""
|
|
211
|
-
Return number of deleted
|
|
212
|
-
"""
|
|
213
|
-
if response_pos is not None:
|
|
214
|
-
return self.responses[response_pos]['numDeleted']
|
|
215
|
-
else:
|
|
216
|
-
num_deleted = 0
|
|
217
|
-
for query_result in self.responses:
|
|
218
|
-
if 'numDeleted' in query_result:
|
|
219
|
-
num_deleted += query_result['numDeleted']
|
|
220
|
-
return num_deleted
|
pyopencga/retry.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module defines a function to retry execution of a function.
|
|
3
|
-
"""
|
|
4
|
-
import sys
|
|
5
|
-
import time
|
|
6
|
-
|
|
7
|
-
from pyopencga.exceptions import OpencgaAuthorisationError, OpencgaInvalidToken
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def retry(func, max_attempts, initial_retry_seconds, max_retry_seconds,
|
|
11
|
-
login_handler=None, on_retry=None, dont_retry=None):
|
|
12
|
-
"""
|
|
13
|
-
Attempt a function and retry until success or until running out of
|
|
14
|
-
allowed attempts.
|
|
15
|
-
:param func: function to invoke - parameterless
|
|
16
|
-
:param max_attempts: int: maximum number of attempts allowed
|
|
17
|
-
:param initial_retry_seconds: initial number of seconds to wait between retries.
|
|
18
|
-
The wait time is doubled after each failure, until max_retry_seconds is
|
|
19
|
-
reached.
|
|
20
|
-
:param max_retry_seconds: int: see initial_retry_seconds
|
|
21
|
-
:param login_handler: optional; if provided, then if calling func()
|
|
22
|
-
results in an error because the sessionId is invalid, login_handler()
|
|
23
|
-
will be called and this failed attempt will not count towards the maximum
|
|
24
|
-
of attempts
|
|
25
|
-
:param on_retry: a callback to be called before retrying. Must accept 3 parameters:
|
|
26
|
-
exception value, exception type, traceback.
|
|
27
|
-
:param dont_retry: optional; List of strings, if any are present in the exception
|
|
28
|
-
message don't retry
|
|
29
|
-
:return: the result of func() if successful, otherwise the last exception raised
|
|
30
|
-
by calling func.
|
|
31
|
-
"""
|
|
32
|
-
attempt_number = 1
|
|
33
|
-
retry_seconds = initial_retry_seconds
|
|
34
|
-
while True:
|
|
35
|
-
try:
|
|
36
|
-
return func()
|
|
37
|
-
except OpencgaInvalidToken as e:
|
|
38
|
-
|
|
39
|
-
if login_handler:
|
|
40
|
-
login_handler()
|
|
41
|
-
else:
|
|
42
|
-
raise e
|
|
43
|
-
except OpencgaAuthorisationError as e:
|
|
44
|
-
raise e
|
|
45
|
-
except Exception as e:
|
|
46
|
-
if dont_retry and any(string_ in str(e) for string_ in dont_retry):
|
|
47
|
-
raise e
|
|
48
|
-
if attempt_number >= max_attempts: # last attempt failed, propagate error:
|
|
49
|
-
raise
|
|
50
|
-
if on_retry:
|
|
51
|
-
# notify that we are retrying
|
|
52
|
-
exc_type, exc_val, exc_tb = sys.exc_info()
|
|
53
|
-
on_retry(exc_type, exc_val, exc_tb)
|
|
54
|
-
|
|
55
|
-
time.sleep(retry_seconds)
|
|
56
|
-
attempt_number += 1
|
|
57
|
-
retry_seconds = min(retry_seconds * 2, max_retry_seconds)
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
pyopencga/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
pyopencga/commons.py,sha256=asnM3N7Q6JdgD6hXWmlX875HJizTLAODqs0dl3UYH-E,14307
|
|
3
|
-
pyopencga/exceptions.py,sha256=GmtDcurD3d_fzaa8AEntF4-sZR4Elgg4Iz3z-UUqjYU,274
|
|
4
|
-
pyopencga/opencga_client.py,sha256=gM9UzbjXwHKYRbsz3qmhS8xHuIlr13sn-VEzx6cscxk,14858
|
|
5
|
-
pyopencga/opencga_config.py,sha256=RK23fextK79S5wq4FaQygwuPnE4p4J9GbjY6hJ0Krxc,7009
|
|
6
|
-
pyopencga/rest_response.py,sha256=Gx7utYTsXV-aciFZV4f7M2eNDQg5IlphGK_T8q_PhHE,8634
|
|
7
|
-
pyopencga/retry.py,sha256=_X02bDcJmr9cWH4Bt0YfUPkYborpuStmw5WDDKczwHM,2296
|
|
8
|
-
pyopencga/rest_clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
pyopencga/rest_clients/_parent_rest_clients.py,sha256=6_U1y3fwOCDDlfrdzoigkgbUZke8Msu6dW87CZPwccU,4277
|
|
10
|
-
pyopencga/rest_clients/admin_client.py,sha256=jn34TGFeonEvsC4bEpiw7_kTkH_R47Joo3T3grz8LTs,6926
|
|
11
|
-
pyopencga/rest_clients/alignment_client.py,sha256=qVce3PTZcoYj2HIOwKtHgTp-GNDMnAG6zIWcLDnnWdM,18508
|
|
12
|
-
pyopencga/rest_clients/clinical_analysis_client.py,sha256=e14y-qJznmAIMsIVpdh2ynv5pXx2yjOq7r7Mq_yVSkg,69578
|
|
13
|
-
pyopencga/rest_clients/cohort_client.py,sha256=6HcNiUL3WVsLfRtcitwJuxyraECJ6RExV8GvE2oQhDM,16323
|
|
14
|
-
pyopencga/rest_clients/disease_panel_client.py,sha256=dD5_nzetek5Hk2sSqT1JasdNu8ohkO3yMfdY76jGU8U,18512
|
|
15
|
-
pyopencga/rest_clients/family_client.py,sha256=MC8WHfzycB7WeRqb8FZEt2YLFTNrdSnky-bHwsr-6uY,18585
|
|
16
|
-
pyopencga/rest_clients/file_client.py,sha256=SnFrV6Bs-_ZMoZMoGviNMK1yi2xLXnTQCjm20ovecew,33729
|
|
17
|
-
pyopencga/rest_clients/ga4gh_client.py,sha256=iU0PvOmxTbhFS-AUD6BDp41uU1BAxWJUiiv1waioX6A,3505
|
|
18
|
-
pyopencga/rest_clients/individual_client.py,sha256=jYO4nHluP-gsdX7iM43qwlP9t9QIZBPiUv8sNXMOQ1Q,23224
|
|
19
|
-
pyopencga/rest_clients/job_client.py,sha256=2u1fBSFb87gRsxcsF6ySQGgnKSJLCiaczrxUQ_iAesQ,19810
|
|
20
|
-
pyopencga/rest_clients/meta_client.py,sha256=xVN3YcOrCmoq2Nsx2vZoA-K40phHyWWAlR-GS-h1T0w,2307
|
|
21
|
-
pyopencga/rest_clients/organization_client.py,sha256=wOv7E5kStrRt8FoqA4Xo6q0eVenf367vhfa5KZ8hQCs,9464
|
|
22
|
-
pyopencga/rest_clients/project_client.py,sha256=XuajvAQB9qUGhYRpmZxA1bBkgDkgyS78w-BUepIidtI,5211
|
|
23
|
-
pyopencga/rest_clients/sample_client.py,sha256=UAUDzZCfIaSKCwaIGe11ek11w_tMcxGqNaRXTYwbjMg,23620
|
|
24
|
-
pyopencga/rest_clients/study_client.py,sha256=1ba7-zOxP6ZX_YLpKkzFsfBVBZk4rwRwVoZzzaMVPDo,21490
|
|
25
|
-
pyopencga/rest_clients/user_client.py,sha256=XS4FDLuPaDt9VKHlLIYixvqqLRfBEZ9pwzblUM3GDfQ,7147
|
|
26
|
-
pyopencga/rest_clients/variant_client.py,sha256=qao-KWLjp04mDN3q7tQYsJzsQpxMaMvMzE8zAp8t7pg,75435
|
|
27
|
-
pyopencga/rest_clients/variant_operation_client.py,sha256=Xcr5l1Sf-nJcPitEFUVS331eotgtQt1pgLK-RJqe2Vc,38245
|
|
28
|
-
pyopencga/rest_clients/workflow_client.py,sha256=TN_x3CpC-GIojfsJNZmwPMCeXMUSPxKIas2PnNN18H4,12481
|
|
29
|
-
pyxetabase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
|
-
pyxetabase/commons.py,sha256=Okt5DgvSpZW9PUsxoLNpROb0BDrdr_zhgry4X3dQpfk,14308
|
|
31
|
-
pyxetabase/exceptions.py,sha256=GmtDcurD3d_fzaa8AEntF4-sZR4Elgg4Iz3z-UUqjYU,274
|
|
32
|
-
pyxetabase/opencga_client.py,sha256=V-M9i28z3A-Vgw5BnG_Ddm0MUdjQ0_XG38gohGtzavI,15386
|
|
33
|
-
pyxetabase/opencga_config.py,sha256=RK23fextK79S5wq4FaQygwuPnE4p4J9GbjY6hJ0Krxc,7009
|
|
34
|
-
pyxetabase/rest_response.py,sha256=TgwTI2LZFF_jV9-HSawGkF_qZ88n-dxEtIKiFcfPyDk,8635
|
|
35
|
-
pyxetabase/retry.py,sha256=LjViQOaa_GkpDFkcRq9jIS183mE9t4Rq0uls9PV_mfI,2297
|
|
36
|
-
pyxetabase/rest_clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
|
-
pyxetabase/rest_clients/_parent_rest_clients.py,sha256=ZL9VxTxS1cRcg-ofrE9QJXYL8mlVkbXpvFvwhofo-uI,4280
|
|
38
|
-
pyxetabase/rest_clients/admin_client.py,sha256=WebfbQVa7CjiaNcp5MqwAkgDTqCfW-v5AgTaxmL5EF0,6927
|
|
39
|
-
pyxetabase/rest_clients/alignment_client.py,sha256=srY1fmjMZCPWlbqhrD2gYVhS2zu7fgPx61tZOqQi4Wc,18509
|
|
40
|
-
pyxetabase/rest_clients/clinical_analysis_client.py,sha256=j2LmLT8wg3C9srRMB2mksEVFnqN22Anb7HxZCbdF50c,69126
|
|
41
|
-
pyxetabase/rest_clients/cohort_client.py,sha256=D-su-AFOziztVMI-oAcr5G2Uq_psbLV8Wt0bqZ7zZgI,16324
|
|
42
|
-
pyxetabase/rest_clients/cvdb_client.py,sha256=V7ny5nQEeJqsbALAe7JLyoV6b0XyYF7c9lsn-qK-i8o,143102
|
|
43
|
-
pyxetabase/rest_clients/disease_panel_client.py,sha256=GAYRyAfoB_VunskXOhAzMNbsrFupb6M2QbRK3x1Y5vo,18513
|
|
44
|
-
pyxetabase/rest_clients/family_client.py,sha256=n-kyjnrV09R50JxyiHjFs8rCQkOKFU0Z1O7oVYuaKxg,18586
|
|
45
|
-
pyxetabase/rest_clients/federation_client.py,sha256=p5B8dRq9gj-fdgIfIPhmkT7mNU65cRFtH06kaGtmbWE,5066
|
|
46
|
-
pyxetabase/rest_clients/file_client.py,sha256=fwTWnZtprYNDUBvRetLLe6PTBxW_M8LxN6OlAMGWXC4,33730
|
|
47
|
-
pyxetabase/rest_clients/ga4gh_client.py,sha256=fPnmiblnfpz_zcZPJblGqOFksrdiF3MUer3fv2nwQwk,3506
|
|
48
|
-
pyxetabase/rest_clients/individual_client.py,sha256=C59zr_t7tTxNR7ZBeAPY6fyYl59fE7KY05MaLyXWmXw,23225
|
|
49
|
-
pyxetabase/rest_clients/job_client.py,sha256=amoBW3SL56l6sAPCUB55rZhLR8DcdIIfb5ymOZ9NkLQ,19811
|
|
50
|
-
pyxetabase/rest_clients/meta_client.py,sha256=uExVRfdSKiXteLYe7R3q9x3zCp9mMWWMyPDU56TtoDo,2308
|
|
51
|
-
pyxetabase/rest_clients/organization_client.py,sha256=tnwUTCqJoGiKXMQLMv4ymHA16JxnR5iL2SMLaJDBRs8,9465
|
|
52
|
-
pyxetabase/rest_clients/project_client.py,sha256=M8naPsj47z2ylTrJNU_JyHReKzXrB038PoEtKKrtxmc,5212
|
|
53
|
-
pyxetabase/rest_clients/sample_client.py,sha256=VOsPAhw9HwaEHzzw_5gcVQ1v2xSesvzN3TO4z2opaNo,23621
|
|
54
|
-
pyxetabase/rest_clients/study_client.py,sha256=STtboEiGP-lQ1UptjHxk-ANd3uG6cA6U3srvOO4UQIE,21491
|
|
55
|
-
pyxetabase/rest_clients/user_client.py,sha256=frA7-rMii-yoRyca_Orkj1T80OeEe-zCdWZCHKn1sio,7683
|
|
56
|
-
pyxetabase/rest_clients/variant_client.py,sha256=mmBuVE0JBThJr5zsLGci5nykNcCKyfZXRKl-h3HT9PA,75436
|
|
57
|
-
pyxetabase/rest_clients/variant_operation_client.py,sha256=z_9qEpZEoHF8lLfBq-i3wROnoiNjPjBavqPBepiTIyk,38246
|
|
58
|
-
pyxetabase/rest_clients/workflow_client.py,sha256=QYnyI17aNCjq-uXlguaSj78F0xupeWwmf8uYK1Y5tf4,12482
|
|
59
|
-
pyxetabase-4.0.0.dev0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
60
|
-
pyxetabase-4.0.0.dev0.dist-info/METADATA,sha256=o-VtZAPy4QPUOhwyfof54Uj1aG73tPOmHWn3Ucc2aZM,5539
|
|
61
|
-
pyxetabase-4.0.0.dev0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
62
|
-
pyxetabase-4.0.0.dev0.dist-info/top_level.txt,sha256=0m5pDpBX-lM8QpPl7bTpTQAm4kgu2-nr-pcaEu4Tn_8,11
|
|
63
|
-
pyxetabase-4.0.0.dev0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|