deriva 1.7.0__py3-none-any.whl → 1.7.3__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.
- deriva/config/annotation_config.py +2 -2
- deriva/core/__init__.py +1 -1
- deriva/core/catalog_cli.py +83 -39
- deriva/core/datapath.py +519 -26
- deriva/core/ermrest_catalog.py +103 -23
- deriva/core/ermrest_model.py +387 -7
- deriva/core/hatrac_cli.py +5 -3
- deriva/core/utils/globus_auth_utils.py +3 -1
- deriva/transfer/__init__.py +4 -2
- deriva/transfer/download/__init__.py +4 -0
- deriva/transfer/download/deriva_download.py +33 -13
- deriva/transfer/download/deriva_download_cli.py +3 -2
- deriva/transfer/download/processors/query/base_query_processor.py +9 -4
- deriva/transfer/upload/__init__.py +4 -0
- deriva/transfer/upload/deriva_upload.py +9 -2
- deriva/transfer/upload/deriva_upload_cli.py +2 -2
- {deriva-1.7.0.dist-info → deriva-1.7.3.dist-info}/METADATA +2 -2
- {deriva-1.7.0.dist-info → deriva-1.7.3.dist-info}/RECORD +23 -23
- tests/deriva/core/test_datapath.py +24 -2
- {deriva-1.7.0.dist-info → deriva-1.7.3.dist-info}/LICENSE +0 -0
- {deriva-1.7.0.dist-info → deriva-1.7.3.dist-info}/WHEEL +0 -0
- {deriva-1.7.0.dist-info → deriva-1.7.3.dist-info}/entry_points.txt +0 -0
- {deriva-1.7.0.dist-info → deriva-1.7.3.dist-info}/top_level.txt +0 -0
|
@@ -33,7 +33,7 @@ class AttrSpecList(BaseSpecList):
|
|
|
33
33
|
return None
|
|
34
34
|
new = []
|
|
35
35
|
for item in orig_list:
|
|
36
|
-
new.append(
|
|
36
|
+
new.append(item)
|
|
37
37
|
return new
|
|
38
38
|
|
|
39
39
|
def add_list(self, dictlist):
|
|
@@ -85,7 +85,7 @@ class AttrConfig:
|
|
|
85
85
|
self.toplevel_config = ConfigUtil.find_toplevel_node(self.catalog.getCatalogModel(), schema_name, table_name)
|
|
86
86
|
|
|
87
87
|
def make_speclist(self, name):
|
|
88
|
-
d = self.config.get(
|
|
88
|
+
d = self.config.get(name)
|
|
89
89
|
if d is None:
|
|
90
90
|
d = [dict()]
|
|
91
91
|
return AttrSpecList(self.known_attrs, d)
|
deriva/core/__init__.py
CHANGED
deriva/core/catalog_cli.py
CHANGED
|
@@ -55,21 +55,21 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
55
55
|
|
|
56
56
|
# parent arg parser
|
|
57
57
|
self.remove_options(['--config-file', '--credential-file'])
|
|
58
|
-
self.parser.add_argument("--protocol", choices=["http", "https"], default='https',
|
|
58
|
+
self.parser.add_argument("-p", "--protocol", choices=["http", "https"], default='https',
|
|
59
59
|
help="transport protocol: 'http' or 'https'")
|
|
60
60
|
subparsers = self.parser.add_subparsers(title='sub-commands', dest='subcmd')
|
|
61
61
|
|
|
62
62
|
# exists parser
|
|
63
63
|
exists_parser = subparsers.add_parser('exists', help="Check if catalog exists.")
|
|
64
|
-
exists_parser.add_argument("id", metavar="<id>", type=str, help="
|
|
64
|
+
exists_parser.add_argument("id", metavar="<id>", type=str, help="Catalog ID")
|
|
65
65
|
exists_parser.set_defaults(func=self.catalog_exists)
|
|
66
66
|
|
|
67
67
|
# create parser
|
|
68
68
|
create_parser = subparsers.add_parser('create', help="Create a new catalog.")
|
|
69
|
-
create_parser.add_argument("--id", metavar="<id>", type=str, help="
|
|
70
|
-
create_parser.add_argument("--owner", metavar="<owner> <owner> ...",
|
|
69
|
+
create_parser.add_argument("--id", metavar="<id>", type=str, help="Catalog ID")
|
|
70
|
+
create_parser.add_argument("-o", "--owner", metavar="<owner> <owner> ...",
|
|
71
71
|
nargs="+", help="List of quoted user or group identifier strings.")
|
|
72
|
-
create_parser.add_argument("--auto-configure", action="store_true",
|
|
72
|
+
create_parser.add_argument("-a", "--auto-configure", action="store_true",
|
|
73
73
|
help="Configure the new catalog with a set of baseline defaults")
|
|
74
74
|
create_parser.add_argument("--configure-args", metavar="[key=value key=value ...]",
|
|
75
75
|
nargs='+', action=KeyValuePairArgs, default={},
|
|
@@ -80,11 +80,12 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
80
80
|
|
|
81
81
|
# get parser
|
|
82
82
|
get_parser = subparsers.add_parser('get', help="Send a HTTP GET request to the catalog.")
|
|
83
|
-
get_parser.add_argument("id", metavar="<id>", type=str, help="
|
|
83
|
+
get_parser.add_argument("id", metavar="<id>", type=str, help="Catalog ID")
|
|
84
84
|
get_parser.add_argument("path", metavar="<request-path>", help="The ERMRest API path.")
|
|
85
|
-
get_parser.add_argument("--output-file", metavar="<output file path>", help="Path to output file.")
|
|
86
|
-
get_parser.add_argument("--output-format", choices=["json", "json-stream", "csv"], default="json"
|
|
87
|
-
|
|
85
|
+
get_parser.add_argument("-o", "--output-file", metavar="<output file path>", help="Path to output file.")
|
|
86
|
+
get_parser.add_argument("-f", "--output-format", choices=["json", "json-stream", "csv"], default="json",
|
|
87
|
+
help="The output file format. Defaults to 'json'")
|
|
88
|
+
get_parser.add_argument("-a", "--auto-delete", action="store_true",
|
|
88
89
|
help="Automatically delete output file if no results are returned.")
|
|
89
90
|
get_parser.add_argument("--headers", metavar="[key=value key=value ...]",
|
|
90
91
|
nargs='+', action=KeyValuePairArgs, default={},
|
|
@@ -95,10 +96,12 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
95
96
|
|
|
96
97
|
# put parser
|
|
97
98
|
put_parser = subparsers.add_parser('put', help="Send a HTTP PUT request to the catalog.")
|
|
98
|
-
put_parser.add_argument("id", metavar="<id>", type=str, help="
|
|
99
|
+
put_parser.add_argument("id", metavar="<id>", type=str, help="Catalog ID")
|
|
99
100
|
put_parser.add_argument("path", metavar="<request-path>", help="The ERMRest API path.")
|
|
100
|
-
put_parser.add_argument("
|
|
101
|
-
|
|
101
|
+
put_parser.add_argument("input-file", metavar="<input file path>",
|
|
102
|
+
help="Path to an input file containing the request message body.")
|
|
103
|
+
put_parser.add_argument("-f", "--input-format", choices=["json", "json-stream", "csv"], default="json",
|
|
104
|
+
help="The input file format. Defaults to 'json'")
|
|
102
105
|
put_parser.add_argument("--headers", metavar="[key=value key=value ...]",
|
|
103
106
|
nargs='+', action=KeyValuePairArgs, default={},
|
|
104
107
|
help="Variable length of whitespace-delimited key=value pair arguments used for "
|
|
@@ -108,10 +111,12 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
108
111
|
|
|
109
112
|
# post parser
|
|
110
113
|
post_parser = subparsers.add_parser('post', help="Send a HTTP POST request to the catalog.")
|
|
111
|
-
post_parser.add_argument("id", metavar="<id>", type=str, help="
|
|
114
|
+
post_parser.add_argument("id", metavar="<id>", type=str, help="Catalog ID")
|
|
112
115
|
post_parser.add_argument("path", metavar="<request-path>", help="The ERMRest API path.")
|
|
113
|
-
post_parser.add_argument("
|
|
114
|
-
|
|
116
|
+
post_parser.add_argument("input-file", metavar="<input file path>",
|
|
117
|
+
help="Path to an input file containing the request message body.")
|
|
118
|
+
post_parser.add_argument("-f", "--input-format", choices=["json", "json-stream", "csv"], default="json",
|
|
119
|
+
help="The input file format. Defaults to 'json'")
|
|
115
120
|
post_parser.add_argument("--headers", metavar="[key=value key=value ...]",
|
|
116
121
|
nargs='+', action=KeyValuePairArgs, default={},
|
|
117
122
|
help="Variable length of whitespace-delimited key=value pair arguments used for "
|
|
@@ -122,7 +127,7 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
122
127
|
# delete parser
|
|
123
128
|
del_parser = subparsers.add_parser('delete', help="Send a HTTP DELETE request to the catalog. "
|
|
124
129
|
"Use the 'drop' command to delete the entire catalog.")
|
|
125
|
-
del_parser.add_argument("id", metavar="<id>", type=str, help="
|
|
130
|
+
del_parser.add_argument("id", metavar="<id>", type=str, help="Catalog ID")
|
|
126
131
|
del_parser.add_argument("path", metavar="<request-path>", help="The ERMRest API path.")
|
|
127
132
|
del_parser.add_argument("--headers", metavar="[key=value key=value ...]",
|
|
128
133
|
nargs='+', action=KeyValuePairArgs, default={},
|
|
@@ -133,12 +138,12 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
133
138
|
|
|
134
139
|
# drop parser
|
|
135
140
|
drop_parser = subparsers.add_parser('drop', help="Delete a catalog.")
|
|
136
|
-
drop_parser.add_argument("id", metavar="<id>", type=str, help="
|
|
141
|
+
drop_parser.add_argument("id", metavar="<id>", type=str, help="Catalog ID")
|
|
137
142
|
drop_parser.set_defaults(func=self.catalog_drop)
|
|
138
143
|
|
|
139
144
|
# clone parser
|
|
140
145
|
clone_parser = subparsers.add_parser('clone', help="Clone a source catalog to a new destination catalog.")
|
|
141
|
-
clone_parser.add_argument("id", metavar="<id>", type=str, help="
|
|
146
|
+
clone_parser.add_argument("id", metavar="<id>", type=str, help="Catalog ID")
|
|
142
147
|
clone_parser.add_argument("--no-copy-data", action="store_false",
|
|
143
148
|
help="Do not copy table contents.")
|
|
144
149
|
clone_parser.add_argument("--no-copy-annotations", action="store_false",
|
|
@@ -154,8 +159,8 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
154
159
|
# create_alias parser
|
|
155
160
|
create_alias_parser = subparsers.add_parser('create-alias', help="Create a new catalog alias")
|
|
156
161
|
create_alias_parser.add_argument("--id", metavar="<id>", type=str, help="The alias id.")
|
|
157
|
-
create_alias_parser.add_argument("--alias-target", metavar="<alias>", help="The target catalog id.")
|
|
158
|
-
create_alias_parser.add_argument("--owner", metavar="<owner> <owner> ...",
|
|
162
|
+
create_alias_parser.add_argument("-t", "--alias-target", metavar="<alias>", help="The target catalog id.")
|
|
163
|
+
create_alias_parser.add_argument("-o", "--owner", metavar="<owner> <owner> ...",
|
|
159
164
|
nargs="+", help="List of quoted user or group identifier strings.")
|
|
160
165
|
create_alias_parser.set_defaults(func=self.catalog_alias_create)
|
|
161
166
|
|
|
@@ -167,10 +172,10 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
167
172
|
# update_alias parser
|
|
168
173
|
update_alias_parser = subparsers.add_parser('update-alias', help="Update an existing catalog alias")
|
|
169
174
|
update_alias_parser.add_argument("--id", metavar="<id>", type=str, help="The alias id.")
|
|
170
|
-
update_alias_parser.add_argument("--alias-target", metavar="<alias>", nargs='?', default=nochange, const=None,
|
|
175
|
+
update_alias_parser.add_argument("-t", "--alias-target", metavar="<alias>", nargs='?', default=nochange, const=None,
|
|
171
176
|
help="The target catalog id. If specified without a catalog id as an argument "
|
|
172
177
|
"value, the existing alias target will be cleared ")
|
|
173
|
-
update_alias_parser.add_argument("--owner", metavar="<owner> <owner> ...", nargs='+', default=nochange,
|
|
178
|
+
update_alias_parser.add_argument("-o", "--owner", metavar="<owner> <owner> ...", nargs='+', default=nochange,
|
|
174
179
|
help="List of quoted user or group identifier strings.")
|
|
175
180
|
update_alias_parser.set_defaults(func=self.catalog_alias_update)
|
|
176
181
|
|
|
@@ -194,9 +199,29 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
194
199
|
self.id = args.id
|
|
195
200
|
self.server = DerivaServer(self.protocol,
|
|
196
201
|
args.host,
|
|
197
|
-
credentials=DerivaCatalogCLI._get_credential(
|
|
198
|
-
|
|
199
|
-
|
|
202
|
+
credentials=DerivaCatalogCLI._get_credential(
|
|
203
|
+
self.host,
|
|
204
|
+
token=args.token,
|
|
205
|
+
oauth2_token=args.oauth2_token))
|
|
206
|
+
|
|
207
|
+
@staticmethod
|
|
208
|
+
def _decorate_headers(headers, file_format, method="get"):
|
|
209
|
+
|
|
210
|
+
header_format_map = {
|
|
211
|
+
"json": "application/json",
|
|
212
|
+
"json-stream": "application/x-json-stream",
|
|
213
|
+
"csv": "text/csv"
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
format_type = header_format_map.get(file_format)
|
|
217
|
+
if format_type is None:
|
|
218
|
+
raise UsageException("Unsupported format: %s" % file_format)
|
|
219
|
+
if str(method).lower() in ["get", "head"]:
|
|
220
|
+
headers["accept"] = format_type
|
|
221
|
+
elif str(method).lower() in ["post", "put"]:
|
|
222
|
+
headers["content-type"] = format_type
|
|
223
|
+
else:
|
|
224
|
+
raise UsageException("Unsupported method: %s" % method)
|
|
200
225
|
|
|
201
226
|
def catalog_exists(self, args):
|
|
202
227
|
"""Implements the catalog_exists sub-command.
|
|
@@ -250,16 +275,7 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
250
275
|
"""
|
|
251
276
|
headers = DEFAULT_HEADERS.copy()
|
|
252
277
|
headers.update(args.headers)
|
|
253
|
-
|
|
254
|
-
if args.output_format == "json":
|
|
255
|
-
headers["accept"] = "application/json"
|
|
256
|
-
elif args.output_format == "json-stream":
|
|
257
|
-
headers["accept"] = "application/x-json-stream"
|
|
258
|
-
elif args.output_format == "csv":
|
|
259
|
-
headers["accept"] = "text/csv"
|
|
260
|
-
else:
|
|
261
|
-
raise UsageException("Unsupported output format: %s" % args.output_format)
|
|
262
|
-
|
|
278
|
+
self._decorate_headers(headers, args.output_format)
|
|
263
279
|
catalog = self.server.connect_ermrest(args.id)
|
|
264
280
|
try:
|
|
265
281
|
if args.output_file:
|
|
@@ -278,13 +294,41 @@ class DerivaCatalogCLI (BaseCLI):
|
|
|
278
294
|
os.remove(args.output_file)
|
|
279
295
|
raise
|
|
280
296
|
|
|
281
|
-
# TODO: implement PUT at some point
|
|
282
297
|
def catalog_put(self, args):
|
|
283
|
-
|
|
298
|
+
"""Implements the catalog_put sub-command.
|
|
299
|
+
"""
|
|
300
|
+
headers = DEFAULT_HEADERS.copy()
|
|
301
|
+
headers.update(args.headers)
|
|
302
|
+
self._decorate_headers(headers, args.input_format, "put")
|
|
303
|
+
try:
|
|
304
|
+
catalog = self.server.connect_ermrest(args.id)
|
|
305
|
+
with open(args.input_file, "rb") as input_file:
|
|
306
|
+
resp = catalog.put(args.path, data=input_file, headers=headers)
|
|
307
|
+
if not args.quiet:
|
|
308
|
+
pp(resp.json())
|
|
309
|
+
except HTTPError as e:
|
|
310
|
+
if e.response.status_code == requests.codes.not_found:
|
|
311
|
+
raise ResourceException('Catalog not found', e)
|
|
312
|
+
else:
|
|
313
|
+
raise e
|
|
284
314
|
|
|
285
|
-
# TODO: implement POST at some point
|
|
286
315
|
def catalog_post(self, args):
|
|
287
|
-
|
|
316
|
+
"""Implements the catalog_post sub-command.
|
|
317
|
+
"""
|
|
318
|
+
headers = DEFAULT_HEADERS.copy()
|
|
319
|
+
headers.update(args.headers)
|
|
320
|
+
self._decorate_headers(headers, args.input_format, "post")
|
|
321
|
+
try:
|
|
322
|
+
catalog = self.server.connect_ermrest(args.id)
|
|
323
|
+
with open(args.input_file, "rb") as input_file:
|
|
324
|
+
resp = catalog.post(args.path, data=input_file, headers=headers)
|
|
325
|
+
if not args.quiet:
|
|
326
|
+
pp(resp.json())
|
|
327
|
+
except HTTPError as e:
|
|
328
|
+
if e.response.status_code == requests.codes.not_found:
|
|
329
|
+
raise ResourceException('Catalog not found', e)
|
|
330
|
+
else:
|
|
331
|
+
raise e
|
|
288
332
|
|
|
289
333
|
def catalog_delete(self, args):
|
|
290
334
|
"""Implements the catalog_delete sub-command.
|