-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathvalidation_grid_utils.py
More file actions
executable file
·58 lines (44 loc) · 1.47 KB
/
validation_grid_utils.py
File metadata and controls
executable file
·58 lines (44 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
#! /usr/bin/env -S uv run -q --script
# ICON4Py - ICON inspired code in Python and GT4Py
#
# Copyright (c) 2022-2024, ETH Zurich and MeteoSwiss
# All rights reserved.
#
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "typer>=0.10",
# "icon4py-testing",
# ]
# [tool.uv.sources]
# icon4py-testing = {path = "../model/testing"}
# ///
import hashlib
import sys
import typer
from icon4py.model.testing import definitions as test_defs, grid_utils
VALIDATION_GRIDS = (
test_defs.Grids.R01B01_GLOBAL,
test_defs.Grids.R02B04_GLOBAL,
test_defs.Grids.MCH_CH_R04B09_DSL,
test_defs.Grids.MCH_OPR_R04B07_DOMAIN01,
test_defs.Grids.TORUS_50000x5000,
) # change to MCH_OPR_R04B07_DOMAIN01
app = typer.Typer()
@app.command(name="cache-key")
def cache_key() -> None:
"""Generate a cache key for the Github action cache based on grid file name and download URI."""
d = "_".join(grid.name + grid.uri for grid in VALIDATION_GRIDS)
hexdigest = hashlib.md5(d.encode()).hexdigest()
print(hexdigest)
@app.command(name="download")
def download_validation_grids() -> None:
"""Effectively download the validation grid files."""
for grid in VALIDATION_GRIDS:
print(f"downloading and unpacking {grid.name}")
fname = grid_utils._download_grid_file(grid)
print(f"done - downloaded {fname}")
if __name__ == "__main__":
sys.exit(app())