Skip to main content

prefect_aws.utilities

Utilities for working with AWS services.

Functions

hash_collection

hash_collection(collection) -> int
Use visit_collection to transform and hash a collection. Args:
  • collection: The collection to hash.
Returns:
  • The hash of the transformed collection.

ensure_path_exists

ensure_path_exists(doc: Union[Dict, List], path: List[str])
Ensures the path exists in the document, creating empty dictionaries or lists as needed. Args:
  • doc: The current level of the document or sub-document.
  • path: The remaining path parts to ensure exist.

assemble_document_for_patches

assemble_document_for_patches(patches)
Assembles an initial document that can successfully accept the given JSON Patch operations. Args:
  • patches: A list of JSON Patch operations.
Returns:
  • An initial document structured to accept the patches.
Example:
patches = [
    {"op": "replace", "path": "/name", "value": "Jane"},
    {"op": "add", "path": "/contact/address", "value": "123 Main St"},
    {"op": "remove", "path": "/age"}
]

initial_document = assemble_document_for_patches(patches)

#output
{
    "name": {},
    "contact": {},
    "age": {}
}