dcicutils 8.7.1.1b5__tar.gz → 8.7.1.1b6__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/PKG-INFO +1 -1
  2. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/misc_utils.py +13 -0
  3. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/portal_object_utils.py +27 -13
  4. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/structured_data.py +1 -1
  5. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/pyproject.toml +1 -1
  6. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/LICENSE.txt +0 -0
  7. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/README.rst +0 -0
  8. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/__init__.py +0 -0
  9. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/base.py +0 -0
  10. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/beanstalk_utils.py +0 -0
  11. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/bundle_utils.py +0 -0
  12. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/cloudformation_utils.py +0 -0
  13. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/codebuild_utils.py +0 -0
  14. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/command_utils.py +0 -0
  15. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/common.py +0 -0
  16. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/contribution_scripts.py +0 -0
  17. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/contribution_utils.py +0 -0
  18. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/creds_utils.py +0 -0
  19. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/data_readers.py +0 -0
  20. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/data_utils.py +0 -0
  21. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/deployment_utils.py +0 -0
  22. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/diff_utils.py +0 -0
  23. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/docker_utils.py +0 -0
  24. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/ecr_scripts.py +0 -0
  25. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/ecr_utils.py +0 -0
  26. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/ecs_utils.py +0 -0
  27. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/env_base.py +0 -0
  28. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/env_manager.py +0 -0
  29. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/env_scripts.py +0 -0
  30. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/env_utils.py +0 -0
  31. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/env_utils_legacy.py +0 -0
  32. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/es_utils.py +0 -0
  33. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/exceptions.py +0 -0
  34. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/ff_mocks.py +0 -0
  35. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/ff_utils.py +0 -0
  36. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/file_utils.py +0 -0
  37. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/function_cache_decorator.py +0 -0
  38. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/glacier_utils.py +0 -0
  39. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/jh_utils.py +0 -0
  40. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/kibana/dashboards.json +0 -0
  41. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/kibana/readme.md +0 -0
  42. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/lang_utils.py +0 -0
  43. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
  44. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
  45. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
  46. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
  47. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
  48. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
  49. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/license_utils.py +0 -0
  50. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/log_utils.py +0 -0
  51. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/obfuscation_utils.py +0 -0
  52. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/opensearch_utils.py +0 -0
  53. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/portal_utils.py +0 -0
  54. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/project_utils.py +0 -0
  55. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/qa_checkers.py +0 -0
  56. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/qa_utils.py +0 -0
  57. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/redis_tools.py +0 -0
  58. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/redis_utils.py +0 -0
  59. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/s3_utils.py +0 -0
  60. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/schema_utils.py +0 -0
  61. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/scripts/publish_to_pypi.py +0 -0
  62. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/scripts/run_license_checker.py +0 -0
  63. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/secrets_utils.py +0 -0
  64. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/sheet_utils.py +0 -0
  65. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/snapshot_utils.py +0 -0
  66. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/ssl_certificate_utils.py +0 -0
  67. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/task_utils.py +0 -0
  68. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/tmpfile_utils.py +0 -0
  69. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/trace_utils.py +0 -0
  70. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/validation_utils.py +0 -0
  71. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/variant_utils.py +0 -0
  72. {dcicutils-8.7.1.1b5 → dcicutils-8.7.1.1b6}/dcicutils/zip_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcicutils
3
- Version: 8.7.1.1b5
3
+ Version: 8.7.1.1b6
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
@@ -2,6 +2,7 @@
2
2
  This file contains functions that might be generally useful.
3
3
  """
4
4
 
5
+ from collections import namedtuple
5
6
  import contextlib
6
7
  import datetime
7
8
  import functools
@@ -17,6 +18,7 @@ import re
17
18
  import rfc3986.validators
18
19
  import rfc3986.exceptions
19
20
  import time
21
+ import uuid
20
22
  import warnings
21
23
  import webtest # importing the library makes it easier to mock testing
22
24
 
@@ -1525,6 +1527,17 @@ def create_dict(**kwargs) -> dict:
1525
1527
  return result
1526
1528
 
1527
1529
 
1530
+ def create_readonly_object(**kwargs):
1531
+ """
1532
+ Returns a new/unique object instance with readonly properties equal to the give kwargs.
1533
+ """
1534
+ readonly_class_name = "readonlyclass_" + str(uuid.uuid4()).replace("-", "")
1535
+ readonly_class_args = " ".join(kwargs.keys())
1536
+ readonly_class = namedtuple(readonly_class_name, readonly_class_args)
1537
+ readonly_object = readonly_class(**kwargs)
1538
+ return readonly_object
1539
+
1540
+
1528
1541
  def is_c4_arn(arn: str) -> bool:
1529
1542
  """
1530
1543
  Returns True iff the given (presumed) AWS ARN string value looks like it
@@ -3,6 +3,7 @@ from functools import lru_cache
3
3
  import re
4
4
  from typing import Any, List, Optional, Tuple, Type, Union
5
5
  from dcicutils.data_readers import RowReader
6
+ from dcicutils.misc_utils import create_readonly_object
6
7
  from dcicutils.portal_utils import Portal
7
8
  from dcicutils.schema_utils import Schema
8
9
 
@@ -136,21 +137,33 @@ class PortalObject:
136
137
  comparing_data = value
