dcicutils 8.14.0.1b10__tar.gz → 8.14.0.1b12__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/PKG-INFO +1 -1
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/scripts/update_portal_object.py +93 -31
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/pyproject.toml +1 -1
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/LICENSE.txt +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/README.rst +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/__init__.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/base.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/beanstalk_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/bundle_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/captured_output.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/cloudformation_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/codebuild_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/command_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/common.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/contribution_scripts.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/contribution_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/creds_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/data_readers.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/data_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/datetime_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/deployment_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/diff_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/docker_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/ecr_scripts.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/ecr_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/ecs_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/env_base.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/env_manager.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/env_scripts.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/env_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/env_utils_legacy.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/es_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/exceptions.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/ff_mocks.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/ff_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/file_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/function_cache_decorator.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/glacier_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/hack_for_elasticsearch_numpy_usage.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/http_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/jh_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/kibana/dashboards.json +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/kibana/readme.md +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/lang_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/license_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/log_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/misc_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/obfuscation_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/opensearch_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/portal_object_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/portal_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/progress_bar.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/project_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/qa_checkers.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/qa_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/redis_tools.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/redis_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/s3_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/schema_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/scripts/publish_to_pypi.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/scripts/run_license_checker.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/scripts/view_portal_object.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/secrets_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/sheet_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/snapshot_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/ssl_certificate_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/structured_data.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/submitr/progress_constants.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/task_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/tmpfile_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/trace_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/validation_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/variant_utils.py +0 -0
- {dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/zip_utils.py +0 -0
@@ -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(
|
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
|
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,9 @@ def _upsert_data(portal: Portal, data: dict, schema_name: str,
|
|
408
400
|
return
|
409
401
|
|
410
402
|
|
411
|
-
def _load_data(
|
412
|
-
verbose: bool = False, debug: bool = False, noprogress: bool = False
|
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,
|
405
|
+
_portal: Optional[Portal] = None, _single_insert_file: Optional[str] = None) -> bool:
|
413
406
|
|
414
407
|
from snovault.loadxl import load_all_gen, LoadGenWrapper
|
415
408
|
from dcicutils.captured_output import captured_output
|
@@ -419,7 +412,7 @@ def _load_data(inserts_directory: str, ini_file: str,
|
|
419
412
|
|
420
413
|
nonlocal LoadGenWrapper, load_all_gen, verbose, debug
|
421
414
|
progress_total = sum(schema_names_to_load.values()) * 2 # loadxl does two passes
|
422
|
-
progress_bar = ProgressBar(progress_total) if not noprogress else None
|
415
|
+
progress_bar = ProgressBar(progress_total, interrupt_exit=True) if not noprogress else None
|
423
416
|
|
424
417
|
def decode_bytes(str_or_bytes: Union[str, bytes], *, encoding: str = "utf-8") -> str:
|
425
418
|
if not isinstance(encoding, str):
|
@@ -431,7 +424,7 @@ def _load_data(inserts_directory: str, ini_file: str,
|
|
431
424
|
return ""
|
432
425
|
|
433
426
|
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": "
|
427
|
+
LOADXL_ACTION_NAME = {"POST": "Create", "PATCH": "Update", "SKIP": "Check",
|
435
428
|
"CHECK": "Validate", "ERROR": "Error"}
|
436
429
|
current_item_type = None
|
437
430
|
current_item_count = 0
|
@@ -472,16 +465,73 @@ def _load_data(inserts_directory: str, ini_file: str,
|
|
472
465
|
if not os.path.exists(ini_file):
|
473
466
|
_print(f"The INI file required for --load is not found: {ini_file}")
|
474
467
|
exit(1)
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
468
|
+
|
469
|
+
if not os.path.isabs(load := os.path.expanduser(load)):
|
470
|
+
load = os.path.join(os.getcwd(), load)
|
471
|
+
if not os.path.exists(load):
|
472
|
+
return False
|
473
|
+
|
474
|
+
if os.path.isdir(load):
|
475
|
+
inserts_directory = load
|
476
|
+
inserts_file = None
|
477
|
+
else:
|
478
|
+
inserts_directory = None
|
479
|
+
inserts_file = load
|
480
|
+
|
481
|
+
if not (portal := _portal):
|
482
|
+
with captured_output(not debug):
|
483
|
+
portal = Portal(ini_file)
|
484
|
+
|
485
|
+
if inserts_file:
|
486
|
+
with io.open(inserts_file, "r") as f:
|
487
|
+
try:
|
488
|
+
data = json.load(f)
|
489
|
+
except Exception:
|
490
|
+
_print(f"Cannot load JSON data from file: {inserts_file}")
|
491
|
+
return False
|
492
|
+
if isinstance(data, list):
|
493
|
+
if not (schema_name := explicit_schema_name):
|
494
|
+
if not (schema_name := _get_schema_name_from_schema_named_json_file_name(portal, inserts_file)):
|
495
|
+
_print("Unable to determine schema name for JSON data file: {inserts_file}")
|
496
|
+
return False
|
497
|
+
with temporary_directory() as tmpdir:
|
498
|
+
file_name = os.path.join(tmpdir, f"{to_snake_case(schema_name)}.json")
|
499
|
+
with io.open(file_name, "w") as f:
|
500
|
+
json.dump(data, f)
|
501
|
+
return _load_data(load=tmpdir, ini_file=ini_file, explicit_schema_name=explicit_schema_name,
|
502
|
+
verbose=verbose, debug=debug, noprogress=noprogress,
|
503
|
+
_portal=portal, _single_insert_file=inserts_file)
|
504
|
+
elif isinstance(data, dict):
|
505
|
+
_print("DICT IN FILE FOR LOAD NOT YET SUPPPORTED")
|
506
|
+
if not _is_schema_name_list(portal, schema_names := list(data.keys())):
|
507
|
+
_print(f"Unrecognized types in JSON data file: {inserts_file}")
|
508
|
+
return False
|
509
|
+
with temporary_directory() as tmpdir:
|
510
|
+
nfiles = 0
|
511
|
+
for schema_name in schema_names:
|
512
|
+
if not isinstance(schema_data := data[schema_name], list):
|
513
|
+
_print(f"Unexpected value for data type ({schema_name})"
|
514
|
+
f" in JSON data file: {inserts_file} ▶ ignoring")
|
515
|
+
continue
|
516
|
+
file_name = os.path.join(tmpdir, f"{to_snake_case(schema_name)}.json")
|
517
|
+
with io.open(file_name, "w") as f:
|
518
|
+
json.dump(schema_data, f)
|
519
|
+
nfiles += 1
|
520
|
+
if nfiles > 0:
|
521
|
+
return _load_data(load=tmpdir, ini_file=ini_file,
|
522
|
+
verbose=verbose, debug=debug, noprogress=noprogress,
|
523
|
+
_portal=portal, _single_insert_file=inserts_file)
|
524
|
+
# TODO
|
525
|
+
return True
|
526
|
+
else:
|
527
|
+
_print(f"Unrecognized JSON data in file: {inserts_file}")
|
528
|
+
return False
|
529
|
+
return True
|
483
530
|
if verbose:
|
484
|
-
|
531
|
+
if _single_insert_file:
|
532
|
+
_print(f"Loading data file into Portal (via snovault.loadxl) from: {_single_insert_file}")
|
533
|
+
else:
|
534
|
+
_print(f"Loading data files into Portal (via snovault.loadxl) from: {inserts_directory}")
|
485
535
|
_print(f"Portal INI file for load is: {ini_file}")
|
486
536
|
|
487
537
|
schema_names = list(_get_schemas(portal).keys())
|
@@ -511,7 +561,7 @@ def _load_data(inserts_directory: str, ini_file: str,
|
|
511
561
|
copy_to_temporary_directory = True
|
512
562
|
if not schema_names_to_load:
|
513
563
|
_print("Directory contains no valid data: {inserts_directory}")
|
514
|
-
return
|
564
|
+
return False
|
515
565
|
if copy_to_temporary_directory:
|
516
566
|
with temporary_directory() as tmpdir:
|
517
567
|
if debug:
|
@@ -526,6 +576,16 @@ def _load_data(inserts_directory: str, ini_file: str,
|
|
526
576
|
loadxl(portal=portal, inserts_directory=inserts_directory, schema_names_to_load=schema_names_to_load)
|
527
577
|
if verbose:
|
528
578
|
_print(f"Done loading data into Portal (via snovault.loadxl) files from: {inserts_directory}")
|
579
|
+
return True
|
580
|
+
|
581
|
+
|
582
|
+
def _is_schema_name_list(portal: Portal, keys: list) -> bool:
|
583
|
+
if isinstance(keys, list):
|
584
|
+
for key in keys:
|
585
|
+
if portal.get_schema(key) is None:
|
586
|
+
return False
|
587
|
+
return True
|
588
|
+
return False
|
529
589
|
|
530
590
|
|
531
591
|
def _prune_data_for_update(data: dict, noignore: bool = False, ignore: Optional[List[str]] = None) -> dict:
|
@@ -603,13 +663,15 @@ def _parse_delete_fields(value: str) -> str:
|
|
603
663
|
|
604
664
|
|
605
665
|
def _get_schema_name_from_schema_named_json_file_name(portal: Portal, value: str) -> Optional[str]:
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
666
|
+
if isinstance(value, str) and value:
|
667
|
+
try:
|
668
|
+
if value.endswith(".json"):
|
669
|
+
value = value[:-5]
|
670
|
+
_, schema_name = _get_schema(portal, os.path.basename(value))
|
671
|
+
return schema_name
|
672
|
+
except Exception:
|
673
|
+
pass
|
674
|
+
return False
|
613
675
|
|
614
676
|
|
615
677
|
@lru_cache(maxsize=1)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "dcicutils"
|
3
|
-
version = "8.14.0.
|
3
|
+
version = "8.14.0.1b12" # 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"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/hack_for_elasticsearch_numpy_usage.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/license_policies/c4-infrastructure.jsonc
RENAMED
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/license_policies/park-lab-common.jsonc
RENAMED
File without changes
|
File without changes
|
{dcicutils-8.14.0.1b10 → dcicutils-8.14.0.1b12}/dcicutils/license_policies/park-lab-pipeline.jsonc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|