Skip to content

Commit 0ea5f55

Browse files
committed
MSFTv4 model runs
1 parent 005f166 commit 0ea5f55

26 files changed

+783
-331
lines changed

poetry.lock

Lines changed: 290 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ scikit-learn = "^1.6.0"
4444
pyarrow = "^18.1.0"
4545
torch = "^2.5.1"
4646
lightning = "^2.5.0.post0"
47+
scikit-image = "^0.25.1"
48+
pypdf2 = "^3.0.1"
49+
contextily = "^1.6.2"
4750

4851
[tool.poetry.group.dev.dependencies]
4952
mkdocstrings = {version = "*", extras = ["python"]}
@@ -60,6 +63,9 @@ pytest-github-actions-annotate-failures = "*"
6063
pytest-cov = "*"
6164
python-kacl = "*"
6265
ruff = "*"
66+
pandas-stubs = "^2.2.3.241126"
67+
types-tqdm = "^4.67.0.20241221"
68+
types-pyyaml = "^6.0.12.20241230"
6369

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

148154
# If you need to ignore something for some specific module,
149155
# add overrides for them. Avoid changing the global config!
150156
# For example:
151-
# [[tool.mypy.overrides]]
152-
# module = [
153-
# "my_unpyted_dependency1.*",
154-
# "my_unpyted_dependency2.*"
155-
# ]
156-
# ignore_missing_imports = true
157+
[[tool.mypy.overrides]]
158+
module = [
159+
"geopandas.*",
160+
"shapely.*",
161+
"seaborn.*",
162+
"mpl_toolkits.*",
163+
"rasterio.*",
164+
"affine.*",
165+
"scipy.*",
166+
"sklearn.*",
167+
"contextily.*",
168+
]
169+
ignore_missing_imports = true
157170

158171
# [[tool.mypy.overrides]]
159172
# module = [

src/rra_population_model/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ def task_runner() -> None:
4242
for name, runner in task_runners.items():
4343
task_runner.add_command(runner, name)
4444

45-
pmtask.add_command(task_runner)
45+
pmtask.add_command(task_runner)

src/rra_population_model/cli_options.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
with_queue,
1919
with_verbose,
2020
)
21-
from rra_population_model import constants as pmc
2221

22+
from rra_population_model import constants as pmc
2323

2424
_T = TypeVar("_T")
2525
_P = ParamSpec("_P")
@@ -67,6 +67,7 @@ def with_year(
6767
help="Year to run.",
6868
)
6969

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

95+
9496
def with_tile_key() -> ClickOption[_P, _T]:
9597
return click.option(
9698
"--tile-key",
@@ -100,6 +102,7 @@ def with_tile_key() -> ClickOption[_P, _T]:
100102
help="Tile key of tile to run.",
101103
)
102104

105+
103106
def with_model_name() -> ClickOption[_P, _T]:
104107
return click.option(
105108
"--model-name",
@@ -115,20 +118,20 @@ def with_model_name() -> ClickOption[_P, _T]:
115118
"ClickOption",
116119
"convert_choice",
117120
"process_choices",
121+
"with_block_key",
118122
"with_choice",
119123
"with_debugger",
120124
"with_dry_run",
121125
"with_input_directory",
126+
"with_iso3",
122127
"with_num_cores",
123128
"with_output_directory",
124129
"with_overwrite",
125130
"with_progress_bar",
126131
"with_queue",
127-
"with_verbose",
128132
"with_resolution",
129-
"with_time_point",
130-
"with_block_key",
131133
"with_tile_key",
134+
"with_time_point",
135+
"with_verbose",
132136
"with_year",
133-
"with_iso3",
134-
]
137+
]

src/rra_population_model/constants.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import itertools
2+
import warnings
23
from pathlib import Path
3-
import pyproj
44

5+
import pyproj
56
from pydantic import BaseModel, model_validator
6-
import warnings
77

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

1818
FEATURE_AVERAGE_RADII = [
19-
100, 500, 1000, 2500, 5000, 10000,
19+
100,
20+
500,
21+
1000,
22+
2500,
23+
5000,
24+
10000,
2025
]
2126

2227
GHSL_TIME_POINTS = [f"{y}q1" for y in range(1975, 2024)]
2328
MICROSOFT_TIME_POINTS = {
24-
"microsoft_v2": [f"{y}q{q}" for q, y in itertools.product(range(1, 5), range(2018, 2024))][
25-
:-1
26-
],
29+
"microsoft_v2": [
30+
f"{y}q{q}" for q, y in itertools.product(range(1, 5), range(2018, 2024))
31+
][:-1],
2732
"microsoft_v3": ["2023q3"],
2833
"microsoft_v4": ["2023q4"],
2934
}
@@ -59,7 +64,7 @@ def validate_code_and_proj_string(self) -> "CRS":
5964
msg = "code and proj_string must represent the same CRS."
6065
raise ValueError(msg)
6166
return self
62-
67+
6368
def to_string(self) -> str:
6469
if self.code:
6570
return self.code
@@ -69,8 +74,8 @@ def to_pyproj(self) -> pyproj.CRS:
6974
if self.code:
7075
return pyproj.CRS.from_user_input(self.code)
7176
return pyproj.CRS.from_user_input(self.proj_string)
72-
73-
def __hash__(self):
77+
78+
def __hash__(self) -> int:
7479
return hash(self.name)
7580

7681

0 commit comments

Comments
 (0)