dcicutils 8.13.3__py3-none-any.whl → 8.13.3.1b2__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- dcicutils/common.py +1 -2
- dcicutils/qa_checkers.py +1 -2
- dcicutils/qa_utils.py +1 -2
- dcicutils/s3_utils.py +1 -2
- dcicutils/scripts/view_portal_object.py +41 -29
- {dcicutils-8.13.3.dist-info → dcicutils-8.13.3.1b2.dist-info}/METADATA +4 -4
- {dcicutils-8.13.3.dist-info → dcicutils-8.13.3.1b2.dist-info}/RECORD +10 -10
- {dcicutils-8.13.3.dist-info → dcicutils-8.13.3.1b2.dist-info}/LICENSE.txt +0 -0
- {dcicutils-8.13.3.dist-info → dcicutils-8.13.3.1b2.dist-info}/WHEEL +0 -0
- {dcicutils-8.13.3.dist-info → dcicutils-8.13.3.1b2.dist-info}/entry_points.txt +0 -0
dcicutils/common.py
CHANGED
dcicutils/qa_checkers.py
CHANGED
@@ -6,8 +6,7 @@ import toml
|
|
6
6
|
import warnings
|
7
7
|
|
8
8
|
from collections import defaultdict
|
9
|
-
from typing import Optional, List, Dict, Type
|
10
|
-
from typing_extensions import Literal
|
9
|
+
from typing import Optional, List, Dict, Type, Literal
|
11
10
|
from .contribution_utils import Contributions
|
12
11
|
from .lang_utils import conjoined_list, n_of, there_are
|
13
12
|
from .misc_utils import PRINT, remove_prefix, remove_suffix, getattr_customized, CustomizableProperty
|
dcicutils/qa_utils.py
CHANGED
@@ -25,8 +25,7 @@ from botocore.credentials import Credentials as Boto3Credentials
|
|
25
25
|
from botocore.exceptions import ClientError
|
26
26
|
from collections import defaultdict
|
27
27
|
from json import dumps as json_dumps, loads as json_loads
|
28
|
-
from typing import Any, Optional, List, DefaultDict, Union, Type, Dict
|
29
|
-
from typing_extensions import Literal
|
28
|
+
from typing import Any, Optional, List, DefaultDict, Union, Type, Dict, Literal
|
30
29
|
from unittest import mock
|
31
30
|
from . import misc_utils as misc_utils_module, command_utils as command_utils_module
|
32
31
|
from .common import S3StorageClass
|
dcicutils/s3_utils.py
CHANGED
@@ -5,8 +5,7 @@ import mimetypes
|
|
5
5
|
import os
|
6
6
|
|
7
7
|
from io import BytesIO
|
8
|
-
from typing import Optional, Any, Union
|
9
|
-
from typing_extensions import Literal
|
8
|
+
from typing import Optional, Any, Union, Literal
|
10
9
|
from zipfile import ZipFile
|
11
10
|
from .base import get_beanstalk_real_url
|
12
11
|
from .common import (
|
@@ -114,16 +114,13 @@ def main():
|
|
114
114
|
help="Copy object data to clipboard.")
|
115
115
|
parser.add_argument("--output", required=False, help="Output file.", type=str)
|
116
116
|
parser.add_argument("--indent", required=False, default=False, help="Indent output.", type=int)
|
117
|
-
parser.add_argument("--
|
118
|
-
|
119
|
-
|
117
|
+
parser.add_argument("--summary", action="store_true", required=False, default=False,
|
118
|
+
help="Summary output (for schema only).")
|
119
|
+
parser.add_argument("--terse", action="store_true", required=False, default=False, help="Terse output.")
|
120
120
|
parser.add_argument("--verbose", action="store_true", required=False, default=False, help="Verbose output.")
|
121
121
|
parser.add_argument("--debug", action="store_true", required=False, default=False, help="Debugging output.")
|
122
122
|
args = parser.parse_args()
|
123
123
|
|
124
|
-
if args.more_details:
|
125
|
-
args.details = True
|
126
|
-
|
127
124
|
portal = _create_portal(ini=args.ini, env=args.env or os.environ.get("SMAHT_ENV"),
|
128
125
|
server=args.server, app=args.app, verbose=args.verbose, debug=args.debug)
|
129
126
|
|
@@ -143,9 +140,8 @@ def main():
|
|
143
140
|
_output_file = io.open(args.output, "w")
|
144
141
|
|
145
142
|
if args.uuid and ((args.uuid.lower() == "schemas") or (args.uuid.lower() == "schema")):
|
146
|
-
_print_all_schema_names(portal=portal,
|
147
|
-
|
148
|
-
tree=args.tree, raw=args.raw, raw_yaml=args.yaml)
|
143
|
+
_print_all_schema_names(portal=portal, terse=args.terse, all=args.all,
|
144
|
+
tree=args.tree, summary=args.summary, yaml=args.yaml)
|
149
145
|
return
|
150
146
|
elif args.uuid and (args.uuid.lower() == "info"):
|
151
147
|
if consortia := portal.get_metadata("/consortia?limit=1000"):
|
@@ -182,7 +178,7 @@ def main():
|
|
182
178
|
if schema:
|
183
179
|
if args.copy:
|
184
180
|
pyperclip.copy(json.dumps(schema, indent=4))
|
185
|
-
if
|
181
|
+
if args.summary:
|
186
182
|
if parent_schema_name := _get_parent_schema_name(schema):
|
187
183
|
if schema.get("isAbstract") is True:
|
188
184
|
_print_output(f"{schema_name} | parent: {parent_schema_name} | abstract")
|
@@ -190,8 +186,8 @@ def main():
|
|
190
186
|
_print_output(f"{schema_name} | parent: {parent_schema_name}")
|
191
187
|
else:
|
192
188
|
_print_output(schema_name)
|
193
|
-
_print_schema(schema,
|
194
|
-
all=args.all,
|
189
|
+
_print_schema(schema, terse=args.terse,
|
190
|
+
all=args.all, summary=args.summary, yaml=args.yaml)
|
195
191
|
return
|
196
192
|
|
197
193
|
data = _get_portal_object(portal=portal, uuid=args.uuid, raw=args.raw, inserts=args.inserts,
|
@@ -276,9 +272,26 @@ def _get_portal_object(portal: Portal, uuid: str,
|
|
276
272
|
(isinstance(results_type := response.get("@type"), list) and results_type) and
|
277
273
|
(isinstance(results_type := results_type[0], str) and results_type.endswith("SearchResults")) and
|
278
274
|
(results_type := results_type[0:-len("SearchResults")])): # noqa
|
275
|
+
# For search results, the type (from XyzSearchResults, above) may not be precisely correct for
|
276
|
+
# each of the results; it may be the supertype (e.g. QualityMetric vs QualityMetricWorkflowRun);
|
277
|
+
# so for types which are supertypes (gotten via Portal.get_schemas_super_type_map) we actually
|
278
|
+
# lookup each result individually to determine its actual precise type.
|
279
|
+
if not ((supertypes := portal.get_schemas_super_type_map()) and (subtypes := supertypes.get(results_type))):
|
280
|
+
subtypes = None
|
281
|
+
response = {}
|
279
282
|
for result in results:
|
280
283
|
result.pop("schema_version", None)
|
281
|
-
|
284
|
+
if (subtypes and
|
285
|
+
(result_uuid := result.get("uuid")) and
|
286
|
+
(individual_result := portal.get_metadata(result_uuid, raise_exception=False)) and
|
287
|
+
isinstance(result_type:= individual_result.get("@type"), list) and result_type and result_type[0]): # noqa
|
288
|
+
result_type = result_type[0]
|
289
|
+
else:
|
290
|
+
result_type = results_type
|
291
|
+
if response.get(result_type):
|
292
|
+
response[result_type].append(result)
|
293
|
+
else:
|
294
|
+
response[result_type] = [result]
|
282
295
|
# Get the result as non-raw so we can get its type.
|
283
296
|
elif ((response_cooked := portal.get(path, database=database)) and
|
284
297
|
(isinstance(response_type := response_cooked.json().get("@type"), list) and response_type)):
|
@@ -332,19 +345,19 @@ def _get_schema_name_from_schema_named_json_file_name(portal: Portal, value: str
|
|
332
345
|
return False
|
333
346
|
|
334
347
|
|
335
|
-
def _print_schema(schema: dict,
|
336
|
-
|
337
|
-
if
|
338
|
-
if
|
348
|
+
def _print_schema(schema: dict, terse: bool = False, all: bool = False,
|
349
|
+
summary: bool = False, yaml: bool = False) -> None:
|
350
|
+
if summary is not True:
|
351
|
+
if yaml:
|
339
352
|
_print_output(yaml.dump(schema))
|
340
353
|
else:
|
341
354
|
_print_output(json.dumps(schema, indent=4))
|
342
355
|
return
|
343
|
-
_print_schema_info(schema,
|
356
|
+
_print_schema_info(schema, terse=terse, all=all)
|
344
357
|
|
345
358
|
|
346
359
|
def _print_schema_info(schema: dict, level: int = 0,
|
347
|
-
|
360
|
+
terse: bool = False, all: bool = False,
|
348
361
|
required: Optional[List[str]] = None) -> None:
|
349
362
|
if not schema or not isinstance(schema, dict):
|
350
363
|
return
|
@@ -396,7 +409,7 @@ def _print_schema_info(schema: dict, level: int = 0,
|
|
396
409
|
_print_output(f" - {reference_property['name']}: {reference_property['ref']}")
|
397
410
|
if schema.get("additionalProperties") is True:
|
398
411
|
_print_output(f" - additional properties are allowed")
|
399
|
-
if
|
412
|
+
if terse:
|
400
413
|
return
|
401
414
|
if properties := (schema.get("properties") if level == 0 else schema):
|
402
415
|
if level == 0:
|
@@ -422,8 +435,7 @@ def _print_schema_info(schema: dict, level: int = 0,
|
|
422
435
|
if property.get("calculatedProperty"):
|
423
436
|
suffix += f" | calculated"
|
424
437
|
_print_output(f"{spaces}- {property_name}: {property_type}{suffix}")
|
425
|
-
_print_schema_info(object_properties, level=level + 1,
|
426
|
-
details=details, more_details=more_details, all=all,
|
438
|
+
_print_schema_info(object_properties, level=level + 1, terse=terse, all=all,
|
427
439
|
required=property.get("required"))
|
428
440
|
elif property_type == "array":
|
429
441
|
suffix = ""
|
@@ -447,7 +459,7 @@ def _print_schema_info(schema: dict, level: int = 0,
|
|
447
459
|
suffix = ""
|
448
460
|
_print_output(f"{spaces}- {property_name}: array of object{suffix}")
|
449
461
|
_print_schema_info(property_items.get("properties"), level=level + 1,
|
450
|
-
|
462
|
+
terse=terse, all=all,
|
451
463
|
required=property_items.get("required"))
|
452
464
|
elif property_type == "array":
|
453
465
|
# This (array-of-array) never happens to occur at this time (February 2024).
|
@@ -523,13 +535,13 @@ def _print_schema_info(schema: dict, level: int = 0,
|
|
523
535
|
|
524
536
|
|
525
537
|
def _print_all_schema_names(portal: Portal,
|
526
|
-
|
527
|
-
tree: bool = False,
|
538
|
+
terse: bool = False, all: bool = False,
|
539
|
+
tree: bool = False, summary: bool = False, yaml: bool = False) -> None:
|
528
540
|
if not (schemas := _get_schemas(portal)):
|
529
541
|
return
|
530
542
|
|
531
|
-
if
|
532
|
-
if
|
543
|
+
if summary is not True:
|
544
|
+
if yaml:
|
533
545
|
_print_output(yaml.dump(schemas))
|
534
546
|
else:
|
535
547
|
_print_output(json.dumps(schemas, indent=4))
|
@@ -550,8 +562,8 @@ def _print_all_schema_names(portal: Portal,
|
|
550
562
|
_print_output(f"{schema_name} | abstract")
|
551
563
|
else:
|
552
564
|
_print_output(schema_name)
|
553
|
-
if
|
554
|
-
_print_schema(schemas[schema_name],
|
565
|
+
if not terse:
|
566
|
+
_print_schema(schemas[schema_name], terse=terse, all=all)
|
555
567
|
|
556
568
|
|
557
569
|
def _get_parent_schema_name(schema: dict) -> Optional[str]:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: dcicutils
|
3
|
-
Version: 8.13.3
|
3
|
+
Version: 8.13.3.1b2
|
4
4
|
Summary: Utility package for interacting with the 4DN Data Portal and other 4DN resources
|
5
5
|
Home-page: https://github.com/4dn-dcic/utils
|
6
6
|
License: MIT
|
@@ -26,8 +26,8 @@ Requires-Dist: PyJWT (>=2.6.0,<3.0.0)
|
|
26
26
|
Requires-Dist: PyYAML (>=6.0.1,<7.0.0)
|
27
27
|
Requires-Dist: appdirs (>=1.4.4,<2.0.0)
|
28
28
|
Requires-Dist: aws-requests-auth (>=0.4.2,<1)
|
29
|
-
Requires-Dist: boto3 (>=1.34.
|
30
|
-
Requires-Dist: botocore (>=1.34.
|
29
|
+
Requires-Dist: boto3 (>=1.34.147,<2.0.0)
|
30
|
+
Requires-Dist: botocore (>=1.34.147,<2.0.0)
|
31
31
|
Requires-Dist: chardet (>=5.2.0,<6.0.0)
|
32
32
|
Requires-Dist: docker (>=4.4.4,<5.0.0)
|
33
33
|
Requires-Dist: elasticsearch (==7.13.4)
|
@@ -41,7 +41,7 @@ Requires-Dist: pyperclip (>=1.8.2,<2.0.0)
|
|
41
41
|
Requires-Dist: pyramid (==1.10.8)
|
42
42
|
Requires-Dist: pytz (>=2020.4)
|
43
43
|
Requires-Dist: redis (>=4.5.1,<5.0.0)
|
44
|
-
Requires-Dist: requests (
|
44
|
+
Requires-Dist: requests (==2.31.0)
|
45
45
|
Requires-Dist: rfc3986 (>=1.4.0,<2.0.0)
|
46
46
|
Requires-Dist: shortuuid (>=1.0.13,<2.0.0)
|
47
47
|
Requires-Dist: structlog (>=19.2.0,<20.0.0)
|
@@ -6,7 +6,7 @@ dcicutils/captured_output.py,sha256=0hP7sPwleMaYXQAvCfJOxG8Z8T_JJYy8ADp8A5ZoblE,
|
|
6
6
|
dcicutils/cloudformation_utils.py,sha256=MtWJrSTXyiImgbPHgRvfH9bWso20ZPLTFJAfhDQSVj4,13786
|
7
7
|
dcicutils/codebuild_utils.py,sha256=CKpmhJ-Z8gYbkt1I2zyMlKtFdsg7T8lqrx3V5ieta-U,1155
|
8
8
|
dcicutils/command_utils.py,sha256=4LkszKXWlvgaUP_7d_tRsRqpOMc9IaohD2Kc9u9bEeU,18506
|
9
|
-
dcicutils/common.py,sha256=
|
9
|
+
dcicutils/common.py,sha256=U6tedhp6FFl9EUGoMqiMAqON_WqGJ_317JE_Tr4dXDs,3926
|
10
10
|
dcicutils/contribution_scripts.py,sha256=0k5Gw1TumcD5SAcXVkDd6-yvuMEw-jUp5Kfb7FJH6XQ,2015
|
11
11
|
dcicutils/contribution_utils.py,sha256=vYLS1JUB3sKd24BUxZ29qUBqYeQBLK9cwo8x3k64uPg,25653
|
12
12
|
dcicutils/creds_utils.py,sha256=64BbIfS90T1eJmmQJrDyfrRa3V2F1x7T8lOrEeFfqJY,11127
|
@@ -52,16 +52,16 @@ dcicutils/portal_object_utils.py,sha256=Az3n1aL-PQkN5gOFE6ZqC2XkYsqiwKlq7-tZggs1
|
|
52
52
|
dcicutils/portal_utils.py,sha256=R7v4uQUll34mn-NxyU3qoTouAwWrVDzW6W1zBGSU-M4,44762
|
53
53
|
dcicutils/progress_bar.py,sha256=R3bWLMYM3Xq9PY7U0JadcFT1m7QmCbrbDp9qs9_Kf_c,19472
|
54
54
|
dcicutils/project_utils.py,sha256=qPdCaFmWUVBJw4rw342iUytwdQC0P-XKpK4mhyIulMM,31250
|
55
|
-
dcicutils/qa_checkers.py,sha256=
|
56
|
-
dcicutils/qa_utils.py,sha256=
|
55
|
+
dcicutils/qa_checkers.py,sha256=j0kzo_T5VduKTxgsMTp7xjneyNokumZzI_iz55Y0Jjs,20505
|
56
|
+
dcicutils/qa_utils.py,sha256=tMvsMX0fXmE0BAaw34ulDw0f2twqgWnYcNQFBXHtAM0,160179
|
57
57
|
dcicutils/redis_tools.py,sha256=qkcSNMtvqkpvts-Cm9gWhneK523Q_oHwhNUud1be1qk,7055
|
58
58
|
dcicutils/redis_utils.py,sha256=VJ-7g8pOZqR1ZCtdcjKz3-6as2DMUcs1b1zG6wSprH4,6462
|
59
|
-
dcicutils/s3_utils.py,sha256=
|
59
|
+
dcicutils/s3_utils.py,sha256=h2B9ftOo-kxqfiKth5ZDC_cAUFy1Pbu7BrVanFnE5Iw,28839
|
60
60
|
dcicutils/schema_utils.py,sha256=GmRm-XqZKJ6qine16SQF1txcby9WougDav_sYmKNs9E,12400
|
61
61
|
dcicutils/scripts/publish_to_pypi.py,sha256=sMd4WASQGlxlh7uLrt2eGkFRXYgONVmvIg8mClMS5RQ,13903
|
62
62
|
dcicutils/scripts/run_license_checker.py,sha256=z2keYnRDZsHQbTeo1XORAXSXNJK5axVzL5LjiNqZ7jE,4184
|
63
63
|
dcicutils/scripts/update_portal_object.py,sha256=p9pFkoA3ZZOWvh-GMDpgR8qOfx_jQppOVNOjsuZndAU,18810
|
64
|
-
dcicutils/scripts/view_portal_object.py,sha256=
|
64
|
+
dcicutils/scripts/view_portal_object.py,sha256=h8COy0lcLNWF9b5spjrlQ28wfqyTTMqAeC_xpFXutus,32262
|
65
65
|
dcicutils/secrets_utils.py,sha256=8dppXAsiHhJzI6NmOcvJV5ldvKkQZzh3Fl-cb8Wm7MI,19745
|
66
66
|
dcicutils/sheet_utils.py,sha256=VlmzteONW5VF_Q4vo0yA5vesz1ViUah1MZ_yA1rwZ0M,33629
|
67
67
|
dcicutils/snapshot_utils.py,sha256=YDeI3vD-MhAtHwKDzfEm2q-n3l-da2yRpRR3xp0Ah1M,23021
|
@@ -75,8 +75,8 @@ dcicutils/trace_utils.py,sha256=g8kwV4ebEy5kXW6oOrEAUsurBcCROvwtZqz9fczsGRE,1769
|
|
75
75
|
dcicutils/validation_utils.py,sha256=cMZIU2cY98FYtzK52z5WUYck7urH6JcqOuz9jkXpqzg,14797
|
76
76
|
dcicutils/variant_utils.py,sha256=2H9azNx3xAj-MySg-uZ2SFqbWs4kZvf61JnK6b-h4Qw,4343
|
77
77
|
dcicutils/zip_utils.py,sha256=_Y9EmL3D2dUZhxucxHvrtmmlbZmK4FpSsHEb7rGSJLU,3265
|
78
|
-
dcicutils-8.13.3.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
|
79
|
-
dcicutils-8.13.3.dist-info/METADATA,sha256=
|
80
|
-
dcicutils-8.13.3.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
81
|
-
dcicutils-8.13.3.dist-info/entry_points.txt,sha256=W6kEWdUJk9tQ4myAgpehPdebcwvCAZ7UgB-wyPgDUMg,335
|
82
|
-
dcicutils-8.13.3.dist-info/RECORD,,
|
78
|
+
dcicutils-8.13.3.1b2.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
|
79
|
+
dcicutils-8.13.3.1b2.dist-info/METADATA,sha256=iEgNqdxcjbwkxqQ3YMTFnjFs4toHmHXBUU16hSrJCPQ,3439
|
80
|
+
dcicutils-8.13.3.1b2.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
81
|
+
dcicutils-8.13.3.1b2.dist-info/entry_points.txt,sha256=W6kEWdUJk9tQ4myAgpehPdebcwvCAZ7UgB-wyPgDUMg,335
|
82
|
+
dcicutils-8.13.3.1b2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|