branch_registry
branch_registry
¶
A registry for logic_tree_branches (sources and GMMs) that are uniquely identified by a shake_256 hash.
Data is stored in the resources folder in CSV form. New branched may be added by developers to support new source or logic tree components.
Examples:
>>> from nzshm_model import branch_registry
>>> registry = branch_registry.Registry()
>>> entry = registry.source_registry.get_by_hash("af9ec2b004d7")
... BranchRegistryEntry(... )
Functions:
Name | Description |
---|---|
identity_digest |
get a standard hash_digest from an identity string |
BranchRegistry
¶
Storage Manager for BranchRegistryEntry objects
Source code in nzshm_model/branch_registry.py
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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
add(entry)
¶
add a new registry entry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry
|
BranchRegistryEntry
|
a BranchRegistryEntry object. |
required |
Source code in nzshm_model/branch_registry.py
133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
get_by_extra(extra)
¶
Get a registry entry by the extra string.
Notes
- this may return None.
- only used a workaroound becuase some post NSHM hazard jobs used the extra value
instead of the identity string in the HDF% ( e.g.
T3BlbnF1YWtlSGF6YXJkVGFzazo2OTMxODkz
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra
|
str
|
the extra string. |
required |
Source code in nzshm_model/branch_registry.py
163 164 165 166 167 168 169 170 171 172 173 174 |
|
get_by_hash(hash_digest)
¶
Get a registry entry by hash_digest.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hash_digest
|
str
|
the hash digest string. |
required |
Source code in nzshm_model/branch_registry.py
147 148 149 150 151 152 153 |
|
get_by_identity(identity)
¶
Get a registry entry by identity string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identity
|
str
|
the identity string. |
required |
Source code in nzshm_model/branch_registry.py
155 156 157 158 159 160 161 |
|
load(registry_file)
¶
Load the entries contained in a CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
registry_file
|
IO[Any]
|
file-like object with expected CSV header file |
required |
Returns:
Type | Description |
---|---|
BranchRegistry
|
the populated BranchRegistry |
Source code in nzshm_model/branch_registry.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
save(registry_file)
¶
Save the registry entries in CSV format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
registry_file
|
IO[Any]
|
file-like object to write |
required |
Source code in nzshm_model/branch_registry.py
122 123 124 125 126 127 128 129 130 131 |
|
BranchRegistryEntry
dataclass
¶
A standard registry entry
Attributes:
Name | Type | Description |
---|---|---|
identity |
str
|
the unique identity string (see Branch.registry_identity) |
hash_digest |
Optional[str]
|
the shake_256 hexdigest of the identity. |
extra |
Optional[str]
|
more information about the entry. |
Source code in nzshm_model/branch_registry.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
Registry
¶
A container for the published registries.
Attributes:
Name | Type | Description |
---|---|---|
gmm_registry |
BranchRegistry
|
the model sources registry. |
source_registry |
BranchRegistry
|
the model gmms registry. |
Source code in nzshm_model/branch_registry.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
identity_digest(identity)
¶
get a standard hash_digest from an identity string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identity
|
str
|
a unique identity string |
required |
Returns:
Type | Description |
---|---|
str
|
a shake_256 hash digest |
Source code in nzshm_model/branch_registry.py
29 30 31 32 33 34 35 36 37 38 |
|