dcicutils 8.7.0.1b36__tar.gz → 8.7.0.1b37__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.0.1b36 → dcicutils-8.7.0.1b37}/PKG-INFO +1 -1
  2. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/portal_object_utils.py +1 -64
  3. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/schema_utils.py +1 -85
  4. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/pyproject.toml +1 -1
  5. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/LICENSE.txt +0 -0
  6. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/README.rst +0 -0
  7. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/__init__.py +0 -0
  8. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/base.py +0 -0
  9. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/beanstalk_utils.py +0 -0
  10. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/bundle_utils.py +0 -0
  11. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/cloudformation_utils.py +0 -0
  12. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/codebuild_utils.py +0 -0
  13. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/command_utils.py +0 -0
  14. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/common.py +0 -0
  15. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/contribution_scripts.py +0 -0
  16. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/contribution_utils.py +0 -0
  17. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/creds_utils.py +0 -0
  18. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/data_readers.py +0 -0
  19. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/data_utils.py +0 -0
  20. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/deployment_utils.py +0 -0
  21. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/diff_utils.py +0 -0
  22. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/docker_utils.py +0 -0
  23. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/ecr_scripts.py +0 -0
  24. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/ecr_utils.py +0 -0
  25. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/ecs_utils.py +0 -0
  26. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/env_base.py +0 -0
  27. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/env_manager.py +0 -0
  28. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/env_scripts.py +0 -0
  29. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/env_utils.py +0 -0
  30. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/env_utils_legacy.py +0 -0
  31. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/es_utils.py +0 -0
  32. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/exceptions.py +0 -0
  33. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/ff_mocks.py +0 -0
  34. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/ff_utils.py +0 -0
  35. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/file_utils.py +0 -0
  36. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/function_cache_decorator.py +0 -0
  37. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/glacier_utils.py +0 -0
  38. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/jh_utils.py +0 -0
  39. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/kibana/dashboards.json +0 -0
  40. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/kibana/readme.md +0 -0
  41. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/lang_utils.py +0 -0
  42. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
  43. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
  44. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
  45. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
  46. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
  47. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
  48. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/license_utils.py +0 -0
  49. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/log_utils.py +0 -0
  50. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/misc_utils.py +0 -0
  51. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/obfuscation_utils.py +0 -0
  52. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/opensearch_utils.py +0 -0
  53. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/portal_utils.py +0 -0
  54. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/project_utils.py +0 -0
  55. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/qa_checkers.py +0 -0
  56. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/qa_utils.py +0 -0
  57. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/redis_tools.py +0 -0
  58. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/redis_utils.py +0 -0
  59. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/s3_utils.py +0 -0
  60. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/scripts/publish_to_pypi.py +0 -0
  61. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/scripts/run_license_checker.py +0 -0
  62. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/secrets_utils.py +0 -0
  63. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/sheet_utils.py +0 -0
  64. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/snapshot_utils.py +0 -0
  65. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/ssl_certificate_utils.py +0 -0
  66. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/structured_data.py +0 -0
  67. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/task_utils.py +0 -0
  68. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/tmpfile_utils.py +0 -0
  69. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/trace_utils.py +0 -0
  70. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/validation_utils.py +0 -0
  71. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/variant_utils.py +0 -0
  72. {dcicutils-8.7.0.1b36 → dcicutils-8.7.0.1b37}/dcicutils/zip_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcicutils
3
- Version: 8.7.0.1b36
3
+ Version: 8.7.0.1b37
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
@@ -1,8 +1,6 @@
1
1
  from functools import lru_cache
2
- import re
3
- from typing import Any, Callable, List, Optional, Tuple, Type, Union
2
+ from typing import List, Optional, Tuple, Type, Union
4
3
  from dcicutils.portal_utils import Portal
5
- from dcicutils.schema_utils import Schema
6
4
 
7
5
  PortalObject = Type["PortalObject"] # Forward type reference for type hints.
8
6
 
@@ -112,64 +110,3 @@ class PortalObject:
112
110
  except Exception:
113
111
  pass
114
112
  return None, self.identifying_path
