dcicutils 8.13.3__py3-none-any.whl → 8.13.3.1b1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -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("--details", action="store_true", required=False, default=False, help="Detailed output.")
118
- parser.add_argument("--more-details", action="store_true", required=False, default=False,
119
- help="More detailed output.")
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, details=args.details,
147
- more_details=args.more_details, all=args.all,
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 not args.raw:
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, details=args.details, more_details=args.details,
194
- all=args.all, raw=args.raw, raw_yaml=args.yaml)
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
- response = {f"{results_type}": results}
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, details: bool = False, more_details: bool = False, all: bool = False,
336
- raw: bool = False, raw_yaml: bool = False) -> None:
337
- if raw:
338
- if raw_yaml:
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, details=details, more_details=more_details, all=all)
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
- details: bool = False, more_details: bool = False, all: bool = False,
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 not more_details:
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
- details=details, more_details=more_details, all=all,
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
- details: bool = False, more_details: bool = False, all: bool = False,
527
- tree: bool = False, raw: bool = False, raw_yaml: bool = False) -> None:
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 raw:
532
- if raw_yaml:
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 details:
554
- _print_schema(schemas[schema_name], details=details, more_details=more_details, all=all)
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.1b1
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.136,<2.0.0)
30
- Requires-Dist: botocore (>=1.34.136,<2.0.0)
29
+ Requires-Dist: boto3 (>=1.34.144,<2.0.0)
30
+ Requires-Dist: botocore (>=1.34.144,<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)
@@ -61,7 +61,7 @@ dcicutils/schema_utils.py,sha256=GmRm-XqZKJ6qine16SQF1txcby9WougDav_sYmKNs9E,124
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=ddZdOuSsYD-4VlsWth0EBTD_2TycQ4Ktgh-IdzKHweM,31490
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=B583S5ausZLy7zA73GFhcTCgX3KJVnhy008WzM0H6uk,3442
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.1b1.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
79
+ dcicutils-8.13.3.1b1.dist-info/METADATA,sha256=Qf_4Nxv0PpDGb0NuNqilIzyNY_tuJ8-sgXyN9YZZ1Zc,3446
80
+ dcicutils-8.13.3.1b1.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
81
+ dcicutils-8.13.3.1b1.dist-info/entry_points.txt,sha256=W6kEWdUJk9tQ4myAgpehPdebcwvCAZ7UgB-wyPgDUMg,335
82
+ dcicutils-8.13.3.1b1.dist-info/RECORD,,