dcicutils 8.14.0.1b8__tar.gz → 8.14.0.1b10__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/PKG-INFO +1 -1
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/scripts/update_portal_object.py +147 -40
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/scripts/view_portal_object.py +7 -11
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/pyproject.toml +1 -1
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/LICENSE.txt +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/README.rst +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/__init__.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/base.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/beanstalk_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/bundle_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/captured_output.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/cloudformation_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/codebuild_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/command_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/common.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/contribution_scripts.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/contribution_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/creds_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/data_readers.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/data_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/datetime_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/deployment_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/diff_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/docker_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/ecr_scripts.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/ecr_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/ecs_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/env_base.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/env_manager.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/env_scripts.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/env_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/env_utils_legacy.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/es_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/exceptions.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/ff_mocks.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/ff_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/file_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/function_cache_decorator.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/glacier_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/hack_for_elasticsearch_numpy_usage.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/http_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/jh_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/kibana/dashboards.json +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/kibana/readme.md +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/lang_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/license_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/log_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/misc_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/obfuscation_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/opensearch_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/portal_object_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/portal_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/progress_bar.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/project_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/qa_checkers.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/qa_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/redis_tools.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/redis_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/s3_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/schema_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/scripts/publish_to_pypi.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/scripts/run_license_checker.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/secrets_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/sheet_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/snapshot_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/ssl_certificate_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/structured_data.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/submitr/progress_constants.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/task_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/tmpfile_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/trace_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/validation_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/variant_utils.py +0 -0
- {dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/zip_utils.py +0 -0
@@ -14,13 +14,15 @@ import io
|
|
14
14
|
import json
|
15
15
|
import os
|
16
16
|
import re
|
17
|
+
import shutil
|
17
18
|
import sys
|
18
19
|
from typing import Callable, List, Optional, Tuple, Union
|
19
20
|
from dcicutils.command_utils import yes_or_no
|
20
21
|
from dcicutils.common import ORCHESTRATED_APPS, APP_SMAHT
|
21
22
|
from dcicutils.ff_utils import delete_metadata, purge_metadata
|
22
|
-
from dcicutils.misc_utils import get_error_message, ignored, PRINT
|
23
|
+
from dcicutils.misc_utils import get_error_message, ignored, PRINT, to_camel_case, to_snake_case
|
23
24
|
from dcicutils.portal_utils import Portal as PortalFromUtils
|
25
|
+
from dcicutils.tmpfile_utils import temporary_directory
|
24
26
|
|
25
27
|
|
26
28
|
class Portal(PortalFromUtils):
|
@@ -131,6 +133,8 @@ def main():
|
|
131
133
|
parser.add_argument("--confirm", action="store_true", required=False, default=False, help="Confirm before action.")
|
132
134
|
parser.add_argument("--verbose", action="store_true", required=False, default=False, help="Verbose output.")
|
133
135
|
parser.add_argument("--quiet", action="store_true", required=False, default=False, help="Quiet output.")
|
136
|
+
parser.add_argument("--noprogress", action="store_true", required=False, default=False,
|
137
|
+
help="No progress bar output for --load.")
|
134
138
|
parser.add_argument("--debug", action="store_true", required=False, default=False, help="Debugging output.")
|
135
139
|
args = parser.parse_args()
|
136
140
|
|
@@ -158,27 +162,8 @@ def main():
|
|
158
162
|
_print("The --env is not used for the --load option (to load data via snovault.loadxl).")
|
159
163
|
if args.schema:
|
160
164
|
_print("The --schema is not used for the --load option (to load data via snovault.loadxl).")
|
161
|
-
|
162
|
-
|
163
|
-
if args.ini:
|
164
|
-
ini_file = args.ini
|
165
|
-
else:
|
166
|
-
ini_file = _DEFAULT_INI_FILE_FOR_LOAD
|
167
|
-
if not os.path.exists(ini_file):
|
168
|
-
_print(f"The INI file required for --load is not found: {ini_file}")
|
169
|
-
exit(1)
|
170
|
-
if not os.path.isdir(args.load):
|
171
|
-
_print(f"Load directory does not exist: {args.load}")
|
172
|
-
exit(1)
|
173
|
-
portal = None
|
174
|
-
with captured_output(not args.debug):
|
175
|
-
portal = Portal(ini_file)
|
176
|
-
if args.verbose:
|
177
|
-
_print(f"Loading data files into Portal (via snovault.loadxl) from: {args.load}")
|
178
|
-
_print(f"Portal INI file for load is: {ini_file}")
|
179
|
-
load_data(portal.vapp, indir=args.load, overwrite=True, use_master_inserts=False)
|
180
|
-
if args.verbose:
|
181
|
-
_print(f"Done loading data into Portal (via snovault.loadxl) files from: {args.load}")
|
165
|
+
_load_data(inserts_directory=args.load, ini_file=args.ini,
|
166
|
+
verbose=args.verbose, debug=args.debug, noprogress=args.noprogress)
|
182
167
|
exit(0)
|
183
168
|
|
184
169
|
portal = _create_portal(env=args.env, app=app, verbose=args.verbose, debug=args.debug)
|
@@ -192,7 +177,7 @@ def main():
|
|
192
177
|
_post_or_patch_or_upsert(portal=portal,
|
193
178
|
file_or_directory=args.post,
|
194
179
|
explicit_schema_name=explicit_schema_name,
|
195
|
-
update_function=
|
180
|
+
update_function=_post_data,
|
196
181
|
update_action_name="POST",
|
197
182
|
noignore=args.noignore, ignore=args.ignore,
|
198
183
|
confirm=args.confirm, verbose=args.verbose, quiet=args.quiet, debug=args.debug)
|
@@ -200,7 +185,7 @@ def main():
|
|
200
185
|
_post_or_patch_or_upsert(portal=portal,
|
201
186
|
file_or_directory=args.patch,
|
202
187
|
explicit_schema_name=explicit_schema_name,
|
203
|
-
update_function=
|
188
|
+
update_function=_patch_data,
|
204
189
|
update_action_name="PATCH",
|
205
190
|
patch_delete_fields=args.delete,
|
206
191
|
noignore=args.noignore, ignore=args.ignore,
|
@@ -210,7 +195,7 @@ def main():
|
|
210
195
|
_post_or_patch_or_upsert(portal=portal,
|
211
196
|
file_or_directory=args.upsert,
|
212
197
|
explicit_schema_name=explicit_schema_name,
|
213
|
-
update_function=
|
198
|
+
update_function=_upsert_data,
|
214
199
|
update_action_name="UPSERT",
|
215
200
|
patch_delete_fields=args.delete,
|
216
201
|
noignore=args.noignore, ignore=args.ignore,
|
@@ -329,11 +314,11 @@ def _impose_special_ordering(data: List[dict], schema_name: str) -> List[dict]:
|
|
329
314
|
return data
|
330
315
|
|
331
316
|
|
332
|
-
def
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
317
|
+
def _post_data(portal: Portal, data: dict, schema_name: str,
|
318
|
+
file: Optional[str] = None, index: int = 0,
|
319
|
+
patch_delete_fields: Optional[str] = None,
|
320
|
+
noignore: bool = False, ignore: Optional[List[str]] = None,
|
321
|
+
confirm: bool = False, verbose: bool = False, debug: bool = False) -> None:
|
337
322
|
ignored(patch_delete_fields)
|
338
323
|
if not (identifying_path := portal.get_identifying_path(data, portal_type=schema_name)):
|
339
324
|
if isinstance(file, str) and isinstance(index, int):
|
@@ -359,11 +344,11 @@ def post_data(portal: Portal, data: dict, schema_name: str,
|
|
359
344
|
return
|
360
345
|
|
361
346
|
|
362
|
-
def
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
347
|
+
def _patch_data(portal: Portal, data: dict, schema_name: str,
|
348
|
+
file: Optional[str] = None, index: int = 0,
|
349
|
+
patch_delete_fields: Optional[str] = None,
|
350
|
+
noignore: bool = False, ignore: Optional[List[str]] = None,
|
351
|
+
confirm: bool = False, verbose: bool = False, debug: bool = False) -> None:
|
367
352
|
if not (identifying_path := portal.get_identifying_path(data, portal_type=schema_name)):
|
368
353
|
if isinstance(file, str) and isinstance(index, int):
|
369
354
|
_print(f"ERROR: Item for PATCH has no identifying property: {file} (#{index + 1})")
|
@@ -390,11 +375,11 @@ def patch_data(portal: Portal, data: dict, schema_name: str,
|
|
390
375
|
return
|
391
376
|
|
392
377
|
|
393
|
-
def
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
378
|
+
def _upsert_data(portal: Portal, data: dict, schema_name: str,
|
379
|
+
file: Optional[str] = None, index: int = 0,
|
380
|
+
patch_delete_fields: Optional[str] = None,
|
381
|
+
noignore: bool = False, ignore: Optional[List[str]] = None,
|
382
|
+
confirm: bool = False, verbose: bool = False, debug: bool = False) -> None:
|
398
383
|
if not (identifying_path := portal.get_identifying_path(data, portal_type=schema_name)):
|
399
384
|
if isinstance(file, str) and isinstance(index, int):
|
400
385
|
_print(f"ERROR: Item for UPSERT has no identifying property: {file} (#{index + 1})")
|
@@ -423,6 +408,126 @@ def upsert_data(portal: Portal, data: dict, schema_name: str,
|
|
423
408
|
return
|
424
409
|
|
425
410
|
|
411
|
+
def _load_data(inserts_directory: str, ini_file: str,
|
412
|
+
verbose: bool = False, debug: bool = False, noprogress: bool = False) -> None:
|
413
|
+
|
414
|
+
from snovault.loadxl import load_all_gen, LoadGenWrapper
|
415
|
+
from dcicutils.captured_output import captured_output
|
416
|
+
from dcicutils.progress_bar import ProgressBar
|
417
|
+
|
418
|
+
def loadxl(portal: Portal, inserts_directory: str, schema_names_to_load: dict):
|
419
|
+
|
420
|
+
nonlocal LoadGenWrapper, load_all_gen, verbose, debug
|
421
|
+
progress_total = sum(schema_names_to_load.values()) * 2 # loadxl does two passes
|
422
|
+
progress_bar = ProgressBar(progress_total) if not noprogress else None
|
423
|
+
|
424
|
+
def decode_bytes(str_or_bytes: Union[str, bytes], *, encoding: str = "utf-8") -> str:
|
425
|
+
if not isinstance(encoding, str):
|
426
|
+
encoding = "utf-8"
|
427
|
+
if isinstance(str_or_bytes, bytes):
|
428
|
+
return str_or_bytes.decode(encoding).strip()
|
429
|
+
elif isinstance(str_or_bytes, str):
|
430
|
+
return str_or_bytes.strip()
|
431
|
+
return ""
|
432
|
+
|
433
|
+
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",
|
435
|
+
"CHECK": "Validate", "ERROR": "Error"}
|
436
|
+
current_item_type = None
|
437
|
+
current_item_count = 0
|
438
|
+
current_item_total = 0
|
439
|
+
total_item_count = 0
|
440
|
+
for item in LoadGenWrapper(load_all_gen(testapp=portal.vapp, inserts=inserts_directory,
|
441
|
+
docsdir=None, overwrite=True, verbose=True)):
|
442
|
+
total_item_count += 1
|
443
|
+
item = decode_bytes(item)
|
444
|
+
match = LOADXL_RESPONSE_PATTERN.match(item)
|
445
|
+
if not match or match.re.groups < 3:
|
446
|
+
continue
|
447
|
+
action = LOADXL_ACTION_NAME[match.group(1).upper()]
|
448
|
+
# response_value = match.group(0)
|
449
|
+
# identifying_value = match.group(2)
|
450
|
+
item_type = match.group(3)
|
451
|
+
if current_item_type != item_type:
|
452
|
+
if noprogress and debug and current_item_type is not None:
|
453
|
+
print()
|
454
|
+
current_item_type = item_type
|
455
|
+
current_item_count = 0
|
456
|
+
current_item_total = schema_names_to_load[item_type]
|
457
|
+
if progress_bar:
|
458
|
+
progress_bar.set_description(f"▶ {to_camel_case(current_item_type)}: {action}")
|
459
|
+
current_item_count += 1
|
460
|
+
if progress_bar:
|
461
|
+
progress_bar.set_progress(total_item_count)
|
462
|
+
elif debug:
|
463
|
+
print(f"{current_item_type}: {current_item_count} or {current_item_total} ({action})")
|
464
|
+
if progress_bar:
|
465
|
+
progress_bar.set_description("▶ Load Complete")
|
466
|
+
print()
|
467
|
+
|
468
|
+
if not ini_file:
|
469
|
+
ini_file = _DEFAULT_INI_FILE_FOR_LOAD
|
470
|
+
if not os.path.isabs(ini_file := os.path.expanduser(ini_file)):
|
471
|
+
ini_file = os.path.join(os.getcwd(), ini_file)
|
472
|
+
if not os.path.exists(ini_file):
|
473
|
+
_print(f"The INI file required for --load is not found: {ini_file}")
|
474
|
+
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)
|
480
|
+
portal = None
|
481
|
+
with captured_output(not debug):
|
482
|
+
portal = Portal(ini_file)
|
483
|
+
if verbose:
|
484
|
+
_print(f"Loading data files into Portal (via snovault.loadxl) from: {inserts_directory}")
|
485
|
+
_print(f"Portal INI file for load is: {ini_file}")
|
486
|
+
|
487
|
+
schema_names = list(_get_schemas(portal).keys())
|
488
|
+
schema_snake_case_names = [to_snake_case(item) for item in schema_names]
|
489
|
+
schema_names_to_load = {}
|
490
|
+
|
491
|
+
copy_to_temporary_directory = False
|
492
|
+
for json_file_path in glob.glob(os.path.join(inserts_directory, "*.json")):
|
493
|
+
json_file_name = os.path.basename(json_file_path)
|
494
|
+
schema_name = os.path.basename(json_file_name)[:-len(".json")]
|
495
|
+
if (schema_name not in schema_snake_case_names) and (schema_name not in schema_names):
|
496
|
+
_print(f"File is not named for a known schema: {json_file_name} ▶ ignoring")
|
497
|
+
copy_to_temporary_directory = True
|
498
|
+
else:
|
499
|
+
try:
|
500
|
+
with io.open(json_file_path, "r") as f:
|
501
|
+
if not isinstance(data := json.load(f), list):
|
502
|
+
_print("Data JSON file does not contain an array: {json_file_path} ▶ ignoring")
|
503
|
+
copy_to_temporary_directory = True
|
504
|
+
elif (nobjects := len(data)) < 1:
|
505
|
+
_print("Data JSON file contains no items: {json_file_path} ▶ ignoring")
|
506
|
+
copy_to_temporary_directory = True
|
507
|
+
else:
|
508
|
+
schema_names_to_load[schema_name] = nobjects
|
509
|
+
except Exception:
|
510
|
+
_print("Cannot load JSON data from file: {json_file_path} ▶ ignoring")
|
511
|
+
copy_to_temporary_directory = True
|
512
|
+
if not schema_names_to_load:
|
513
|
+
_print("Directory contains no valid data: {inserts_directory}")
|
514
|
+
return
|
515
|
+
if copy_to_temporary_directory:
|
516
|
+
with temporary_directory() as tmpdir:
|
517
|
+
if debug:
|
518
|
+
_print(f"Using temporary directory: {tmpdir}")
|
519
|
+
for json_file_path in glob.glob(os.path.join(inserts_directory, "*.json")):
|
520
|
+
json_file_name = os.path.basename(json_file_path)
|
521
|
+
schema_name = os.path.basename(json_file_name)[:-len(".json")]
|
522
|
+
if (schema_name in schema_snake_case_names) or (schema_name in schema_names):
|
523
|
+
shutil.copy(json_file_path, tmpdir)
|
524
|
+
loadxl(portal=portal, inserts_directory=tmpdir, schema_names_to_load=schema_names_to_load)
|
525
|
+
else:
|
526
|
+
loadxl(portal=portal, inserts_directory=inserts_directory, schema_names_to_load=schema_names_to_load)
|
527
|
+
if verbose:
|
528
|
+
_print(f"Done loading data into Portal (via snovault.loadxl) files from: {inserts_directory}")
|
529
|
+
|
530
|
+
|
426
531
|
def _prune_data_for_update(data: dict, noignore: bool = False, ignore: Optional[List[str]] = None) -> dict:
|
427
532
|
ignore_these_properties = [] if noignore is True else _IGNORE_PROPERTIES_ON_UPDATE
|
428
533
|
if isinstance(ignore, list):
|
@@ -509,6 +614,8 @@ def _get_schema_name_from_schema_named_json_file_name(portal: Portal, value: str
|
|
509
614
|
|
510
615
|
@lru_cache(maxsize=1)
|
511
616
|
def _get_schemas(portal: Portal) -> Optional[dict]:
|
617
|
+
if portal.vapp:
|
618
|
+
return portal.vapp.get("/profiles/?frame=raw").json
|
512
619
|
return portal.get_schemas()
|
513
620
|
|
514
621
|
|
@@ -330,6 +330,8 @@ def _get_portal_object(portal: Portal, uuid: str,
|
|
330
330
|
results_total = len(results)
|
331
331
|
for result in results:
|
332
332
|
results_index += 1
|
333
|
+
if debug:
|
334
|
+
print(f"Processing result: {results_index}")
|
333
335
|
result.pop("schema_version", None)
|
334
336
|
result = prune_data(result)
|
335
337
|
if (subtypes and one_or_more_objects_of_types_exists(portal, subtypes, debug=debug) and
|
@@ -374,14 +376,7 @@ def _get_portal_object(portal: Portal, uuid: str,
|
|
374
376
|
|
375
377
|
def one_or_more_objects_of_types_exists(portal: Portal, schema_types: List[str], debug: bool = False) -> bool:
|
376
378
|
for schema_type in schema_types:
|
377
|
-
|
378
|
-
if one_or_more_objects_of_type_exists(portal, schema_type, debug=debug):
|
379
|
-
return True
|
380
|
-
response = portal.get(f"/{schema_type}")
|
381
|
-
if response and response.status_code == 404:
|
382
|
-
_print(f"There are no objects of sub-type: {schema_type}")
|
383
|
-
return False
|
384
|
-
except Exception:
|
379
|
+
if one_or_more_objects_of_type_exists(portal, schema_type, debug=debug):
|
385
380
|
return True
|
386
381
|
return False
|
387
382
|
|
@@ -393,14 +388,15 @@ def one_or_more_objects_of_type_exists(portal: Portal, schema_type: str, debug:
|
|
393
388
|
_print(f"Checking if there are actually any objects of type: {schema_type}")
|
394
389
|
if portal.get(f"/{schema_type}").status_code == 404:
|
395
390
|
if debug:
|
396
|
-
_print(f"No
|
391
|
+
_print(f"No objects of type actually exist: {schema_type}")
|
392
|
+
return False
|
397
393
|
else:
|
398
394
|
if debug:
|
399
395
|
_print(f"One or more objects of type exist: {schema_type}")
|
400
396
|
except Exception as e:
|
401
|
-
_print(f"ERROR:
|
397
|
+
_print(f"ERROR: Cannot determine if there are actually any objects of type: {schema_type}")
|
402
398
|
_print(e)
|
403
|
-
return
|
399
|
+
return True
|
404
400
|
|
405
401
|
|
406
402
|
@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.1b10" # 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.1b8 → dcicutils-8.14.0.1b10}/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.1b8 → dcicutils-8.14.0.1b10}/dcicutils/license_policies/c4-infrastructure.jsonc
RENAMED
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/dcicutils/license_policies/park-lab-common.jsonc
RENAMED
File without changes
|
File without changes
|
{dcicutils-8.14.0.1b8 → dcicutils-8.14.0.1b10}/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
|