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.
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/PKG-INFO +1 -1
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/scripts/view_portal_object.py +91 -42
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/pyproject.toml +1 -1
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/LICENSE.txt +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/README.rst +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/__init__.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/base.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/beanstalk_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/bundle_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/captured_output.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/cloudformation_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/codebuild_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/command_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/common.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/contribution_scripts.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/contribution_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/creds_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/data_readers.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/data_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/datetime_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/deployment_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/diff_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/docker_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ecr_scripts.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ecr_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ecs_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/env_base.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/env_manager.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/env_scripts.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/env_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/env_utils_legacy.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/es_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/exceptions.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ff_mocks.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ff_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/file_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/function_cache_decorator.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/glacier_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/hack_for_elasticsearch_numpy_usage.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/http_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/jh_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/kibana/dashboards.json +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/kibana/readme.md +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/lang_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/log_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/misc_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/obfuscation_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/opensearch_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/portal_object_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/portal_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/progress_bar.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/project_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/qa_checkers.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/qa_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/redis_tools.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/redis_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/s3_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/schema_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/scripts/publish_to_pypi.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/scripts/run_license_checker.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/scripts/update_portal_object.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/secrets_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/sheet_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/snapshot_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/ssl_certificate_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/structured_data.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/submitr/progress_constants.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/task_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/tmpfile_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/trace_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/validation_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/variant_utils.py +0 -0
- {dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/zip_utils.py +0 -0
@@ -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
|
311
|
-
|
312
|
-
if
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
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
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
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.
|
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"
|
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.1b28 → dcicutils-8.14.0.1b29}/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.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/c4-infrastructure.jsonc
RENAMED
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/dcicutils/license_policies/park-lab-common.jsonc
RENAMED
File without changes
|
File without changes
|
{dcicutils-8.14.0.1b28 → dcicutils-8.14.0.1b29}/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
|