dcicutils 8.9.0.1b2__tar.gz → 8.9.0.1b5__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/PKG-INFO +1 -1
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/misc_utils.py +41 -10
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/structured_data.py +5 -6
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/pyproject.toml +1 -1
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/LICENSE.txt +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/README.rst +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/__init__.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/base.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/beanstalk_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/bundle_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/captured_output.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/cloudformation_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/codebuild_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/command_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/common.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/contribution_scripts.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/contribution_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/creds_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/data_readers.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/data_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/datetime_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/deployment_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/diff_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/docker_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/ecr_scripts.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/ecr_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/ecs_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/env_base.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/env_manager.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/env_scripts.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/env_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/env_utils_legacy.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/es_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/exceptions.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/ff_mocks.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/ff_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/file_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/function_cache_decorator.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/glacier_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/http_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/jh_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/kibana/dashboards.json +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/kibana/readme.md +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/lang_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/log_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/obfuscation_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/opensearch_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/portal_object_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/portal_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/progress_bar.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/project_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/qa_checkers.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/qa_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/redis_tools.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/redis_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/s3_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/schema_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/scripts/publish_to_pypi.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/scripts/run_license_checker.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/scripts/view_portal_object.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/secrets_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/sheet_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/snapshot_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/ssl_certificate_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/submitr/progress_constants.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/task_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/tmpfile_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/trace_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/validation_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/variant_utils.py +0 -0
- {dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/zip_utils.py +0 -0
@@ -4,6 +4,7 @@ This file contains functions that might be generally useful.
|
|
4
4
|
|
5
5
|
from collections import namedtuple
|
6
6
|
import appdirs
|
7
|
+
from copy import deepcopy
|
7
8
|
import contextlib
|
8
9
|
import datetime
|
9
10
|
import functools
|
@@ -2199,28 +2200,58 @@ def merge_key_value_dict_lists(x, y):
|
|
2199
2200
|
return [key_value_dict(k, v) for k, v in merged.items()]
|
2200
2201
|
|
2201
2202
|
|
2202
|
-
def merge_objects(target: Union[dict, List[Any]], source: Union[dict, List[Any]],
|
2203
|
+
def merge_objects(target: Union[dict, List[Any]], source: Union[dict, List[Any]],
|
2204
|
+
full: bool = False, # deprecated
|
2205
|
+
expand_lists: Optional[bool] = None,
|
2206
|
+
primitive_lists: bool = False,
|
2207
|
+
copy: bool = False, _recursing: bool = False) -> Union[dict, List[Any]]:
|
2203
2208
|
"""
|
2204
|
-
Merges the given source dictionary or list into the target dictionary or list
|
2205
|
-
This MAY well change the given target (dictionary or list) IN PLACE
|
2206
|
-
|
2207
|
-
|
2209
|
+
Merges the given source dictionary or list into the target dictionary or list and returns the
|
2210
|
+
result. This MAY well change the given target (dictionary or list) IN PLACE ... UNLESS the copy
|
2211
|
+
argument is True, then the given target will not change as a local copy is made (and returned).
|
2212
|
+
|
2213
|
+
If the expand_lists argument is True then any target lists longer than the
|
2214
|
+
source be will be filled out with the last element(s) of the source; the full
|
2215
|
+
argument (is deprecated and) is a synomym for this. The default is False.
|
2216
|
+
|
2217
|
+
If the primitive_lists argument is True then lists of primitives (i.e. lists in which
|
2218
|
+
NONE of its elements are dictionaries, lists, or tuples) will themselves be treated
|
2219
|
+
like primitives, meaning the whole of a source list will replace the corresponding
|
2220
|
+
target; otherwise they will be merged normally, meaning each element of a source list
|
2221
|
+
will be merged, recursively, into the corresponding target list. The default is False.
|
2208
2222
|
"""
|
2223
|
+
def is_primitive_list(value: Any) -> bool: # noqa
|
2224
|
+
if not isinstance(value, list):
|
2225
|
+
return False
|
2226
|
+
for item in value:
|
2227
|
+
if isinstance(item, (dict, list, tuple)):
|
2228
|
+
return False
|
2229
|
+
return True
|
2230
|
+
|
2209
2231
|
if target is None:
|
2210
2232
|
return source
|
2233
|
+
if expand_lists not in (True, False):
|
2234
|
+
expand_lists = full is True
|
2235
|
+
if (copy is True) and (_recursing is not True):
|
2236
|
+
target = deepcopy(target)
|
2211
2237
|
if isinstance(target, dict) and isinstance(source, dict) and source:
|
2212
2238
|
for key, value in source.items():
|
2213
|
-
|
2239
|
+
if ((primitive_lists is True) and
|
2240
|
+
(key in target) and is_primitive_list(target[key]) and is_primitive_list(value)): # noqa
|
2241
|
+
target[key] = value
|
2242
|
+
else:
|
2243
|
+
target[key] = merge_objects(target[key], value,
|
2244
|
+
expand_lists=expand_lists, _recursing=True) if key in target else value
|
2214
2245
|
elif isinstance(target, list) and isinstance(source, list) and source:
|
2215
2246
|
for i in range(max(len(source), len(target))):
|
2216
2247
|
if i < len(target):
|
2217
2248
|
if i < len(source):
|
2218
|
-
target[i] = merge_objects(target[i], source[i],
|
2219
|
-
elif
|
2220
|
-
target[i] = merge_objects(target[i], source[len(source) - 1],
|
2249
|
+
target[i] = merge_objects(target[i], source[i], expand_lists=expand_lists, _recursing=True)
|
2250
|
+
elif expand_lists is True:
|
2251
|
+
target[i] = merge_objects(target[i], source[len(source) - 1], expand_lists=expand_lists)
|
2221
2252
|
else:
|
2222
2253
|
target.append(source[i])
|
2223
|
-
elif source:
|
2254
|
+
elif source not in (None, {}, []):
|
2224
2255
|
target = source
|
2225
2256
|
return target
|
2226
2257
|
|
@@ -74,7 +74,7 @@ class StructuredDataSet:
|
|
74
74
|
self._nrows = 0
|
75
75
|
self._autoadd_properties = autoadd if isinstance(autoadd, dict) and autoadd else None
|
76
76
|
self._norefs = True if norefs is True else False
|
77
|
-
self._merge = True if merge is True else False
|
77
|
+
self._merge = True if merge is True else False # New merge functionality (2024-05-25)
|
78
78
|
self._debug_sleep = None
|
79
79
|
if debug_sleep:
|
80
80
|
try:
|
@@ -347,7 +347,7 @@ class StructuredDataSet:
|
|
347
347
|
(self._portal.get_schema(schema_name_inferred_from_file_name) is not None)): # noqa
|
348
348
|
# If the JSON file name looks like a schema name then assume it
|
349
349
|
# contains an object or an array of object of that schema type.
|
350
|
-
if self._merge:
|
350
|
+
if self._merge: # New merge functionality (2024-05-25)
|
351
351
|
data = self._merge_with_existing_portal_object(data, schema_name_inferred_from_file_name)
|
352
352
|
self._add(Schema.type_name(file), data)
|
353
353
|
elif isinstance(data, dict):
|
@@ -356,7 +356,7 @@ class StructuredDataSet:
|
|
356
356
|
# which (each property) contains a list of object of that schema type.
|
357
357
|
for schema_name in data:
|
358
358
|
item = data[schema_name]
|
359
|
-
if self._merge:
|
359
|
+
if self._merge: # New merge functionality (2024-05-25)
|
360
360
|
item = self._merge_with_existing_portal_object(item, schema_name)
|
361
361
|
self._add(schema_name, item)
|
362
362
|
|
@@ -380,8 +380,7 @@ class StructuredDataSet:
|
|
380
380
|
structured_row_template.set_value(structured_row, column_name, value, reader.file, reader.row_number)
|
381
381
|
if self._autoadd_properties:
|
382
382
|
self._add_properties(structured_row, self._autoadd_properties, schema)
|
383
|
-
# New merge functionality (2024-05-25)
|
384
|
-
if self._merge:
|
383
|
+
if self._merge: # New merge functionality (2024-05-25)
|
385
384
|
structured_row = self._merge_with_existing_portal_object(structured_row, schema_name)
|
386
385
|
if (prune_error := self._prune_structured_row(structured_row)) is not None:
|
387
386
|
self._note_error({"src": create_dict(type=schema_name, row=reader.row_number),
|
@@ -437,7 +436,7 @@ class StructuredDataSet:
|
|
437
436
|
"""
|
438
437
|
for identifying_path in self._portal.get_identifying_paths(portal_object, portal_type):
|
439
438
|
if existing_portal_object := self._portal.get_metadata(identifying_path, raw=True, raise_exception=False):
|
440
|
-
return merge_objects(existing_portal_object, portal_object)
|
439
|
+
return merge_objects(existing_portal_object, portal_object, primitive_lists=True)
|
441
440
|
return portal_object
|
442
441
|
|
443
442
|
def _is_ref_lookup_specified_type(ref_lookup_flags: int) -> bool:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "dcicutils"
|
3
|
-
version = "8.9.0.
|
3
|
+
version = "8.9.0.1b5" # TODO: To become 8.10.0
|
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.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/c4-infrastructure.jsonc
RENAMED
File without changes
|
File without changes
|
{dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-common-server.jsonc
RENAMED
File without changes
|
{dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-common.jsonc
RENAMED
File without changes
|
{dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc
RENAMED
File without changes
|
{dcicutils-8.9.0.1b2 → dcicutils-8.9.0.1b5}/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
|