Hazard Metadata Models¶
These models manage metadata about hazard calculations and producers, stored as JSON files.
Compatible Hazard Calculation¶
Provides a unique identifier for compatible hazard calculations (calculations that produce comparable results).
Bases: BaseModel
Provides a unique identifier for compatible Hazard Calculations.
Attributes:
| Name | Type | Description |
|---|---|---|
unique_id |
str
|
A unique identifier for the Hazard Calculation. |
notes |
optional
|
Additional information about the Hazard Calculation. |
created_at |
datetime
|
The date and time this record was created. Defaults to utcnow. |
updated_at |
datetime
|
The date and time this record was last updated. Defaults to utcnow. |
Source code in toshi_hazard_store/model/hazard_models_pydantic.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
Hazard Curve Producer Config¶
Records characteristics of hazard curve producers/engines for compatibility and reproducibility.
Bases: BaseModel
Records characteristics of Hazard Curve producers/engines for compatibility and reproducibility.
For hazard curve compatibility, we use both:
- compatible_calc_fk: curves sharing this fk are compatible because the software/science is compatible.
- config_digest: the config digest tells us the PSHA software configuration is compatible
(see nzshm-model for details).
For hazard curve reproducibility, use both: - ecr_image_digest: a hexdigest from the ecr_image (this is stored in the dataset). - ecr_image: we can run the same inputs against this Docker image to reproduce the outputs.
Attributes:
| Name | Type | Description |
|---|---|---|
compatible_calc_fk |
str
|
Foreign key to a CompatibleHazardCalculation (must map to a valid unique_id). |
ecr_image_digest |
str
|
Docker image digest (sha256:...). |
config_digest |
str
|
Configuration digest. |
created_at |
datetime
|
The date and time this record was created. Defaults to utcnow. |
updated_at |
datetime
|
The date and time this record was last updated. Defaults to utcnow. |
ecr_image |
AwsEcrImage | None
|
Optional AwsEcrImage for reproducibility. |
notes |
str | None
|
Optional additional information. |
POSSIBLE in future
- if necessary we can extend this with a GithubRef / DockerImage alternative to AwsEcrImage.
Source code in toshi_hazard_store/model/hazard_models_pydantic.py
32 33 34 35 36 37 38 39 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 71 | |
Usage¶
These metadata models are used together to identify compatible hazard curves:
- CompatibleHazardCalculation - Created when setting up a new hazard calculation
- HazardCurveProducerConfig - Created when running a calculation, linked to a CompatibleHazardCalculation
Two hazard curves are considered "compatible" if they share the same compatible_calc_id and config_digest.
The managers handle CRUD operations via JSON files in the resources/metadata/ directory.