dcicutils 8.14.0.1b28__tar.gz → 8.14.0.1b29__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/PKG-INFO +1 -1
  2. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/scripts/view_portal_object.py +91 -42
  3. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/pyproject.toml +1 -1
  4. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/LICENSE.txt +0 -0
  5. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/README.rst +0 -0
  6. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/__init__.py +0 -0
  7. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/base.py +0 -0
  8. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/beanstalk_utils.py +0 -0
  9. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/bundle_utils.py +0 -0
  10. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/captured_output.py +0 -0
  11. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/cloudformation_utils.py +0 -0
  12. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/codebuild_utils.py +0 -0
  13. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/command_utils.py +0 -0
  14. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/common.py +0 -0
  15. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/contribution_scripts.py +0 -0
  16. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/contribution_utils.py +0 -0
  17. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/creds_utils.py +0 -0
  18. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/data_readers.py +0 -0
  19. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/data_utils.py +0 -0
  20. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/datetime_utils.py +0 -0
  21. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/deployment_utils.py +0 -0
  22. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/diff_utils.py +0 -0
  23. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/docker_utils.py +0 -0
  24. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ecr_scripts.py +0 -0
  25. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ecr_utils.py +0 -0
  26. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ecs_utils.py +0 -0
  27. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/env_base.py +0 -0
  28. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/env_manager.py +0 -0
  29. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/env_scripts.py +0 -0
  30. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/env_utils.py +0 -0
  31. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/env_utils_legacy.py +0 -0
  32. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/es_utils.py +0 -0
  33. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/exceptions.py +0 -0
  34. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ff_mocks.py +0 -0
  35. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ff_utils.py +0 -0
  36. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/file_utils.py +0 -0
  37. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/function_cache_decorator.py +0 -0
  38. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/glacier_utils.py +0 -0
  39. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/hack_for_elasticsearch_numpy_usage.py +0 -0
  40. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/http_utils.py +0 -0
  41. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/jh_utils.py +0 -0
  42. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/kibana/dashboards.json +0 -0
  43. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/kibana/readme.md +0 -0
  44. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/lang_utils.py +0 -0
  45. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
  46. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
  47. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
  48. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
  49. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
  50. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
  51. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_utils.py +0 -0
  52. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/log_utils.py +0 -0
  53. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/misc_utils.py +0 -0
  54. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/obfuscation_utils.py +0 -0
  55. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/opensearch_utils.py +0 -0
  56. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/portal_object_utils.py +0 -0
  57. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/portal_utils.py +0 -0
  58. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/progress_bar.py +0 -0
  59. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/project_utils.py +0 -0
  60. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/qa_checkers.py +0 -0
  61. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/qa_utils.py +0 -0
  62. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/redis_tools.py +0 -0
  63. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/redis_utils.py +0 -0
  64. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/s3_utils.py +0 -0
  65. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/schema_utils.py +0 -0
  66. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/scripts/publish_to_pypi.py +0 -0
  67. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/scripts/run_license_checker.py +0 -0
  68. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/scripts/update_portal_object.py +0 -0
  69. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/secrets_utils.py +0 -0
  70. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/sheet_utils.py +0 -0
  71. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/snapshot_utils.py +0 -0
  72. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ssl_certificate_utils.py +0 -0
  73. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/structured_data.py +0 -0
  74. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/submitr/progress_constants.py +0 -0
  75. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
  76. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/task_utils.py +0 -0
  77. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/tmpfile_utils.py +0 -0
  78. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/trace_utils.py +0 -0
  79. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/validation_utils.py +0 -0
  80. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/variant_utils.py +0 -0
  81. {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/zip_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcicutils
3
- Version: 8.14.0.1b28
3
+ Version: 8.14.0.1b29
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
@@ -307,28 +307,76 @@ def _get_portal_object(portal: Portal, uuid: str,
307
307
  return None
308
308
  return metadata_types
309
309
 
310
- response = None
311
- try:
312
- if not uuid.startswith("/"):
313
- path = f"/{uuid}"
314
- else:
315
- path = uuid
316
- response = portal.get(path, raw=raw or inserts, database=database)
317
- except Exception as e:
318
- if "404" in str(e) and "not found" in str(e).lower():
319
- _print(f"Portal object not found at {portal.server}: {uuid}")
320
- _exit()
321
- _exit(f"Exception getting Portal object from {portal.server}: {uuid}\n{get_error_message(e)}")
322
- if not response:
323
- if check:
324
- return None
325
- _exit(f"Null response getting Portal object from {portal.server}: {uuid}")
326
- if response.status_code not in [200, 307]:
327
- # TODO: Understand why the /me endpoint returns HTTP status code 307, which is only why we mention it above.
328
- _exit(f"Invalid status code ({response.status_code}) getting Portal object from {portal.server}: {uuid}")
329
- if not response.json:
330
- _exit(f"Invalid JSON getting Portal object: {uuid}")
331
- response = response.json()
310
+ def write_insert_files(response: dict) -> None:
311
+ nonlocal insert_files, force
312
+ output_directory = insert_files if isinstance(insert_files, str) else os.getcwd()
313
+ for schema_name in response:
314
+ schema_data = response[schema_name]
315
+ file_name = f"{to_snake_case(schema_name)}.json"
316
+ file_path = os.path.join(output_directory, file_name)
317
+ message_verb = "Writing"
318
+ if os.path.exists(file_path):
319
+ message_verb = "Overwriting"
320
+ if os.path.isdir(file_path):
321
+ _print(f"WARNING: Output file already exists as a directory. SKIPPING: {file_path}")
322
+ continue
323
+ if not force:
324
+ _print(f"Output file already exists: {file_path}")
325
+ if not yes_or_no(f"Overwrite this file?"):
326
+ continue
327
+ if verbose:
328
+ _print(f"{message_verb} {schema_name} (object{'s' if len(schema_data) != 1 else ''}:"
329
+ f" {len(schema_data)}) file: {file_path}")
330
+ with io.open(file_path, "w") as f:
331
+ json.dump(schema_data, f, indent=4)
332
+
333
+ if os.path.exists(uuid) and inserts:
334
+ # Very special case: If given "uuid" (or other path) as actually a file then assume it
335
+ # contains a list of references (e.g. /Donor/3039a6ca-9849-432d-ad49-2c5630bcbee7) to fetch.
336
+ response = {}
337
+ if verbose:
338
+ _print(f"Reading references from file: {uuid}")
339
+ with io.open(uuid) as f:
340
+ for line in f:
341
+ if ((line := line.strip()) and (components := line.split("/")) and (len(components) > 1) and
342
+ (schema_name := components[1]) and (schema_name := _get_schema(portal, schema_name)[1])): # noqa
343
+ try:
344
+ if ((result := portal.get(line, raw=True, database=database)) and
345
+ (result.status_code in [200, 307]) and (result := result.json())): # noqa
346
+ if not response.get(schema_name):
347
+ response[schema_name] = []
348
+ response[schema_name].append(result)
349
+ continue
350
+ except Exception:
351
+ pass
352
+ _print(f"Cannot get reference: {line}")
353
+ if insert_files:
354
+ write_insert_files(response)
355
+ return response
356
+ else:
357
+ response = None
358
+ try:
359
+ if not uuid.startswith("/"):
360
+ path = f"/{uuid}"
361
+ else:
362
+ path = uuid
363
+ response = portal.get(path, raw=raw or inserts, database=database)
364
+ except Exception as e:
365
+ if "404" in str(e) and "not found" in str(e).lower():
366
+ _print(f"Portal object not found at {portal.server}: {uuid}")
367
+ _exit()
368
+ _exit(f"Exception getting Portal object from {portal.server}: {uuid}\n{get_error_message(e)}")
369
+ if not response:
370
+ if check:
371
+ return None
372
+ _exit(f"Null response getting Portal object from {portal.server}: {uuid}")
373
+ if response.status_code not in [200, 307]:
374
+ # TODO: Understand why the /me endpoint returns HTTP status code 307, which is only why we mention it above.
375
+ _exit(f"Invalid status code ({response.status_code}) getting Portal object from {portal.server}: {uuid}")
376
+ if not response.json:
377
+ _exit(f"Invalid JSON getting Portal object: {uuid}")
378
+ response = response.json()
379
+
332
380
  response_types = {}
333
381
  if inserts:
334
382
  # Format results as suitable for inserts (e.g. via update-portal-object).
@@ -376,26 +424,27 @@ def _get_portal_object(portal: Portal, uuid: str,
376
424
  (isinstance(response_type := response_cooked.json().get("@type"), list) and response_type)):
377
425
  response = {f"{response_type[0]}": [prune_data(response)]}
378
426
  if insert_files:
379
- output_directory = insert_files if isinstance(insert_files, str) else os.getcwd()
380
- for schema_name in response:
381
- schema_data = response[schema_name]
382
- file_name = f"{to_snake_case(schema_name)}.json"
383
- file_path = os.path.join(output_directory, file_name)
384
- message_verb = "Writing"
385
- if os.path.exists(file_path):
386
- message_verb = "Overwriting"
387
- if os.path.isdir(file_path):
388
- _print(f"WARNING: Output file already exists as a directory. SKIPPING: {file_path}")
389
- continue
390
- if not force:
391
- _print(f"Output file already exists: {file_path}")
392
- if not yes_or_no(f"Overwrite this file?"):
393
- continue
394
- if verbose:
395
- _print(f"{message_verb} {schema_name} (object{'s' if len(schema_data) != 1 else ''}:"
396
- f" {len(schema_data)}) file: {file_path}")
397
- with io.open(file_path, "w") as f:
398
- json.dump(schema_data, f, indent=4)
427
+ write_insert_files(response)
428
+ # output_directory = insert_files if isinstance(insert_files, str) else os.getcwd()
429
+ # for schema_name in response:
430
+ # schema_data = response[schema_name]
431
+ # file_name = f"{to_snake_case(schema_name)}.json"
432
+ # file_path = os.path.join(output_directory, file_name)
433
+ # message_verb = "Writing"
434
+ # if os.path.exists(file_path):
435
+ # message_verb = "Overwriting"
436
+ # if os.path.isdir(file_path):
437
+ # _print(f"WARNING: Output file already exists as a directory. SKIPPING: {file_path}")
438
+ # continue
439
+ # if not force:
440
+ # _print(f"Output file already exists: {file_path}")
441
+ # if not yes_or_no(f"Overwrite this file?"):
442
+ # continue
443
+ # if verbose:
444
+ # _print(f"{message_verb} {schema_name} (object{'s' if len(schema_data) != 1 else ''}:"
445
+ # f" {len(schema_data)}) file: {file_path}")
446
+ # with io.open(file_path, "w") as f:
447
+ # json.dump(schema_data, f, indent=4)
399
448
  elif raw:
400
449
  response.pop("schema_version", None)
401
450
  return response
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dcicutils"
3
- version = "8.14.0.1b28" # TODO: To become 8.14.1
3
+ version = "8.14.0.1b29" # TODO: To become 8.14.1
4
4
  description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
5
5
  authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
6
6
  license = "MIT"