Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vulnerability functions. #326

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ include = ["physrisk*"]

[tool.pdm.dev-dependencies]
test = [
"pdm[pytest]",
"pytest",
"pytest-cov",
"sphinx-pyproject"
"pdm[pytest]",
"pytest",
"pytest-cov",
"sphinx-pyproject",
"pandas>=2.0.3",
"dependency-injector>=4.41.0",
"geopandas<1.0,>=0.13.2",
]
dev = [
"mypy",
Expand Down
1 change: 1 addition & 0 deletions src/physrisk/api/v1/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from enum import Enum
from typing import Dict, List, Optional, Union

import numpy as np
Expand Down
8 changes: 6 additions & 2 deletions src/physrisk/api/v1/impact_req_resp.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class AssetImpactRequest(BaseModel):
True, description="If true, include impact calculation details."
)
use_case_id: str = Field(
"",
description="Identifier for 'use case' used in the risk measures calculation.",
"DEFAULT",
description=(
"Identifier for 'use case' used in vulnerability models and risk measures calculations."
),
)
provider_max_requests: Dict[str, int] = Field(
{},
Expand Down Expand Up @@ -70,6 +72,8 @@ class Category(int, Enum):
HIGH = 3
REDFLAG = 4

NORISK = -1


class RiskMeasureDefinition(BaseModel):
measure_id: str = Field(None, description="Identifier for the risk measure.")
Expand Down
13 changes: 2 additions & 11 deletions src/physrisk/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

from dependency_injector import containers, providers

from physrisk.kernel import calculation as calc
from physrisk.data.hazard_data_provider import SourcePath
from physrisk.data.inventory import EmbeddedInventory
from physrisk.data.inventory_reader import InventoryReader
from physrisk.data.pregenerated_hazard_model import ZarrHazardModel
from physrisk.data.zarr_reader import ZarrReader
from physrisk.kernel import calculation as calc
from physrisk.kernel.hazard_model import HazardModelFactory
from physrisk.kernel.vulnerability_model import (
DictBasedVulnerabilityModels,
VulnerabilityModels,
VulnerabilityModelsFactory,
)
from physrisk.kernel.vulnerability_model import DictBasedVulnerabilityModelsFactory
from physrisk.requests import Requester, _create_inventory, create_source_paths


Expand Down Expand Up @@ -41,11 +37,6 @@ def hazard_model(
)


class DictBasedVulnerabilityModelsFactory(VulnerabilityModelsFactory):
def vulnerability_models(self) -> VulnerabilityModels:
return DictBasedVulnerabilityModels(calc.get_default_vulnerability_models())


class Container(containers.DeclarativeContainer):
config = providers.Configuration(default={"zarr_sources": ["embedded", "hazard"]})

Expand Down
3 changes: 1 addition & 2 deletions src/physrisk/data/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

import physrisk.data.colormap_provider as colormap_provider
import physrisk.data.static.hazard
from physrisk.api.v1.hazard_data import HazardResource, Period
from physrisk.data.inventory_reader import HazardModels

from ..api.v1.hazard_data import HazardResource, Period

# from physrisk.kernel.hazards import ChronicHeat


Expand Down
Loading