115
-
116
- def compare(self, value: Union[dict, PortalObject], consider_link_to: bool = False) -> dict:
117
- """
118
- Compares this Portal object against the given Portal object value; noting differences values of properites
119
- which they have in common; and properties which are in this Portal object and not in the given Portal object;
120
- we do NOT check the converse, i.e. properties in the given Portal object which are not in this Portal object.
121
- Returns a dictionary with a description of the differences. If the given consider_link_to flag is True then
122
- TODO.
123
- """
124
- def are_properties_equal(property_path: str, property_value_a: Any, property_value_b: Any) -> bool:
125
- if property_value_a == property_value_b:
126
- return True
127
- nonlocal self
128
- if (schema := self.schema) and (property_type := Schema.get_property_by_path(schema, property_path)):
129
- if link_to := property_type.get("linkTo"):
130
- """
131
- This works basically except not WRT sub/super-types (e.g. CellCultureSample vs Sample);
132
- this is only preferable as it only requires one Portal GET rather than two, as below.
133
- if (a := self._portal.get(f"/{link_to}/{property_value_a}")) and (a.status_code == 200):
134
- if a_identifying_paths := PortalObject(self._portal, a.json()).identifying_paths:
135
- if f"/{link_to}/{property_value_b}" in a_identifying_paths:
136
- return True
137
- """
138
- if a := self._portal.get(f"/{link_to}/{property_value_a}", raw=True):
139
- if (a.status_code == 200) and (a := a.json()):
140
- if b := self._portal.get(f"/{link_to}/{property_value_b}", raw=True):
141
- if (b.status_code == 200) and (b := b.json()):
142
- return a == b
143
- return False
144
- return PortalObject._compare(self._data, value.data if isinstance(value, PortalObject) else value,
145
- compare=are_properties_equal if consider_link_to else None)
146
-
147
- _ARRAY_KEY_REGULAR_EXPRESSION = re.compile(rf"^({Schema._ARRAY_NAME_SUFFIX_CHAR}\d+)$")
148
-
149
- @staticmethod
150
- def _compare(a: dict, b: dict, compare: Optional[Callable] = None, _path: Optional[str] = None) -> dict:
151
- def key_to_path(key: str) -> Optional[str]: # noqa
152
- nonlocal _path
153
- if match := PortalObject._ARRAY_KEY_REGULAR_EXPRESSION.search(key):
154
- return f"{_path}{match.group(1)}" if _path else match.group(1)
155
- return f"{_path}.{key}" if _path else key
156
- def list_to_dictionary(value: list) -> dict: # noqa
157
- result = {}
158
- for index, item in enumerate(sorted(value)): # ignore array order
159
- result[f"#{index}"] = item
160
- return result
161
- diffs = {}
162
- for key in a:
163
- path = key_to_path(key)
164
- if key not in b:
165
- diffs[path] = {"value": a[key], "missing_value": True}
166
- else:
167
- if isinstance(a[key], dict) and isinstance(b[key], dict):
168
- diffs.update(PortalObject._compare(a[key], b[key], compare=compare, _path=path))
169
- elif isinstance(a[key], list) and isinstance(b[key], list):
170
- diffs.update(PortalObject._compare(list_to_dictionary(a[key]),
171
- list_to_dictionary(b[key]), compare=compare, _path=path))
172
- elif a[key] != b[key]:
173
- if not callable(compare) or not compare(path, a[key], b[key]):
174
- diffs[path] = {"value": a[key], "differing_value": b[key]}
175
- return diffs
@@ -1,6 +1,4 @@
1
- import os
2
- from typing import Any, Dict, List, Optional, Tuple
3
- from dcicutils.misc_utils import to_camel_case
1
+ from typing import Any, Dict, List
4
2
 
5
3
 
6
4
  class JsonSchemaConstants:
@@ -185,85 +183,3 @@ def get_one_of_formats(schema: Dict[str, Any]) -> List[str]:
185
183
  for one_of_schema in get_one_of(schema)
186
184
  if get_format(one_of_schema)
187
185
  ]
