Skip to content

Commit

Permalink
MSFTv4 model runs
Browse files Browse the repository at this point in the history
  • Loading branch information
collijk committed Feb 1, 2025
1 parent 005f166 commit 0ea5f55
Show file tree
Hide file tree
Showing 26 changed files with 783 additions and 331 deletions.
291 changes: 290 additions & 1 deletion poetry.lock

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ scikit-learn = "^1.6.0"
pyarrow = "^18.1.0"
torch = "^2.5.1"
lightning = "^2.5.0.post0"
scikit-image = "^0.25.1"
pypdf2 = "^3.0.1"
contextily = "^1.6.2"

[tool.poetry.group.dev.dependencies]
mkdocstrings = {version = "*", extras = ["python"]}
Expand All @@ -60,6 +63,9 @@ pytest-github-actions-annotate-failures = "*"
pytest-cov = "*"
python-kacl = "*"
ruff = "*"
pandas-stubs = "^2.2.3.241126"
types-tqdm = "^4.67.0.20241221"
types-pyyaml = "^6.0.12.20241230"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down Expand Up @@ -143,17 +149,24 @@ exclude_lines = [
# This is the global mypy configuration.
# Avoid changing this!
strict = true # See all the enabled flags `mypy --help | grep -A 10 'Strict mode'`
disallow_any_unimported = true
disallow_any_unimported = false

# If you need to ignore something for some specific module,
# add overrides for them. Avoid changing the global config!
# For example:
# [[tool.mypy.overrides]]
# module = [
# "my_unpyted_dependency1.*",
# "my_unpyted_dependency2.*"
# ]
# ignore_missing_imports = true
[[tool.mypy.overrides]]
module = [
"geopandas.*",
"shapely.*",
"seaborn.*",
"mpl_toolkits.*",
"rasterio.*",
"affine.*",
"scipy.*",
"sklearn.*",
"contextily.*",
]
ignore_missing_imports = true

# [[tool.mypy.overrides]]
# module = [
Expand Down
2 changes: 1 addition & 1 deletion src/rra_population_model/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def task_runner() -> None:
for name, runner in task_runners.items():
task_runner.add_command(runner, name)

pmtask.add_command(task_runner)
pmtask.add_command(task_runner)
15 changes: 9 additions & 6 deletions src/rra_population_model/cli_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
with_queue,
with_verbose,
)
from rra_population_model import constants as pmc

from rra_population_model import constants as pmc

_T = TypeVar("_T")
_P = ParamSpec("_P")
Expand Down Expand Up @@ -67,6 +67,7 @@ def with_year(
help="Year to run.",
)


def with_time_point(
choices: Collection[str] = pmc.ALL_TIME_POINTS,
*,
Expand All @@ -91,6 +92,7 @@ def with_block_key() -> ClickOption[_P, _T]:
help="Block key of block to run.",
)


def with_tile_key() -> ClickOption[_P, _T]:
return click.option(
"--tile-key",
Expand All @@ -100,6 +102,7 @@ def with_tile_key() -> ClickOption[_P, _T]:
help="Tile key of tile to run.",
)


def with_model_name() -> ClickOption[_P, _T]:
return click.option(
"--model-name",
Expand All @@ -115,20 +118,20 @@ def with_model_name() -> ClickOption[_P, _T]:
"ClickOption",
"convert_choice",
"process_choices",
"with_block_key",
"with_choice",
"with_debugger",
"with_dry_run",
"with_input_directory",
"with_iso3",
"with_num_cores",
"with_output_directory",
"with_overwrite",
"with_progress_bar",
"with_queue",
"with_verbose",
"with_resolution",
"with_time_point",
"with_block_key",
"with_tile_key",
"with_time_point",
"with_verbose",
"with_year",
"with_iso3",
]
]
23 changes: 14 additions & 9 deletions src/rra_population_model/constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import itertools
import warnings
from pathlib import Path
import pyproj

import pyproj
from pydantic import BaseModel, model_validator
import warnings

RRA_ROOT = Path("/mnt/team/rapidresponse/")
RRA_CREDENTIALS_ROOT = RRA_ROOT / "priv" / "shared" / "credentials"
Expand All @@ -16,14 +16,19 @@
RESOLUTIONS = ["40", "100", "250", "500", "1000"]

FEATURE_AVERAGE_RADII = [
100, 500, 1000, 2500, 5000, 10000,
100,
500,
1000,
2500,
5000,
10000,
]

GHSL_TIME_POINTS = [f"{y}q1" for y in range(1975, 2024)]
MICROSOFT_TIME_POINTS = {
"microsoft_v2": [f"{y}q{q}" for q, y in itertools.product(range(1, 5), range(2018, 2024))][
:-1
],
"microsoft_v2": [
f"{y}q{q}" for q, y in itertools.product(range(1, 5), range(2018, 2024))
][:-1],
"microsoft_v3": ["2023q3"],
"microsoft_v4": ["2023q4"],
}
Expand Down Expand Up @@ -59,7 +64,7 @@ def validate_code_and_proj_string(self) -> "CRS":
msg = "code and proj_string must represent the same CRS."
raise ValueError(msg)
return self

def to_string(self) -> str:
if self.code:
return self.code
Expand All @@ -69,8 +74,8 @@ def to_pyproj(self) -> pyproj.CRS:
if self.code:
return pyproj.CRS.from_user_input(self.code)
return pyproj.CRS.from_user_input(self.proj_string)
def __hash__(self):

def __hash__(self) -> int:
return hash(self.name)


Expand Down
Loading

0 comments on commit 0ea5f55

Please sign in to comment.