dcicutils 8.9.0.1b1__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.
Files changed (79) hide show
  1. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/PKG-INFO +1 -1
  2. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/misc_utils.py +41 -10
  3. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/portal_utils.py +15 -1
  4. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/structured_data.py +5 -6
  5. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/pyproject.toml +1 -1
  6. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/LICENSE.txt +0 -0
  7. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/README.rst +0 -0
  8. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/__init__.py +0 -0
  9. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/base.py +0 -0
  10. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/beanstalk_utils.py +0 -0
  11. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/bundle_utils.py +0 -0
  12. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/captured_output.py +0 -0
  13. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/cloudformation_utils.py +0 -0
  14. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/codebuild_utils.py +0 -0
  15. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/command_utils.py +0 -0
  16. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/common.py +0 -0
  17. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/contribution_scripts.py +0 -0
  18. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/contribution_utils.py +0 -0
  19. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/creds_utils.py +0 -0
  20. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/data_readers.py +0 -0
  21. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/data_utils.py +0 -0
  22. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/datetime_utils.py +0 -0
  23. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/deployment_utils.py +0 -0
  24. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/diff_utils.py +0 -0
  25. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/docker_utils.py +0 -0
  26. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/ecr_scripts.py +0 -0
  27. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/ecr_utils.py +0 -0
  28. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/ecs_utils.py +0 -0
  29. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/env_base.py +0 -0
  30. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/env_manager.py +0 -0
  31. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/env_scripts.py +0 -0
  32. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/env_utils.py +0 -0
  33. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/env_utils_legacy.py +0 -0
  34. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/es_utils.py +0 -0
  35. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/exceptions.py +0 -0
  36. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/ff_mocks.py +0 -0
  37. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/ff_utils.py +0 -0
  38. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/file_utils.py +0 -0
  39. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/function_cache_decorator.py +0 -0
  40. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/glacier_utils.py +0 -0
  41. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/http_utils.py +0 -0
  42. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/jh_utils.py +0 -0
  43. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/kibana/dashboards.json +0 -0
  44. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/kibana/readme.md +0 -0
  45. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/lang_utils.py +0 -0
  46. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
  47. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
  48. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
  49. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
  50. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
  51. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
  52. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/license_utils.py +0 -0
  53. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/log_utils.py +0 -0
  54. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/obfuscation_utils.py +0 -0
  55. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/opensearch_utils.py +0 -0
  56. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/portal_object_utils.py +0 -0
  57. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/progress_bar.py +0 -0
  58. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/project_utils.py +0 -0
  59. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/qa_checkers.py +0 -0
  60. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/qa_utils.py +0 -0
  61. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/redis_tools.py +0 -0
  62. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/redis_utils.py +0 -0
  63. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/s3_utils.py +0 -0
  64. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/schema_utils.py +0 -0
  65. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/scripts/publish_to_pypi.py +0 -0
  66. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/scripts/run_license_checker.py +0 -0
  67. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/scripts/view_portal_object.py +0 -0
  68. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/secrets_utils.py +0 -0
  69. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/sheet_utils.py +0 -0
  70. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/snapshot_utils.py +0 -0
  71. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/ssl_certificate_utils.py +0 -0
  72. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/submitr/progress_constants.py +0 -0
  73. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
  74. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/task_utils.py +0 -0
  75. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/tmpfile_utils.py +0 -0
  76. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/trace_utils.py +0 -0
  77. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/validation_utils.py +0 -0
  78. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/variant_utils.py +0 -0
  79. {dcicutils-8.9.0.1b1 → dcicutils-8.9.0.1b5}/dcicutils/zip_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcicutils
3
- Version: 8.9.0.1b1
3
+ Version: 8.9.0.1b5
4
4
  Summary: Utility package for interacting with the 4DN Data Portal and other 4DN resources
5
5
  Home-page: https://github.com/4dn-dcic/utils
6
6
  License: MIT
@@ -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]], full: bool = False) -> dict:
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
- The the full argument is True then any target lists longer than the
2207
- source be will be filled out with the last element(s) of the source.
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
- target[key] = merge_objects(target[key], value, full) if key in target else value
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], full)
2219
- elif full:
2220
- target[i] = merge_objects(target[i], source[len(source) - 1], full)
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
 
@@ -17,7 +17,7 @@ from uuid import uuid4 as uuid
17
17
  from webtest.app import TestApp, TestResponse
18
18
  from wsgiref.simple_server import make_server as wsgi_make_server
19
19
  from dcicutils.common import APP_SMAHT, OrchestratedApp, ORCHESTRATED_APPS
20
- from dcicutils.ff_utils import get_metadata, get_schema, patch_metadata, post_metadata
20
+ from dcicutils.ff_utils import delete_metadata, get_metadata, get_schema, patch_metadata, post_metadata, purge_metadata
21
21
  from dcicutils.misc_utils import to_camel_case, VirtualApp
22
22
  from dcicutils.schema_utils import get_identifying_properties
23
23
  from dcicutils.tmpfile_utils import temporary_file
@@ -280,6 +280,20 @@ class Portal:
280
280
  add_on="check_only=True" if check_only else "")
281
281
  return self.post(f"/{object_type}{'?check_only=True' if check_only else ''}", data).json()
282
282
 
283
+ def delete_metadata(self, object_id: str) -> Optional[dict]:
284
+ if isinstance(object_id, str) and object_id:
285
+ if self.key:
286
+ return delete_metadata(obj_id=object_id, key=self.key)
287
+ else:
288
+ return self.patch_metadata(object_id, {"status": "deleted"})
289
+ return None
290
+
291
+ def purge_metadata(self, object_id: str) -> Optional[dict]:
292
+ if isinstance(object_id, str) and object_id:
293
+ if self.key:
294
+ return purge_metadata(obj_id=object_id, key=self.key)
295
+ return None
296
+
283
297
  def get_health(self) -> OptionalResponse:
284
298
  return self.get("/health")
285
299
 
@@ -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.1b1" # TODO: To become 8.10.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