dcicutils 8.14.0.1b10__tar.gz → 8.14.0.1b11__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.1b10 → dcicutils-8.14.0.1b11}/PKG-INFO +1 -1
  2. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/scripts/update_portal_object.py +82 -26
  3. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/pyproject.toml +1 -1
  4. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/LICENSE.txt +0 -0
  5. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/README.rst +0 -0
  6. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/__init__.py +0 -0
  7. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/base.py +0 -0
  8. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/beanstalk_utils.py +0 -0
  9. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/bundle_utils.py +0 -0
  10. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/captured_output.py +0 -0
  11. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/cloudformation_utils.py +0 -0
  12. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/codebuild_utils.py +0 -0
  13. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/command_utils.py +0 -0
  14. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/common.py +0 -0
  15. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/contribution_scripts.py +0 -0
  16. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/contribution_utils.py +0 -0
  17. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/creds_utils.py +0 -0
  18. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/data_readers.py +0 -0
  19. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/data_utils.py +0 -0
  20. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/datetime_utils.py +0 -0
  21. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/deployment_utils.py +0 -0
  22. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/diff_utils.py +0 -0
  23. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/docker_utils.py +0 -0
  24. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/ecr_scripts.py +0 -0
  25. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/ecr_utils.py +0 -0
  26. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/ecs_utils.py +0 -0
  27. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/env_base.py +0 -0
  28. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/env_manager.py +0 -0
  29. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/env_scripts.py +0 -0
  30. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/env_utils.py +0 -0
  31. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/env_utils_legacy.py +0 -0
  32. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/es_utils.py +0 -0
  33. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/exceptions.py +0 -0
  34. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/ff_mocks.py +0 -0
  35. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/ff_utils.py +0 -0
  36. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/file_utils.py +0 -0
  37. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/function_cache_decorator.py +0 -0
  38. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/glacier_utils.py +0 -0
  39. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/hack_for_elasticsearch_numpy_usage.py +0 -0
  40. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/http_utils.py +0 -0
  41. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/jh_utils.py +0 -0
  42. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/kibana/dashboards.json +0 -0
  43. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/kibana/readme.md +0 -0
  44. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/lang_utils.py +0 -0
  45. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
  46. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
  47. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
  48. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
  49. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
  50. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
  51. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/license_utils.py +0 -0
  52. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/log_utils.py +0 -0
  53. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/misc_utils.py +0 -0
  54. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/obfuscation_utils.py +0 -0
  55. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/opensearch_utils.py +0 -0
  56. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/portal_object_utils.py +0 -0
  57. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/portal_utils.py +0 -0
  58. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/progress_bar.py +0 -0
  59. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/project_utils.py +0 -0
  60. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/qa_checkers.py +0 -0
  61. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/qa_utils.py +0 -0
  62. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/redis_tools.py +0 -0
  63. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/redis_utils.py +0 -0
  64. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/s3_utils.py +0 -0
  65. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/schema_utils.py +0 -0
  66. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/scripts/publish_to_pypi.py +0 -0
  67. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/scripts/run_license_checker.py +0 -0
  68. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/scripts/view_portal_object.py +0 -0
  69. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/secrets_utils.py +0 -0
  70. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/sheet_utils.py +0 -0
  71. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/snapshot_utils.py +0 -0
  72. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/ssl_certificate_utils.py +0 -0
  73. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/structured_data.py +0 -0
  74. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/submitr/progress_constants.py +0 -0
  75. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
  76. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/task_utils.py +0 -0
  77. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/tmpfile_utils.py +0 -0
  78. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/trace_utils.py +0 -0
  79. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/validation_utils.py +0 -0
  80. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/dcicutils/variant_utils.py +0 -0
  81. {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b11}/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.1b10
3
+ Version: 8.14.0.1b11
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
@@ -162,7 +162,7 @@ def main():
162
162
  _print("The --env is not used for the --load option (to load data via snovault.loadxl).")
163
163
  if args.schema:
164
164
  _print("The --schema is not used for the --load option (to load data via snovault.loadxl).")
