anemoi-utils 0.4.9__py3-none-any.whl → 0.4.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of anemoi-utils might be problematic. Click here for more details.
- anemoi/utils/_version.py +2 -2
- anemoi/utils/commands/requests.py +44 -0
- anemoi/utils/config.py +30 -4
- anemoi/utils/logs.py +40 -0
- anemoi/utils/mars/requests.py +22 -0
- {anemoi_utils-0.4.9.dist-info → anemoi_utils-0.4.10.dist-info}/METADATA +19 -20
- {anemoi_utils-0.4.9.dist-info → anemoi_utils-0.4.10.dist-info}/RECORD +11 -8
- {anemoi_utils-0.4.9.dist-info → anemoi_utils-0.4.10.dist-info}/WHEEL +1 -1
- {anemoi_utils-0.4.9.dist-info → anemoi_utils-0.4.10.dist-info}/LICENSE +0 -0
- {anemoi_utils-0.4.9.dist-info → anemoi_utils-0.4.10.dist-info}/entry_points.txt +0 -0
- {anemoi_utils-0.4.9.dist-info → anemoi_utils-0.4.10.dist-info}/top_level.txt +0 -0
anemoi/utils/_version.py
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
|
|
2
|
+
# This software is licensed under the terms of the Apache Licence Version 2.0
|
|
3
|
+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
4
|
+
# In applying this licence, ECMWF does not waive the privileges and immunities
|
|
5
|
+
# granted to it by virtue of its status as an intergovernmental organisation
|
|
6
|
+
# nor does it submit to any jurisdiction.
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
|
|
10
|
+
from anemoi.utils.mars.requests import print_request
|
|
11
|
+
|
|
12
|
+
from . import Command
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Requests(Command):
|
|
16
|
+
"""Convert a JSON requests file to MARS format."""
|
|
17
|
+
|
|
18
|
+
def add_arguments(self, command_parser):
|
|
19
|
+
command_parser.add_argument("input")
|
|
20
|
+
command_parser.add_argument("output")
|
|
21
|
+
command_parser.add_argument("--verb", default="retrieve")
|
|
22
|
+
command_parser.add_argument("--only-one-field", action="store_true")
|
|
23
|
+
|
|
24
|
+
def run(self, args):
|
|
25
|
+
with open(args.input) as f:
|
|
26
|
+
requests = json.load(f)
|
|
27
|
+
|
|
28
|
+
if args.only_one_field:
|
|
29
|
+
for r in requests:
|
|
30
|
+
for key in (
|
|
31
|
+
"grid",
|
|
32
|
+
"area",
|
|
33
|
+
):
|
|
34
|
+
r.pop(key, None)
|
|
35
|
+
for k, v in list(r.items()):
|
|
36
|
+
if isinstance(v, list):
|
|
37
|
+
r[k] = v[-1]
|
|
38
|
+
|
|
39
|
+
with open(args.output, "w") as f:
|
|
40
|
+
for r in requests:
|
|
41
|
+
print_request(args.verb, r, file=f)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
command = Requests
|
anemoi/utils/config.py
CHANGED
|
@@ -50,14 +50,14 @@ class DotDict(dict):
|
|
|
50
50
|
super().__init__(*args, **kwargs)
|
|
51
51
|
|
|
52
52
|
for k, v in self.items():
|
|
53
|
-
if isinstance(v, dict):
|
|
53
|
+
if isinstance(v, dict) or is_omegaconf_dict(v):
|
|
54
54
|
self[k] = DotDict(v)
|
|
55
55
|
|
|
56
|
-
if isinstance(v, list):
|
|
57
|
-
self[k] = [DotDict(i) if isinstance(i, dict) else i for i in v]
|
|
56
|
+
if isinstance(v, list) or is_omegaconf_list(v):
|
|
57
|
+
self[k] = [DotDict(i) if isinstance(i, dict) or is_omegaconf_dict(i) else i for i in v]
|
|
58
58
|
|
|
59
59
|
if isinstance(v, tuple):
|
|
60
|
-
self[k] = [DotDict(i) if isinstance(i, dict) else i for i in v]
|
|
60
|
+
self[k] = [DotDict(i) if isinstance(i, dict) or is_omegaconf_dict(i) else i for i in v]
|
|
61
61
|
|
|
62
62
|
@classmethod
|
|
63
63
|
def from_file(cls, path: str):
|
|
@@ -106,6 +106,24 @@ class DotDict(dict):
|
|
|
106
106
|
return f"DotDict({super().__repr__()})"
|
|
107
107
|
|
|
108
108
|
|
|
109
|
+
def is_omegaconf_dict(value) -> bool:
|
|
110
|
+
try:
|
|
111
|
+
from omegaconf import DictConfig
|
|
112
|
+
|
|
113
|
+
return isinstance(value, DictConfig)
|
|
114
|
+
except ImportError:
|
|
115
|
+
return False
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def is_omegaconf_list(value) -> bool:
|
|
119
|
+
try:
|
|
120
|
+
from omegaconf import ListConfig
|
|
121
|
+
|
|
122
|
+
return isinstance(value, ListConfig)
|
|
123
|
+
except ImportError:
|
|
124
|
+
return False
|
|
125
|
+
|
|
126
|
+
|
|
109
127
|
CONFIG = {}
|
|
110
128
|
CHECKED = {}
|
|
111
129
|
CONFIG_LOCK = threading.RLock()
|
|
@@ -376,3 +394,11 @@ def find(metadata, what, result=None, *, select: callable = None):
|
|
|
376
394
|
find(v, what, result)
|
|
377
395
|
|
|
378
396
|
return result
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
def merge_configs(*configs):
|
|
400
|
+
result = {}
|
|
401
|
+
for config in configs:
|
|
402
|
+
_merge_dicts(result, config)
|
|
403
|
+
|
|
404
|
+
return result
|
anemoi/utils/logs.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# (C) Copyright 2024 Anemoi contributors.
|
|
2
|
+
#
|
|
3
|
+
# This software is licensed under the terms of the Apache Licence Version 2.0
|
|
4
|
+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
5
|
+
#
|
|
6
|
+
# In applying this licence, ECMWF does not waive the privileges and immunities
|
|
7
|
+
# granted to it by virtue of its status as an intergovernmental organisation
|
|
8
|
+
# nor does it submit to any jurisdiction.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
"""Logging utilities."""
|
|
12
|
+
|
|
13
|
+
import logging
|
|
14
|
+
import threading
|
|
15
|
+
|
|
16
|
+
thread_local = threading.local()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
LOGGER = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def set_logging_name(name):
|
|
23
|
+
thread_local.logging_name = name
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ThreadCustomFormatter(logging.Formatter):
|
|
27
|
+
def format(self, record):
|
|
28
|
+
record.logging_name = thread_local.logging_name
|
|
29
|
+
return super().format(record)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def enable_logging_name(name="main"):
|
|
33
|
+
thread_local.logging_name = name
|
|
34
|
+
|
|
35
|
+
formatter = ThreadCustomFormatter("%(asctime)s - %(logging_name)s - %(levelname)s - %(message)s")
|
|
36
|
+
|
|
37
|
+
logger = logging.getLogger()
|
|
38
|
+
|
|
39
|
+
for handler in logger.handlers:
|
|
40
|
+
handler.setFormatter(formatter)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
|
|
2
|
+
# This software is licensed under the terms of the Apache Licence Version 2.0
|
|
3
|
+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
4
|
+
# In applying this licence, ECMWF does not waive the privileges and immunities
|
|
5
|
+
# granted to it by virtue of its status as an intergovernmental organisation
|
|
6
|
+
# nor does it submit to any jurisdiction.
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def print_request(verb, request, file=sys.stdout):
|
|
12
|
+
r = [verb]
|
|
13
|
+
for k, v in request.items():
|
|
14
|
+
if not isinstance(v, (list, tuple, set)):
|
|
15
|
+
v = [v]
|
|
16
|
+
v = [str(_) for _ in v]
|
|
17
|
+
v = "/".join(v)
|
|
18
|
+
r.append(f"{k}={v}")
|
|
19
|
+
|
|
20
|
+
r = ",\n ".join(r)
|
|
21
|
+
print(r, file=file)
|
|
22
|
+
print(file=file)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: anemoi-utils
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.10
|
|
4
4
|
Summary: A package to hold various functions to support training of ML models on ECMWF data.
|
|
5
5
|
Author-email: "European Centre for Medium-Range Weather Forecasts (ECMWF)" <software.support@ecmwf.int>
|
|
6
|
-
License:
|
|
6
|
+
License: Apache License
|
|
7
7
|
Version 2.0, January 2004
|
|
8
8
|
http://www.apache.org/licenses/
|
|
9
9
|
|
|
@@ -225,31 +225,30 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
225
225
|
Requires-Python: >=3.9
|
|
226
226
|
License-File: LICENSE
|
|
227
227
|
Requires-Dist: aniso8601
|
|
228
|
+
Requires-Dist: importlib-metadata; python_version < "3.10"
|
|
228
229
|
Requires-Dist: python-dateutil
|
|
229
230
|
Requires-Dist: pyyaml
|
|
231
|
+
Requires-Dist: tomli; python_version < "3.11"
|
|
230
232
|
Requires-Dist: tqdm
|
|
231
|
-
Requires-Dist: importlib-metadata ; python_version < "3.10"
|
|
232
|
-
Requires-Dist: tomli ; python_version < "3.11"
|
|
233
233
|
Provides-Extra: all
|
|
234
|
-
Requires-Dist: anemoi-utils[grib,provenance,text]
|
|
234
|
+
Requires-Dist: anemoi-utils[grib,provenance,text]; extra == "all"
|
|
235
235
|
Provides-Extra: dev
|
|
236
|
-
Requires-Dist: anemoi-utils[all,docs,tests]
|
|
236
|
+
Requires-Dist: anemoi-utils[all,docs,tests]; extra == "dev"
|
|
237
237
|
Provides-Extra: docs
|
|
238
|
-
Requires-Dist: nbsphinx
|
|
239
|
-
Requires-Dist: pandoc
|
|
240
|
-
Requires-Dist: requests
|
|
241
|
-
Requires-Dist: sphinx
|
|
242
|
-
Requires-Dist: sphinx-argparse
|
|
243
|
-
Requires-Dist: sphinx-rtd-theme
|
|
244
|
-
Requires-Dist: termcolor
|
|
238
|
+
Requires-Dist: nbsphinx; extra == "docs"
|
|
239
|
+
Requires-Dist: pandoc; extra == "docs"
|
|
240
|
+
Requires-Dist: requests; extra == "docs"
|
|
241
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
242
|
+
Requires-Dist: sphinx-argparse<0.5; extra == "docs"
|
|
243
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
244
|
+
Requires-Dist: termcolor; extra == "docs"
|
|
245
245
|
Provides-Extra: grib
|
|
246
|
-
Requires-Dist: requests
|
|
246
|
+
Requires-Dist: requests; extra == "grib"
|
|
247
247
|
Provides-Extra: provenance
|
|
248
|
-
Requires-Dist: gitpython
|
|
249
|
-
Requires-Dist: nvsmi
|
|
248
|
+
Requires-Dist: gitpython; extra == "provenance"
|
|
249
|
+
Requires-Dist: nvsmi; extra == "provenance"
|
|
250
250
|
Provides-Extra: tests
|
|
251
|
-
Requires-Dist: pytest
|
|
251
|
+
Requires-Dist: pytest; extra == "tests"
|
|
252
252
|
Provides-Extra: text
|
|
253
|
-
Requires-Dist: termcolor
|
|
254
|
-
Requires-Dist: wcwidth
|
|
255
|
-
|
|
253
|
+
Requires-Dist: termcolor; extra == "text"
|
|
254
|
+
Requires-Dist: wcwidth; extra == "text"
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
anemoi/utils/__init__.py,sha256=0u0eIdu5-H1frf6V4KHpNmlh_SS-bJnxjzIejlsLqdw,702
|
|
2
2
|
anemoi/utils/__main__.py,sha256=5NW2A3OgTimB4ptwYThivIRSeCrvabMuvnr8mmnVx0E,715
|
|
3
|
-
anemoi/utils/_version.py,sha256=
|
|
3
|
+
anemoi/utils/_version.py,sha256=OK_y1wkdggDGF27DpKS31C6p5FSDPep8dDgBhyKlfYE,413
|
|
4
4
|
anemoi/utils/caching.py,sha256=0cznpvaaox14NSVi-Q3PqumfuGtXo0YNcEFwDPxvMZw,1948
|
|
5
5
|
anemoi/utils/checkpoints.py,sha256=q8QqKlZ6qChjzEfq7KM1gVXuyqgsVRGIb4dJFtkGk58,7774
|
|
6
6
|
anemoi/utils/cli.py,sha256=rmMP60VY3em99rQP6TCrKibMngWwVe5h_0GDcf16c5U,4117
|
|
7
7
|
anemoi/utils/compatibility.py,sha256=0_nIcbdQbNMrS6AkqrBgJGJlSJXW8R23ncaZaDwdJ4c,2190
|
|
8
|
-
anemoi/utils/config.py,sha256=
|
|
8
|
+
anemoi/utils/config.py,sha256=c7dh9jRKHQ4DmwNTuniOZcrqZQgxU5VLQqH6rHSE7bI,10460
|
|
9
9
|
anemoi/utils/dates.py,sha256=wwYD5_QI7EWY_jhpENNYtL5O7fjwYkzmqHkNoayvmrY,12452
|
|
10
10
|
anemoi/utils/grib.py,sha256=zBICyOsYtR_9px1C5UDT6wL_D6kiIhUi_00kjFmas5c,3047
|
|
11
11
|
anemoi/utils/hindcasts.py,sha256=TEYDmrZUajuhp_dfWeg6z5c6XfntE-mwugUQJyAgUco,1419
|
|
12
12
|
anemoi/utils/humanize.py,sha256=tSQkiUHiDj3VYk-DeruHp9P79sJO1b0whsPBphqy9qA,16627
|
|
13
|
+
anemoi/utils/logs.py,sha256=o0xXiO2BdG_bZkljxxI2TKlCiA5QbWHgAUlYM53lirE,1058
|
|
13
14
|
anemoi/utils/provenance.py,sha256=SqOiNoY1y36Zec83Pjt7OhihbwxMyknscfmogHCuriA,10894
|
|
14
15
|
anemoi/utils/registry.py,sha256=Iit_CfTGuoVffXkZA2A5mUXb4AdGIUX9TpnUqWT4HJ0,4291
|
|
15
16
|
anemoi/utils/s3.py,sha256=UOEETko08hnIXeFy8u10eQbqpcape9d-L6IgsjFMe18,2473
|
|
@@ -19,14 +20,16 @@ anemoi/utils/text.py,sha256=Xfr_3wvsjg7m-BwvdJVz1bV6f5KNMnGIIFRtXaiMfbs,10496
|
|
|
19
20
|
anemoi/utils/timer.py,sha256=Twnr3GZu-n0WzgboELRKJWs87qyDYqy6Dwr9cQ_JG18,1803
|
|
20
21
|
anemoi/utils/commands/__init__.py,sha256=O5W3yHZywRoAqmRUioAr3zMCh0hGVV18wZYGvc00ioM,698
|
|
21
22
|
anemoi/utils/commands/config.py,sha256=zt4PFATYJ-zs0C5mpUlrQ4Fj5m1kM3CcsszUP1VBbzA,816
|
|
23
|
+
anemoi/utils/commands/requests.py,sha256=7joRYnJUzJh5O8Pqkqa-s9M9woHy-Z86czp00uCZXGc,1448
|
|
22
24
|
anemoi/utils/mars/__init__.py,sha256=kvbu-gSaYI9jSNEzfQltrtHPVIameYGoLjOJKwI7x_U,1723
|
|
23
25
|
anemoi/utils/mars/mars.yaml,sha256=R0dujp75lLA4wCWhPeOQnzJ45WZAYLT8gpx509cBFlc,66
|
|
26
|
+
anemoi/utils/mars/requests.py,sha256=0khe_mbq4GNueR_B8fGPTBoWHtCfjQvtoKXOSVm6La4,759
|
|
24
27
|
anemoi/utils/remote/__init__.py,sha256=-_AA1xm9GpagW5zP0PGpz-3SRKEUjw_AGSNd_bhuh7g,11639
|
|
25
28
|
anemoi/utils/remote/s3.py,sha256=hykbVlh1_aFI00FWjgm_FWIMfVCTFiQf_cq8_gAo31s,11976
|
|
26
29
|
anemoi/utils/remote/ssh.py,sha256=3lqFpY9CEor_DvIK9ZxSmj3rND-366Sm9R3Vw61sWSs,4695
|
|
27
|
-
anemoi_utils-0.4.
|
|
28
|
-
anemoi_utils-0.4.
|
|
29
|
-
anemoi_utils-0.4.
|
|
30
|
-
anemoi_utils-0.4.
|
|
31
|
-
anemoi_utils-0.4.
|
|
32
|
-
anemoi_utils-0.4.
|
|
30
|
+
anemoi_utils-0.4.10.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
31
|
+
anemoi_utils-0.4.10.dist-info/METADATA,sha256=CHhddg_iojS8zfV67wBSG0DIlGeZq7ShPf7UiSAdu3Y,15237
|
|
32
|
+
anemoi_utils-0.4.10.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
33
|
+
anemoi_utils-0.4.10.dist-info/entry_points.txt,sha256=LENOkn88xzFQo-V59AKoA_F_cfYQTJYtrNTtf37YgHY,60
|
|
34
|
+
anemoi_utils-0.4.10.dist-info/top_level.txt,sha256=DYn8VPs-fNwr7fNH9XIBqeXIwiYYd2E2k5-dUFFqUz0,7
|
|
35
|
+
anemoi_utils-0.4.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|