dcicutils 8.8.4.1b35__tar.gz → 8.8.4.1b36__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/PKG-INFO +1 -1
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/misc_utils.py +15 -3
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/structured_data.py +23 -4
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/pyproject.toml +1 -1
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/LICENSE.txt +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/README.rst +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/__init__.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/base.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/beanstalk_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/bundle_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/captured_output.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/cloudformation_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/codebuild_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/command_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/common.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/contribution_scripts.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/contribution_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/creds_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/data_readers.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/data_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/datetime_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/deployment_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/diff_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/docker_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/ecr_scripts.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/ecr_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/ecs_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/env_base.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/env_manager.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/env_scripts.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/env_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/env_utils_legacy.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/es_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/exceptions.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/ff_mocks.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/ff_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/file_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/function_cache_decorator.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/glacier_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/http_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/jh_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/kibana/dashboards.json +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/kibana/readme.md +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/lang_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/license_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/log_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/obfuscation_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/opensearch_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/portal_object_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/portal_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/progress_bar.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/project_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/qa_checkers.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/qa_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/redis_tools.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/redis_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/s3_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/schema_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/scripts/publish_to_pypi.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/scripts/run_license_checker.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/scripts/view_portal_object.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/secrets_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/sheet_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/snapshot_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/ssl_certificate_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/submitr/progress_constants.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/task_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/tmpfile_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/trace_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/validation_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/variant_utils.py +0 -0
- {dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/zip_utils.py +0 -0
@@ -1155,7 +1155,8 @@ def remove_suffix(suffix: str, text: str, required: bool = False):
|
|
1155
1155
|
|
1156
1156
|
def remove_empty_properties(data: Optional[Union[list, dict]],
|
1157
1157
|
isempty: Optional[Callable] = None,
|
1158
|
-
isempty_array_element: Optional[Callable] = None
|
1158
|
+
isempty_array_element: Optional[Callable] = None,
|
1159
|
+
raise_exception_on_nonempty_array_element_after_empty: bool = False) -> None:
|
1159
1160
|
def _isempty(value: Any) -> bool: # noqa
|
1160
1161
|
return isempty(value) if callable(isempty) else value in [None, "", {}, []]
|
1161
1162
|
if isinstance(data, dict):
|
@@ -1163,11 +1164,22 @@ def remove_empty_properties(data: Optional[Union[list, dict]],
|
|
1163
1164
|
if _isempty(value := data[key]):
|
1164
1165
|
del data[key]
|
1165
1166
|
else:
|
1166
|
-
remove_empty_properties(value, isempty=isempty, isempty_array_element=isempty_array_element
|
1167
|
+
remove_empty_properties(value, isempty=isempty, isempty_array_element=isempty_array_element,
|
1168
|
+
raise_exception_on_nonempty_array_element_after_empty= # noqa
|
1169
|
+
raise_exception_on_nonempty_array_element_after_empty)
|
1167
1170
|
elif isinstance(data, list):
|
1168
1171
|
for item in data:
|
1169
|
-
remove_empty_properties(item, isempty=isempty, isempty_array_element=isempty_array_element
|
1172
|
+
remove_empty_properties(item, isempty=isempty, isempty_array_element=isempty_array_element,
|
1173
|
+
raise_exception_on_nonempty_array_element_after_empty= # noqa
|
1174
|
+
raise_exception_on_nonempty_array_element_after_empty)
|
1170
1175
|
if callable(isempty_array_element):
|
1176
|
+
if raise_exception_on_nonempty_array_element_after_empty is True:
|
1177
|
+
empty_element_seen = False
|
1178
|
+
for item in data:
|
1179
|
+
if not empty_element_seen and isempty_array_element(item):
|
1180
|
+
empty_element_seen = True
|
1181
|
+
elif empty_element_seen and not isempty_array_element(item):
|
1182
|
+
raise Exception("Non-empty element found after empty element.")
|
1171
1183
|
data[:] = [item for item in data if not isempty_array_element(item)]
|
1172
1184
|
|
1173
1185
|
|
@@ -53,6 +53,7 @@ class StructuredDataSet:
|
|
53
53
|
def __init__(self, file: Optional[str] = None, portal: Optional[Union[VirtualApp, TestApp, Portal]] = None,
|
54
54
|
schemas: Optional[List[dict]] = None, autoadd: Optional[dict] = None,
|
55
55
|
order: Optional[List[str]] = None, prune: bool = True,
|
56
|
+
remove_empty_objects_from_lists: bool = True,
|
56
57
|
ref_lookup_strategy: Optional[Callable] = None,
|
57
58
|
ref_lookup_nocache: bool = False,
|
58
59
|
norefs: bool = False,
|
@@ -65,7 +66,8 @@ class StructuredDataSet:
|
|
65
66
|
ref_lookup_nocache=ref_lookup_nocache) if portal else None
|
66
67
|
self._ref_lookup_strategy = ref_lookup_strategy
|
67
68
|
self._order = order
|
68
|
-
self._prune = prune
|
69
|
+
self._prune = prune is True
|
70
|
+
self._remove_empty_objects_from_lists = remove_empty_objects_from_lists is True
|
69
71
|
self._warnings = {}
|
70
72
|
self._errors = {}
|
71
73
|
self._resolved_refs = set()
|
@@ -93,12 +95,14 @@ class StructuredDataSet:
|
|
93
95
|
def load(file: str, portal: Optional[Union[VirtualApp, TestApp, Portal]] = None,
|
94
96
|
schemas: Optional[List[dict]] = None, autoadd: Optional[dict] = None,
|
95
97
|
order: Optional[List[str]] = None, prune: bool = True,
|
98
|
+
remove_empty_objects_from_lists: bool = True,
|
96
99
|
ref_lookup_strategy: Optional[Callable] = None,
|
97
100
|
ref_lookup_nocache: bool = False,
|
98
101
|
norefs: bool = False,
|
99
102
|
progress: Optional[Callable] = None,
|
100
103
|
debug_sleep: Optional[str] = None) -> StructuredDataSet:
|
101
104
|
return StructuredDataSet(file=file, portal=portal, schemas=schemas, autoadd=autoadd, order=order, prune=prune,
|
105
|
+
remove_empty_objects_from_lists=remove_empty_objects_from_lists,
|
102
106
|
ref_lookup_strategy=ref_lookup_strategy, ref_lookup_nocache=ref_lookup_nocache,
|
103
107
|
norefs=norefs, progress=progress, debug_sleep=debug_sleep)
|
104
108
|
|
@@ -368,7 +372,11 @@ class StructuredDataSet:
|
|
368
372
|
structured_row_template.set_value(structured_row, column_name, value, reader.file, reader.row_number)
|
369
373
|
if self._autoadd_properties:
|
370
374
|
self._add_properties(structured_row, self._autoadd_properties, schema)
|
371
|
-
self.
|
375
|
+
if (prune_error := self._prune_structured_row(structured_row)) is not None:
|
376
|
+
self._note_error({"src": create_dict(type=schema_name, row=reader.row_number),
|
377
|
+
"error": prune_error}, "validation")
|
378
|
+
else:
|
379
|
+
self._add(type_name, structured_row)
|
372
380
|
if self._progress:
|
373
381
|
self._progress({
|
374
382
|
PROGRESS.LOAD_ITEM: self._nrows,
|
@@ -385,9 +393,20 @@ class StructuredDataSet:
|
|
385
393
|
self._note_error(schema._unresolved_refs, "ref")
|
386
394
|
self._resolved_refs.update(schema._resolved_refs)
|
387
395
|
|
388
|
-
def
|
389
|
-
if self._prune:
|
396
|
+
def _prune_structured_row(self, data: dict) -> Optional[str]:
|
397
|
+
if not self._prune:
|
398
|
+
return None
|
399
|
+
if not self._remove_empty_objects_from_lists:
|
390
400
|
remove_empty_properties(data)
|
401
|
+
return None
|
402
|
+
try:
|
403
|
+
remove_empty_properties(data, isempty_array_element=lambda element: element == {},
|
404
|
+
raise_exception_on_nonempty_array_element_after_empty=True)
|
405
|
+
except Exception as e:
|
406
|
+
return str(e)
|
407
|
+
return None
|
408
|
+
|
409
|
+
def _add(self, type_name: str, data: Union[dict, List[dict]]) -> None:
|
391
410
|
if type_name in self._data:
|
392
411
|
self._data[type_name].extend([data] if isinstance(data, dict) else data)
|
393
412
|
else:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "dcicutils"
|
3
|
-
version = "8.8.4.
|
3
|
+
version = "8.8.4.1b36" # TODO: To become 8.8.5
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/license_policies/c4-infrastructure.jsonc
RENAMED
File without changes
|
File without changes
|
File without changes
|
{dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/license_policies/park-lab-common.jsonc
RENAMED
File without changes
|
{dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc
RENAMED
File without changes
|
{dcicutils-8.8.4.1b35 → dcicutils-8.8.4.1b36}/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
|