165
- _load_data(inserts_directory=args.load, ini_file=args.ini,
165
+ _load_data(load=args.load, ini_file=args.ini,
166
166
  verbose=args.verbose, debug=args.debug, noprogress=args.noprogress)
167
167
  exit(0)
168
168
 
@@ -226,14 +226,6 @@ def _post_or_patch_or_upsert(portal: Portal, file_or_directory: str,
226
226
  confirm: bool = False, verbose: bool = False,
227
227
  quiet: bool = False, debug: bool = False) -> None:
228
228
 
229
- def is_schema_name_list(portal: Portal, keys: list) -> bool:
230
- if isinstance(keys, list):
231
- for key in keys:
232
- if portal.get_schema(key) is None:
233
- return False
234
- return True
235
- return False
236
-
237
229
  def post_or_patch_or_upsert(portal: Portal, file: str, schema_name: Optional[str],
238
230
  patch_delete_fields: Optional[str] = None,
239
231
  confirm: bool = False, verbose: bool = False,
@@ -251,7 +243,7 @@ def _post_or_patch_or_upsert(portal: Portal, file_or_directory: str,
251
243
  patch_delete_fields=patch_delete_fields,
252
244
  noignore=noignore, ignore=ignore,
253
245
  confirm=confirm, verbose=verbose, debug=debug)
254
- elif is_schema_name_list(portal, list(data.keys())):
246
+ elif _is_schema_name_list(portal, list(data.keys())):
255
247
  if debug:
256
248
  _print(f"DEBUG: File ({file}) contains a dictionary of schema names.")
257
249
  for schema_name in data:
@@ -408,8 +400,8 @@ def _upsert_data(portal: Portal, data: dict, schema_name: str,
408
400
  return
409
401
 
410
402
 
411
- def _load_data(inserts_directory: str, ini_file: str,
412
- verbose: bool = False, debug: bool = False, noprogress: bool = False) -> None:
403
+ def _load_data(load: str, ini_file: str, explicit_schema_name: Optional[str] = None,
404
+ verbose: bool = False, debug: bool = False, noprogress: bool = False) -> bool:
413
405
 
414
406
  from snovault.loadxl import load_all_gen, LoadGenWrapper
415
407
  from dcicutils.captured_output import captured_output
@@ -431,7 +423,7 @@ def _load_data(inserts_directory: str, ini_file: str,
431
423
  return ""
432
424
 
433
425
  LOADXL_RESPONSE_PATTERN = re.compile(r"^([A-Z]+):\s*([a-zA-Z\/\d_-]+)\s*(\S+)\s*(\S+)?\s*(.*)$")
434
- LOADXL_ACTION_NAME = {"POST": "Create", "PATCH": "Update", "SKIP": "Skip",
426
+ LOADXL_ACTION_NAME = {"POST": "Create", "PATCH": "Update", "SKIP": "Check",
435
427
  "CHECK": "Validate", "ERROR": "Error"}
436
428
  current_item_type = None
437
429
  current_item_count = 0
@@ -472,14 +464,66 @@ def _load_data(inserts_directory: str, ini_file: str,
472
464
  if not os.path.exists(ini_file):
473
465
  _print(f"The INI file required for --load is not found: {ini_file}")
474
466
  exit(1)
475
- if not os.path.isabs(inserts_directory := os.path.expanduser(inserts_directory)):
476
- inserts_directory = os.path.join(os.getcwd(), inserts_directory)
477
- if not os.path.isdir(inserts_directory := os.path.expanduser(inserts_directory)):
478
- _print(f"Load directory does not exist: {inserts_directory}")
479
- exit(1)
467
+
468
+ if not os.path.isabs(load := os.path.expanduser(load)):
469
+ load = os.path.join(os.getcwd(), load)
470
+ if not os.path.exists(load):
471
+ return False
472
+
473
+ if os.path.isdir(load):
474
+ inserts_directory = load
475
+ inserts_file = None
476
+ else:
477
+ inserts_directory = None
478
+ inserts_file = load
479
+
480
480
  portal = None
481
481
  with captured_output(not debug):
482
482
  portal = Portal(ini_file)
483
+
484
+ if inserts_file:
485
+ with io.open(inserts_file, "r") as f:
486
+ try:
487
+ data = json.load(f)
488
+ except Exception:
489
+ _print(f"Cannot load JSON data from file: {inserts_file}")
490
+ return False
491
+ if isinstance(data, list):
492
+ if not (schema_name := explicit_schema_name):
493
+ if not (schema_name := _get_schema_name_from_schema_named_json_file_name(portal, inserts_file)):
494
+ _print("Unable to determine schema name for JSON data file: {inserts_file}")
495
+ return False
496
+ with temporary_directory() as tmpdir:
497
+ file_name = os.path.join(tmpdir, f"{to_snake_case(schema_name)}.json")
498
+ with io.open(file_name, "w") as f:
499
+ json.dump(data, f)
500
+ return _load_data(load=tmpdir, ini_file=ini_file, explicit_schema_name=explicit_schema_name,
501
+ verbose=verbose, debug=debug, noprogress=noprogress)
502
+ elif isinstance(data, dict):
503
+ _print("DICT IN FILE FOR LOAD NOT YET SUPPPORTED")
504
+ if not _is_schema_name_list(portal, schema_names := list(data.keys())):
505
+ _print(f"Unrecognized types in JSON data file: {inserts_file}")
506
+ return False
507
+ with temporary_directory() as tmpdir:
508
+ nfiles = 0
509
+ for schema_name in schema_names:
510
+ if not isinstance(schema_data := data[schema_name], list):
511
+ _print(f"Unexpected value for data type ({schema_name})"
512
+ f" in JSON data file: {inserts_file} ▶ ignoring")
513
+ continue
514
+ file_name = os.path.join(tmpdir, f"{to_snake_case(schema_name)}.json")
515
+ with io.open(file_name, "w") as f:
516
+ json.dump(schema_data, f)
517
+ nfiles += 1
518
+ if nfiles > 0:
519
+ return _load_data(load=tmpdir, ini_file=ini_file,
520
+ verbose=verbose, debug=debug, noprogress=noprogress)
521
+ # TODO
522
+ return True
523
+ else:
524
+ _print(f"Unrecognized JSON data in file: {inserts_file}")
525
+ return False
526
+ return True
483
527
  if verbose:
484
528
  _print(f"Loading data files into Portal (via snovault.loadxl) from: {inserts_directory}")
485
529
  _print(f"Portal INI file for load is: {ini_file}")
@@ -511,7 +555,7 @@ def _load_data(inserts_directory: str, ini_file: str,
511
555
  copy_to_temporary_directory = True
512
556
  if not schema_names_to_load:
513
557
  _print("Directory contains no valid data: {inserts_directory}")
514
- return
558
+ return False
515
559
  if copy_to_temporary_directory:
516
560
  with temporary_directory() as tmpdir:
517
561
  if debug:
@@ -526,6 +570,16 @@ def _load_data(inserts_directory: str, ini_file: str,
526
570
  loadxl(portal=portal, inserts_directory=inserts_directory, schema_names_to_load=schema_names_to_load)
527
571
  if verbose:
528
572
  _print(f"Done loading data into Portal (via snovault.loadxl) files from: {inserts_directory}")
573
+ return True
574
+
575
+
576
+ def _is_schema_name_list(portal: Portal, keys: list) -> bool:
577
+ if isinstance(keys, list):
578
+ for key in keys:
579
+ if portal.get_schema(key) is None:
580
+ return False
581
+ return True
582
+ return False
529
583
 
530
584
 
531
585
  def _prune_data_for_update(data: dict, noignore: bool = False, ignore: Optional[List[str]] = None) -> dict:
@@ -603,13 +657,15 @@ def _parse_delete_fields(value: str) -> str:
603
657
 
604
658
 
605
659
  def _get_schema_name_from_schema_named_json_file_name(portal: Portal, value: str) -> Optional[str]:
606
- try:
607
- if not value.endswith(".json"):
608
- return None
609
- _, schema_name = _get_schema(portal, os.path.basename(value[:-5]))
610
- return schema_name
611
- except Exception:
612
- return False
660
+ if isinstance(value, str) and value:
661
+ try:
662
+ if value.endswith(".json"):
663
+ value = value[:-5]
664
+ _, schema_name = _get_schema(portal, os.path.basename(value))
665
+ return schema_name
666
+ except Exception:
667
+ pass
668
+ return False
613
669
 
614
670
 
615
671
  @lru_cache(maxsize=1)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dcicutils"
3
- version = "8.14.0.1b10" # TODO: To become 8.14.1
3
+ version = "8.14.0.1b11" # 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"