188
-
189
-
190
- class Schema:
191
-
192
- def __init__(self, schema: dict, schema_type: Optional[str] = None) -> None:
193
- self._data = schema if isinstance(schema, dict) else (schema.data if isinstance(schema, Schema) else {})
194
- self._type = (isinstance(schema_type, str) and schema_type) or Schema.type_name(self._data.get("title", ""))
195
-
196
- @property
197
- def data(self) -> dict:
198
- return self._data
199
-
200
- @property
201
- def type(self) -> str:
202
- return self._type
203
-
204
- @staticmethod
205
- def type_name(value: str) -> Optional[str]: # File or other name.
206
- if isinstance(value, str) and (value := os.path.basename(value.replace(" ", ""))):
207
- return to_camel_case(value[0:dot] if (dot := value.rfind(".")) >= 0 else value)
208
-
209
- def property_by_path(self, property_path: str) -> Optional[dict]:
210
- """
211
- Looks for the given property path within this Portal schema and returns its dictionary value.
212
- This given property path can be either a simple property name, or a series of dot-separated
213
- property names representing nested (object) properties; and/or the property names may be
214
- suffixed with a pound (#) characteter, optionally followed by an integer, representing an
215
- array type property and its optional array index (this integer, if specified, is ignored
216
- for the purposes of this function, but it may have been created by another process/function,
217
- for example by PortalObject.compare). If the property is not found then None is returned.
218
- """
219
- return Schema.get_property_by_path(self._data, property_path)
220
-
221
- _ARRAY_NAME_SUFFIX_CHAR = "#"
222
- _DOTTED_NAME_DELIMITER_CHAR = "."
223
-
224
- @staticmethod
225
- def get_property_by_path(schema: dict, property_path: str) -> Optional[dict]:
226
- if not isinstance(schema, dict) or not isinstance(property_path, str):
227
- return None
228
- elif not (schema_properties := schema.get("properties")):
229
- return None
230
- property_paths = property_path.split(Schema._DOTTED_NAME_DELIMITER_CHAR)
231
- for property_index, property_name in enumerate(property_paths):
232
- property_name, array_specifiers = Schema._unarrayize_property_name(property_name)
233
- if not (property_value := schema_properties.get(property_name)):
234
- return None
235
- elif (property_type := property_value.get("type")) == "object":
236
- property_paths_tail = Schema._DOTTED_NAME_DELIMITER_CHAR.join(property_paths[property_index + 1:])
237
- return Schema.get_property_by_path(property_value, property_paths_tail)
238
- elif (property_type := property_value.get("type")) == "array":
239
- if not array_specifiers:
240
- if property_index == len(property_paths) - 1:
241
- return property_value
242
- return None
243
- for array_index in range(len(array_specifiers)):
244
- if property_type != "array":
245
- return None
246
- elif not (array_items := property_value.get("items")):
247
- return None
248
- property_type = (property_value := array_items).get("type")
249
- if property_type == "object":
250
- if property_index == len(property_paths) - 1:
251
- return property_value
252
- property_paths_tail = Schema._DOTTED_NAME_DELIMITER_CHAR.join(property_paths[property_index + 1:])
253
- return Schema.get_property_by_path(property_value, property_paths_tail)
254
- return property_value
255
-
256
- @staticmethod
257
- def _unarrayize_property_name(property_name: str) -> Tuple[str, Optional[List[int]]]:
258
- if len(components := (property_name := property_name.strip()).split(Schema._ARRAY_NAME_SUFFIX_CHAR)) < 2:
259
- return property_name, None
260
- unarrayized_property_name = components[0].strip()
261
- array_specifiers = []
262
- for component in components[1:]:
263
- if component.isdigit():
264
- array_specifiers.append(int(component))
265
- elif component == "":
266
- array_specifiers.append(0)
267
- else:
268
- return property_name, None
269
- return unarrayized_property_name, array_specifiers
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dcicutils"
3
- version = "8.7.0.1b36" # TODO: To become 8.7.1
3
+ version = "8.7.0.1b37" # TODO: To become 8.7.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"