prefect_aws.utilities
Utilities for working with AWS services.
assemble_document_for_patches(patches)
Assembles an initial document that can successfully accept the given JSON Patch operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
patches
|
A list of JSON Patch operations. |
required |
Returns:
Type | Description |
---|---|
An initial document structured to accept the patches. |
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": {}
}
Source code in prefect_aws/utilities.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
ensure_path_exists(doc, path)
Ensures the path exists in the document, creating empty dictionaries or lists as needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc
|
Union[Dict, List]
|
The current level of the document or sub-document. |
required |
path
|
List[str]
|
The remaining path parts to ensure exist. |
required |
Source code in prefect_aws/utilities.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
hash_collection(collection)
Use visit_collection to transform and hash a collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection
|
Any
|
The collection to hash. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The hash of the transformed collection. |
Example
from prefect_aws.utilities import hash_collection
hash_collection({"a": 1, "b": 2})
Source code in prefect_aws/utilities.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|