dcicutils 8.8.6__tar.gz → 8.8.6.1b1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/PKG-INFO +1 -1
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/portal_utils.py +50 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/structured_data.py +9 -3
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/pyproject.toml +1 -1
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/LICENSE.txt +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/README.rst +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/__init__.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/base.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/beanstalk_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/bundle_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/captured_output.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/cloudformation_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/codebuild_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/command_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/common.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/contribution_scripts.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/contribution_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/creds_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/data_readers.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/data_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/datetime_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/deployment_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/diff_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/docker_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/ecr_scripts.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/ecr_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/ecs_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/env_base.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/env_manager.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/env_scripts.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/env_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/env_utils_legacy.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/es_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/exceptions.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/ff_mocks.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/ff_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/file_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/function_cache_decorator.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/glacier_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/http_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/jh_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/kibana/dashboards.json +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/kibana/readme.md +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/lang_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/license_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/log_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/misc_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/obfuscation_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/opensearch_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/portal_object_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/progress_bar.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/project_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/qa_checkers.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/qa_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/redis_tools.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/redis_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/s3_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/schema_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/scripts/publish_to_pypi.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/scripts/run_license_checker.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/scripts/view_portal_object.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/secrets_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/sheet_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/snapshot_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/ssl_certificate_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/submitr/progress_constants.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/task_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/tmpfile_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/trace_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/validation_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/variant_utils.py +0 -0
- {dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/zip_utils.py +0 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
from collections import deque
|
2
2
|
from functools import lru_cache
|
3
|
+
from dcicutils.function_cache_decorator import function_cache
|
3
4
|
import io
|
4
5
|
import json
|
5
6
|
from pyramid.config import Configurator as PyramidConfigurator
|
@@ -18,6 +19,7 @@ from wsgiref.simple_server import make_server as wsgi_make_server
|
|
18
19
|
from dcicutils.common import APP_SMAHT, OrchestratedApp, ORCHESTRATED_APPS
|
19
20
|
from dcicutils.ff_utils import get_metadata, get_schema, patch_metadata, post_metadata
|
20
21
|
from dcicutils.misc_utils import to_camel_case, VirtualApp
|
22
|
+
from dcicutils.schema_utils import get_identifying_properties
|
21
23
|
from dcicutils.tmpfile_utils import temporary_file
|
22
24
|
|
23
25
|
Portal = Type["Portal"] # Forward type reference for type hints.
|
@@ -441,6 +443,54 @@ class Portal:
|
|
441
443
|
result_kwargs["timeout"] = timeout
|
442
444
|
return result_kwargs
|
443
445
|
|
446
|
+
@function_cache(maxsize=100, serialize_key=True)
|
447
|
+
def get_identifying_paths(self, portal_object: dict, portal_type: Optional[str] = None) -> List[str]:
|
448
|
+
"""
|
449
|
+
Returns the list of the identifying Portal (URL) paths for the given Portal object. Favors any
|
450
|
+
uuid based path and defavors aliases based paths (ala self.get_identifying_property_names);
|
451
|
+
no other ordering defined. Returns empty list of none or otherwise not found.
|
452
|
+
"""
|
453
|
+
results = []
|
454
|
+
if not isinstance(portal_object, dict):
|
455
|
+
return results
|
456
|
+
if not isinstance(portal_type, str) or not portal_type:
|
457
|
+
if not (portal_type := self.get_schema_type(portal_object)):
|
458
|
+
return results
|
459
|
+
for identifying_property in self.get_identifying_property_names(portal_type):
|
460
|
+
if identifying_value := portal_object.get(identifying_property):
|
461
|
+
if isinstance(identifying_value, list):
|
462
|
+
for identifying_value_item in identifying_value:
|
463
|
+
results.append(f"/{portal_type}/{identifying_value_item}")
|
464
|
+
elif identifying_property == "uuid":
|
465
|
+
results.append(f"/{identifying_value}")
|
466
|
+
else:
|
467
|
+
results.append(f"/{portal_type}/{identifying_value}")
|
468
|
+
return results
|
469
|
+
|
470
|
+
@function_cache(maxsize=100, serialize_key=True)
|
471
|
+
def get_identifying_property_names(self, schema: Union[str, dict]) -> List[str]:
|
472
|
+
"""
|
473
|
+
Returns the list of identifying property names for the given Portal schema, which may
|
474
|
+
be either a schema name or a schema object; empty list of none or otherwise not found.
|
475
|
+
"""
|
476
|
+
results = []
|
477
|
+
if isinstance(schema, str):
|
478
|
+
try:
|
479
|
+
if not (schema := self.get_schema(schema)):
|
480
|
+
return results
|
481
|
+
except Exception:
|
482
|
+
return results
|
483
|
+
elif not isinstance(schema, dict):
|
484
|
+
return results
|
485
|
+
if not (identifying_properties := get_identifying_properties(schema)):
|
486
|
+
return results
|
487
|
+
identifying_properties = [*identifying_properties]
|
488
|
+
for favored_identifying_property in reversed(["uuid", "identifier"]):
|
489
|
+
if favored_identifying_property in identifying_properties:
|
490
|
+
identifying_properties.remove(favored_identifying_property)
|
491
|
+
identifying_properties.insert(0, favored_identifying_property)
|
492
|
+
return identifying_properties
|
493
|
+
|
444
494
|
@staticmethod
|
445
495
|
def _default_keys_file(app: Optional[str], env: Optional[str], server: Optional[str]) -> Optional[str]:
|
446
496
|
def infer_app_from_env(env: str) -> Optional[str]: # noqa
|
@@ -56,7 +56,7 @@ class StructuredDataSet:
|
|
56
56
|
remove_empty_objects_from_lists: bool = True,
|
57
57
|
ref_lookup_strategy: Optional[Callable] = None,
|
58
58
|
ref_lookup_nocache: bool = False,
|
59
|
-
norefs: bool = False,
|
59
|
+
norefs: bool = False, merge: bool = False,
|
60
60
|
progress: Optional[Callable] = None,
|
61
61
|
debug_sleep: Optional[str] = None) -> None:
|
62
62
|
self._progress = progress if callable(progress) else None
|
@@ -75,6 +75,7 @@ class StructuredDataSet:
|
|
75
75
|
self._nrows = 0
|
76
76
|
self._autoadd_properties = autoadd if isinstance(autoadd, dict) and autoadd else None
|
77
77
|
self._norefs = True if norefs is True else False
|
78
|
+
self._merge = True if merge is True else False
|
78
79
|
self._debug_sleep = None
|
79
80
|
if debug_sleep:
|
80
81
|
try:
|
@@ -98,13 +99,13 @@ class StructuredDataSet:
|
|
98
99
|
remove_empty_objects_from_lists: bool = True,
|
99
100
|
ref_lookup_strategy: Optional[Callable] = None,
|
100
101
|
ref_lookup_nocache: bool = False,
|
101
|
-
norefs: bool = False,
|
102
|
+
norefs: bool = False, merge: bool = False,
|
102
103
|
progress: Optional[Callable] = None,
|
103
104
|
debug_sleep: Optional[str] = None) -> StructuredDataSet:
|
104
105
|
return StructuredDataSet(file=file, portal=portal, schemas=schemas, autoadd=autoadd, order=order, prune=prune,
|
105
106
|
remove_empty_objects_from_lists=remove_empty_objects_from_lists,
|
106
107
|
ref_lookup_strategy=ref_lookup_strategy, ref_lookup_nocache=ref_lookup_nocache,
|
107
|
-
norefs=norefs, progress=progress, debug_sleep=debug_sleep)
|
108
|
+
norefs=norefs, merge=merge, progress=progress, debug_sleep=debug_sleep)
|
108
109
|
|
109
110
|
def validate(self, force: bool = False) -> None:
|
110
111
|
def data_without_deleted_properties(data: dict) -> dict:
|
@@ -383,6 +384,11 @@ class StructuredDataSet:
|
|
383
384
|
structured_row_template.set_value(structured_row, column_name, value, reader.file, reader.row_number)
|
384
385
|
if self._autoadd_properties:
|
385
386
|
self._add_properties(structured_row, self._autoadd_properties, schema)
|
387
|
+
# New merge functionality (2024-05-25).
|
388
|
+
if self._merge:
|
389
|
+
for identifying_path in self.get_identifying_paths(self._portal, structured_row, type_name):
|
390
|
+
if existing_portal_object := self._portal.get_metadata(identifying_path):
|
391
|
+
structured_row = merge_objects(existing_portal_object, structured_row)
|
386
392
|
if (prune_error := self._prune_structured_row(structured_row)) is not None:
|
387
393
|
self._note_error({"src": create_dict(type=schema_name, row=reader.row_number),
|
388
394
|
"error": prune_error}, "validation")
|
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
|
File without changes
|
{dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/license_policies/c4-python-infrastructure.jsonc
RENAMED
File without changes
|
{dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/license_policies/park-lab-common-server.jsonc
RENAMED
File without changes
|
File without changes
|
{dcicutils-8.8.6 → dcicutils-8.8.6.1b1}/dcicutils/license_policies/park-lab-gpl-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
|
File without changes
|