Skip to content

Commit f600692

Browse files
committed
Merge main into ensembles. There is still a known bug for ensemble runs, related to the ens_comm_group: Inference is running, but does not give outputs
Signed-off-by: evenmn <evenmn@fys.uio.no>
2 parents 21dff75 + 9803bcf commit f600692

33 files changed

Lines changed: 1784 additions & 1031 deletions

.github/workflows/python-package.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ jobs:
5252
run: |
5353
tox -e ruff_checkformat
5454
55-
- name: Run tox unit tests
56-
run: |
57-
tox -e py310
58-
59-
- name: Run tox security check
60-
run: |
61-
tox -e bandit
62-
6355
- name: Run ruff check
6456
run: |
6557
tox -e ruff_check
@@ -68,6 +60,14 @@ jobs:
6860
run: |
6961
tox -e trainingdata
7062
63+
- name: Run tox unit tests
64+
run: |
65+
tox -e py310
66+
67+
- name: Run tox security check
68+
run: |
69+
tox -e bandit
70+
7171
- name: Run inference
7272
run: |
7373
tox -e inference_CI

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ See [Dockerfile](https://gitlab.met.no/yrop/bris-cicd/-/blob/main/Dockerfile?ref
3636

3737
## How to run tests
3838

39-
pip install ".[tests]"
39+
pip install -e '.[dev]'
4040
tox
4141

4242
When pushing to github, default tests will be run automatically and must succeed.

bris/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.3"
1+
__version__ = "0.2.0"
22

33

44
def main():

bris/__main__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .utils import (
1515
create_config,
1616
get_all_leadtimes,
17+
parse_args,
1718
set_base_seed,
1819
set_encoder_decoder_num_chunks,
1920
)
@@ -22,12 +23,9 @@
2223
LOGGER = logging.getLogger(__name__)
2324

2425

25-
def main():
26-
parser = ArgumentParser()
27-
parser.add_argument("--debug", action="store_true")
28-
parser.add_argument("--config", type=str, required=True)
29-
30-
config = create_config(parser)
26+
def main(arg_list: list[str] | None = None):
27+
args = parse_args(arg_list)
28+
config = create_config(args["config"], args)
3129

3230
models = list(config.checkpoints.keys())
3331
checkpoints = {
@@ -38,6 +36,9 @@ def main():
3836
for model in models
3937
}
4038
set_encoder_decoder_num_chunks(getattr(config, "inference_num_chunks", 1))
39+
if "release_cache" not in config or not isinstance(config["release_cache"], bool):
40+
config["release_cache"] = False
41+
4142
set_base_seed()
4243

4344
# Get timestep from checkpoint. Also store a version in seconds for local use.
@@ -168,7 +169,7 @@ def main():
168169
for output in decoder_output["outputs"]:
169170
output.finalize()
170171

171-
print("Hello world")
172+
print("Model run completed. 🤖")
172173

173174

174175
if __name__ == "__main__":

bris/checkpoint.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ def graph(self) -> HeteroData:
153153
154154
return:
155155
HeteroData graph object
156-
157156
"""
158157
return (
159158
self._model_instance.graph_data

bris/conventions/cf.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def get_metadata(anemoi_variable: str) -> dict:
100100
# raise ValueError(f"Unknown leveltype: {leveltype}")
101101

102102

103-
def get_attributes(cfname):
103+
def get_attributes(cfname: str) -> dict[str, str]:
104104
ret = {"standard_name": cfname}
105105

106106
# Coordinate variables
@@ -127,6 +127,9 @@ def get_attributes(cfname):
127127
ret["description"] = "height above ground"
128128
ret["long_name"] = "height"
129129
ret["positive"] = "up"
130+
elif cfname in ["thunder_event"]:
131+
ret["standard_name"] = "thunderstorm_probability"
132+
ret["units"] = "1"
130133

131134
# Data variables
132135
elif cfname in [
@@ -139,7 +142,7 @@ def get_attributes(cfname):
139142
ret["units"] = "m/s"
140143
elif cfname in ["air_temperature", "dew_point_temperature"]:
141144
ret["units"] = "K"
142-
elif cfname == "land_sea_mask":
145+
elif cfname in ["land_sea_mask", "area_fraction"]:
143146
ret["units"] = "1"
144147
elif cfname in ["geopotential", "surface_geopotential"]:
145148
ret["units"] = "m^2/s^2"
@@ -151,8 +154,6 @@ def get_attributes(cfname):
151154
ret["units"] = "kg/kg"
152155
elif cfname in ["cloud_base_altitude", "visibility_in_air"]:
153156
ret["units"] = "m"
154-
elif "area_fraction" in cfname:
155-
ret["units"] = "1"
156157
elif cfname in [
157158
"integral_of_surface_downwelling_longwave_flux_in_air_wrt_time",
158159
"integral_of_surface_downwelling_shortwave_flux_in_air_wrt_time",

bris/data/dataset/__init__.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import logging
2+
3+
from torch.utils.data import get_worker_info
4+
5+
# Make NativeGridDataset and ZipDataset importable from bris.data.dataset:
6+
from .nativegrid import NativeGridDataset # noqa
7+
from .zip import ZipDataset # noqa
8+
9+
LOGGER = logging.getLogger(__name__)
10+
11+
12+
def worker_init_func(worker_id: int) -> None:
13+
"""Configures each dataset worker process. This is a helper function, called by Dataloader.
14+
15+
Calls WeatherBenchDataset.per_worker_init() on each dataset object.
16+
17+
Parameters
18+
----------
19+
worker_id : int
20+
Worker ID
21+
22+
Raises
23+
------
24+
RuntimeError
25+
If worker_info is None
26+
"""
27+
worker_info = get_worker_info() # information specific to each worker process
28+
if worker_info is None:
29+
LOGGER.error("worker_info is None! Set num_workers > 0 in your dataloader!")
30+
raise RuntimeError
31+
dataset_obj = (
32+
worker_info.dataset
33+
) # the copy of the dataset held by this worker process.
34+
dataset_obj.per_worker_init(
35+
n_workers=worker_info.num_workers,
36+
worker_id=worker_id,
37+
)

0 commit comments

Comments
 (0)