dcicutils 8.14.0.1b5__tar.gz → 8.14.0.1b7__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/PKG-INFO +1 -1
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/scripts/update_portal_object.py +0 -1
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/scripts/view_portal_object.py +62 -27
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/pyproject.toml +1 -1
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/LICENSE.txt +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/README.rst +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/__init__.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/base.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/beanstalk_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/bundle_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/captured_output.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/cloudformation_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/codebuild_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/command_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/common.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/contribution_scripts.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/contribution_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/creds_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/data_readers.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/data_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/datetime_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/deployment_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/diff_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/docker_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/ecr_scripts.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/ecr_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/ecs_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/env_base.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/env_manager.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/env_scripts.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/env_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/env_utils_legacy.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/es_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/exceptions.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/ff_mocks.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/ff_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/file_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/function_cache_decorator.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/glacier_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/hack_for_elasticsearch_numpy_usage.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/http_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/jh_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/kibana/dashboards.json +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/kibana/readme.md +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/lang_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/license_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/log_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/misc_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/obfuscation_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/opensearch_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/portal_object_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/portal_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/progress_bar.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/project_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/qa_checkers.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/qa_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/redis_tools.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/redis_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/s3_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/schema_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/scripts/publish_to_pypi.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/scripts/run_license_checker.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/secrets_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/sheet_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/snapshot_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/ssl_certificate_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/structured_data.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/submitr/progress_constants.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/task_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/tmpfile_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/trace_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/validation_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/variant_utils.py +0 -0
- {dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/zip_utils.py +0 -0
@@ -251,7 +251,6 @@ def _post_or_patch_or_upsert(portal: Portal, file_or_directory: str,
|
|
251
251
|
elif isinstance(data, list):
|
252
252
|
if debug:
|
253
253
|
_print(f"DEBUG: File ({file}) contains a list of objects of type: {schema_name}")
|
254
|
-
import pdb ; pdb.set_trace() # noqa
|
255
254
|
data = _impose_special_ordering(data, schema_name)
|
256
255
|
for index, item in enumerate(data):
|
257
256
|
update_function(portal, item, schema_name, file=file, index=index,
|
@@ -122,11 +122,13 @@ def main():
|
|
122
122
|
parser.add_argument("--force", action="store_true", required=False, default=False, help="Debugging output.")
|
123
123
|
parser.add_argument("--terse", action="store_true", required=False, default=False, help="Terse output.")
|
124
124
|
parser.add_argument("--verbose", action="store_true", required=False, default=False, help="Verbose output.")
|
125
|
+
parser.add_argument("--noheader", action="store_true", required=False, default=False, help="Supress header output.")
|
125
126
|
parser.add_argument("--debug", action="store_true", required=False, default=False, help="Debugging output.")
|
126
127
|
args = parser.parse_args()
|
127
128
|
|
128
129
|
portal = _create_portal(ini=args.ini, env=args.env or os.environ.get("SMAHT_ENV"),
|
129
|
-
server=args.server, app=args.app,
|
130
|
+
server=args.server, app=args.app,
|
131
|
+
verbose=args.verbose and not args.noheader, debug=args.debug)
|
130
132
|
|
131
133
|
if not args.uuid:
|
132
134
|
_print("UUID or schema or path required.")
|
@@ -205,7 +207,8 @@ def main():
|
|
205
207
|
|
206
208
|
data = _get_portal_object(portal=portal, uuid=args.uuid, raw=args.raw, database=args.database,
|
207
209
|
inserts=args.inserts, insert_files=args.insert_files,
|
208
|
-
ignore=args.ignore, check=args.bool,
|
210
|
+
ignore=args.ignore, check=args.bool,
|
211
|
+
force=args.force, verbose=args.verbose, debug=args.debug)
|
209
212
|
if args.insert_files:
|
210
213
|
return
|
211
214
|
|
@@ -261,7 +264,8 @@ def _get_portal_object(portal: Portal, uuid: str,
|
|
261
264
|
raw: bool = False, database: bool = False,
|
262
265
|
inserts: bool = False, insert_files: bool = False,
|
263
266
|
ignore: Optional[List[str]] = None,
|
264
|
-
check: bool = False, force: bool = False,
|
267
|
+
check: bool = False, force: bool = False,
|
268
|
+
verbose: bool = False, debug: bool = False) -> dict:
|
265
269
|
|
266
270
|
def prune_data(data: dict) -> dict:
|
267
271
|
nonlocal ignore
|
@@ -269,6 +273,23 @@ def _get_portal_object(portal: Portal, uuid: str,
|
|
269
273
|
return data
|
270
274
|
return {key: value for key, value in data.items() if key not in ignore}
|
271
275
|
|
276
|
+
def get_metadata_for_individual_result_type(uuid: str) -> Optional[dict]: # noqa
|
277
|
+
# There can be a lot of individual results for which we may need to get the actual type,
|
278
|
+
# so do this in a function we were can give verbose output feedback.
|
279
|
+
nonlocal portal, results_index, results_total, verbose
|
280
|
+
if verbose:
|
281
|
+
_print(f"Getting actual type for {results_type} result:"
|
282
|
+
f" {uuid} [{results_index} of {results_total}]", end="")
|
283
|
+
result = portal.get_metadata(uuid, raise_exception=False)
|
284
|
+
if (isinstance(result_types := result.get("@type"), list) and
|
285
|
+
result_types and (result_type := result_types[0])): # noqa
|
286
|
+
if verbose:
|
287
|
+
_print(f" -> {result_type}")
|
288
|
+
return result_type
|
289
|
+
if verbose:
|
290
|
+
_print()
|
291
|
+
return None
|
292
|
+
|
272
293
|
response = None
|
273
294
|
try:
|
274
295
|
if not uuid.startswith("/"):
|
@@ -307,27 +328,11 @@ def _get_portal_object(portal: Portal, uuid: str,
|
|
307
328
|
response = {}
|
308
329
|
results_index = 0
|
309
330
|
results_total = len(results)
|
310
|
-
def get_metadata_for_individual_result_type(uuid: str) -> Optional[dict]: # noqa
|
311
|
-
# There can be a lot of individual results for which we may need to get the actual type,
|
312
|
-
# so do this in a function we were can give verbose output feedback.
|
313
|
-
nonlocal portal, results_index, results_total, verbose
|
314
|
-
if verbose:
|
315
|
-
_print(f"Getting actual type for {results_type} result:"
|
316
|
-
f" {uuid} [{results_index} of {results_total}]", end="")
|
317
|
-
result = portal.get_metadata(uuid, raise_exception=False)
|
318
|
-
if (isinstance(result_types := result.get("@type"), list) and
|
319
|
-
result_types and (result_type := result_types[0])): # noqa
|
320
|
-
if verbose:
|
321
|
-
_print(f" -> {result_type}")
|
322
|
-
return result_type
|
323
|
-
if verbose:
|
324
|
-
_print()
|
325
|
-
return None
|
326
331
|
for result in results:
|
327
332
|
results_index += 1
|
328
333
|
result.pop("schema_version", None)
|
329
334
|
result = prune_data(result)
|
330
|
-
if (subtypes and
|
335
|
+
if (subtypes and one_or_more_objects_of_types_exists(portal, subtypes, debug=debug) and
|
331
336
|
(result_uuid := result.get("uuid")) and
|
332
337
|
(individual_result_type := get_metadata_for_individual_result_type(result_uuid))): # noqa
|
333
338
|
result_type = individual_result_type
|
@@ -347,19 +352,18 @@ def _get_portal_object(portal: Portal, uuid: str,
|
|
347
352
|
schema_data = response[schema_name]
|
348
353
|
file_name = f"{to_snake_case(schema_name)}.json"
|
349
354
|
file_path = os.path.join(output_directory, file_name)
|
355
|
+
message_verb = "Writing"
|
350
356
|
if os.path.exists(file_path):
|
357
|
+
message_verb = "Overwriting"
|
351
358
|
if os.path.isdir(file_path):
|
352
359
|
_print(f"WARNING: Output file already exists as a directory. SKIPPING: {file_path}")
|
353
360
|
continue
|
354
|
-
if force:
|
355
|
-
if verbose:
|
356
|
-
_print(f"Overwriting extant file (per --force option): {file_path}")
|
357
|
-
else:
|
361
|
+
if not force:
|
358
362
|
_print(f"Output file already exists: {file_path}")
|
359
|
-
|
360
|
-
|
363
|
+
if not yes_or_no(f"Overwrite this file?"):
|
364
|
+
continue
|
361
365
|
if verbose:
|
362
|
-
_print(f"
|
366
|
+
_print(f"{message_verb} {schema_name} (object{'s' if len(schema_data) != 1 else ''}:"
|
363
367
|
f" {len(schema_data)}) file: {file_path}")
|
364
368
|
with io.open(file_path, "w") as f:
|
365
369
|
json.dump(schema_data, f, indent=4)
|
@@ -368,6 +372,37 @@ def _get_portal_object(portal: Portal, uuid: str,
|
|
368
372
|
return response
|
369
373
|
|
370
374
|
|
375
|
+
def one_or_more_objects_of_types_exists(portal: Portal, schema_types: List[str], debug: bool = False) -> bool:
|
376
|
+
for schema_type in schema_types:
|
377
|
+
try:
|
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:
|
385
|
+
return True
|
386
|
+
return False
|
387
|
+
|
388
|
+
|
389
|
+
@lru_cache(maxsize=64)
|
390
|
+
def one_or_more_objects_of_type_exists(portal: Portal, schema_type: str, debug: bool = False) -> bool:
|
391
|
+
try:
|
392
|
+
if debug:
|
393
|
+
_print(f"Checking if there are actually any objects of type: {schema_type}")
|
394
|
+
if portal.get(f"/{schema_type}").status_code == 404:
|
395
|
+
if debug:
|
396
|
+
_print(f"No any objects of type exist: {schema_type}")
|
397
|
+
else:
|
398
|
+
if debug:
|
399
|
+
_print(f"One or more objects of type exist: {schema_type}")
|
400
|
+
except Exception as e:
|
401
|
+
_print(f"ERROR: Checking if there are actually any objects of type: {schema_type}")
|
402
|
+
_print(e)
|
403
|
+
return False
|
404
|
+
|
405
|
+
|
371
406
|
@lru_cache(maxsize=1)
|
372
407
|
def _get_schemas(portal: Portal) -> Optional[dict]:
|
373
408
|
return portal.get_schemas()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "dcicutils"
|
3
|
-
version = "8.14.0.
|
3
|
+
version = "8.14.0.1b7" # 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.1b5 → dcicutils-8.14.0.1b7}/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.1b5 → dcicutils-8.14.0.1b7}/dcicutils/license_policies/c4-infrastructure.jsonc
RENAMED
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/license_policies/park-lab-common.jsonc
RENAMED
File without changes
|
{dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc
RENAMED
File without changes
|
{dcicutils-8.14.0.1b5 → dcicutils-8.14.0.1b7}/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
|