137
138
  else:
138
139
  return {}
139
- return PortalObject._compare(this_data, comparing_data)
140
+ return PortalObject._compare(this_data, comparing_data, self.type)
140
141
 
141
142
  _ARRAY_KEY_REGULAR_EXPRESSION = re.compile(rf"^({Schema._ARRAY_NAME_SUFFIX_CHAR}\d+)$")
142
143
 
143
144
  @staticmethod
144
- def _compare(a: Any, b: Any, _path: Optional[str] = None) -> dict:
145
+ def _compare(a: Any, b: Any, value_type: str, _path: Optional[str] = None) -> dict:
146
+ def diff_creating(value: Any) -> object: # noqa
147
+ nonlocal value_type
148
+ return create_readonly_object(value=value, type=value_type,
149
+ creating_value=True, updating_value=None, deleting_value=False)
150
+ def diff_updating(value: Any, updating_value: Any) -> object: # noqa
151
+ nonlocal value_type
152
+ return create_readonly_object(value=value, type=value_type,
153
+ creating_value=False, updating_value=updating_value, deleting_value=False)
154
+ def diff_deleting(value: Any) -> object: # noqa
155
+ nonlocal value_type
156
+ return create_readonly_object(value=value, type=value_type,
157
+ creating_value=False, updating_value=None, deleting_value=True)
145
158
  diffs = {}
146
159
  if isinstance(a, dict) and isinstance(b, dict):
147
160
  for key in a:
148
161
  path = f"{_path}.{key}" if _path else key
149
162
  if key not in b:
150
163
  if a[key] != PortalObject._PROPERTY_DELETION_SENTINEL:
151
- diffs[path] = {"value": a[key], "creating_value": True}
164
+ diffs[path] = diff_creating(a[key])
152
165
  else:
153
- diffs.update(PortalObject._compare(a[key], b[key], _path=path))
166
+ diffs.update(PortalObject._compare(a[key], b[key], type, _path=path))
154
167
  elif isinstance(a, list) and isinstance(b, list):
155
168
  # Ignore order of array elements; not absolutely technically correct but suits our purpose.
156
169
  for index in range(len(a)):
@@ -159,21 +172,21 @@ class PortalObject:
159
172
  if a[index] not in b:
160
173
  if a[index] != PortalObject._PROPERTY_DELETION_SENTINEL:
161
174
  if index < len(b):
162
- diffs[path] = {"value": a[index], "updating_value": b[index]}
175
+ diffs[path] = diff_updating(a[index], b[index])
163
176
  else:
164
- diffs[path] = {"value": a[index], "creating_value": True}
177
+ diffs[path] = diff_creating(a[index])
165
178
  else:
166
179
  if index < len(b):
167
- diffs[path] = {"value": b[index], "deleting_value": True}
180
+ diffs[path] = diff_deleting(b[index])
168
181
  elif len(b) < index:
169
- diffs.update(PortalObject._compare(a[index], b[index], _path=path))
182
+ diffs.update(PortalObject._compare(a[index], b[index], value_type, _path=path))
170
183
  else:
171
- diffs[path] = {"value": a[index], "creating_value": True}
184
+ diffs[path] = diff_creating(a[index])
172
185
  elif a != b:
173
186
  if a == PortalObject._PROPERTY_DELETION_SENTINEL:
174
- diffs[_path] = {"value": b, "deleting_value": True}
187
+ diffs[_path] = diff_deleting(b)
175
188
  else:
176
- diffs[_path] = {"value": a, "updating_value": b}
189
+ diffs[_path] = diff_updating(a, b)
177
190
  return diffs
178
191
 
179
192
  def normalize_refs(self, refs: List[dict]) -> None:
@@ -183,8 +196,9 @@ class PortalObject:
183
196
  based on the given "refs" list which is assumed to be a list of dictionaries, where each
184
197
  contains a "path" and a "uuid" property; this list is typically (for our first usage of
185
198
  this function) the value of structured_data.StructuredDataSet.resolved_refs_with_uuid.
186
- Change is made to this Portal object in place; use normalized_refs function to make a copy.
187
- If there are no "refs" (None or empty) then the references will be looked up via Portal calls.
199
+ Changes are made to this Portal object in place; use normalized_refs function to make a copy.
200
+ If there are no "refs" (None or empty) or if the speicified reference is not found in this
201
+ list then the references will be looked up via Portal calls (via Portal.get_metadata).
188
202
  """
189
203
  PortalObject._normalize_refs(self.data, refs=refs, schema=self.schema, portal=self.portal)
190
204
 
@@ -369,7 +369,7 @@ class Schema:
369
369
  def validate(self, data: dict) -> List[str]:
370
370
  errors = []
371
371
  for error in SchemaValidator(self.data, format_checker=SchemaValidator.FORMAT_CHECKER).iter_errors(data):
372
- errors.append(error.message)
372
+ errors.append(f"Validation error at '{error.json_path}': {error.message}")
373
373
  return errors
374
374
 
375
375
  def get_typeinfo(self, column_name: str) -> Optional[dict]:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dcicutils"
3
- version = "8.7.1.1b5" # TODO: To become 8.7.2
3
+ version = "8.7.1.1b6" # TODO: To become 8.7.2
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