anemoi-utils 0.4.12__py3-none-any.whl → 0.4.13__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/timer.py CHANGED
@@ -13,6 +13,7 @@
13
13
  import logging
14
14
  import time
15
15
  from collections import defaultdict
16
+ from typing import Any
16
17
 
17
18
  from .humanize import seconds_to_human
18
19
 
@@ -20,21 +21,53 @@ LOGGER = logging.getLogger(__name__)
20
21
 
21
22
 
22
23
  class Timer:
23
- """Context manager to measure elapsed time."""
24
-
25
- def __init__(self, title, logger=LOGGER):
24
+ """Context manager to measure elapsed time.
25
+
26
+ Parameters
27
+ ----------
28
+ title : str
29
+ The title of the timer.
30
+ logger : logging.Logger, optional
31
+ The logger to use for logging the elapsed time, by default LOGGER.
32
+ """
33
+
34
+ def __init__(self, title: str, logger: logging.Logger = LOGGER):
35
+ """Initialize the Timer.
36
+
37
+ Parameters
38
+ ----------
39
+ title : str
40
+ The title of the timer.
41
+ logger : logging.Logger, optional
42
+ The logger to use for logging the elapsed time, by default LOGGER.
43
+ """
26
44
  self.title = title
27
45
  self.start = time.time()
28
46
  self.logger = logger
29
47
 
30
- def __enter__(self):
48
+ def __enter__(self) -> "Timer":
49
+ """Enter the runtime context related to this object.
50
+
51
+ Returns
52
+ -------
53
+ Timer
54
+ The Timer object itself.
55
+ """
31
56
  return self
32
57
 
33
58
  @property
34
- def elapsed(self):
59
+ def elapsed(self) -> float:
60
+ """Float: The elapsed time in seconds."""
35
61
  return time.time() - self.start
36
62
 
37
- def __exit__(self, *args):
63
+ def __exit__(self, *args: Any) -> None:
64
+ """Exit the runtime context related to this object.
65
+
66
+ Parameters
67
+ ----------
68
+ *args : Any
69
+ Exception information.
70
+ """
38
71
  self.logger.info("%s: %s.", self.title, seconds_to_human(self.elapsed))
39
72
 
40
73
 
@@ -42,33 +75,76 @@ class _Timer:
42
75
  """Internal timer class."""
43
76
 
44
77
  def __init__(self):
78
+ """Initialize the _Timer."""
45
79
  self.elapsed = 0.0
46
80
 
47
- def __enter__(self):
81
+ def __enter__(self) -> "_Timer":
82
+ """Enter the runtime context related to this object.
83
+
84
+ Returns
85
+ -------
86
+ _Timer
87
+ The _Timer object itself.
88
+ """
48
89
  self.start()
49
90
  return self
50
91
 
51
- def __exit__(self, *args):
92
+ def __exit__(self, *args: Any) -> None:
93
+ """Exit the runtime context related to this object.
94
+
95
+ Parameters
96
+ ----------
97
+ *args : Any
98
+ Exception information.
99
+ """
52
100
  self.stop()
53
101
 
54
- def start(self):
102
+ def start(self) -> None:
103
+ """Start the timer."""
55
104
  self._start = time.time()
56
105
 
57
- def stop(self):
106
+ def stop(self) -> None:
107
+ """Stop the timer and accumulate the elapsed time."""
58
108
  self.elapsed += time.time() - self._start
59
109
 
60
110
 
61
111
  class Timers:
62
- """A collection of timers."""
63
-
64
- def __init__(self, logger=LOGGER):
112
+ """A collection of timers.
113
+
114
+ Parameters
115
+ ----------
116
+ logger : logging.Logger, optional
117
+ The logger to use for logging the elapsed time, by default LOGGER.
118
+ """
119
+
120
+ def __init__(self, logger: logging.Logger = LOGGER):
121
+ """Initialize the Timers collection.
122
+
123
+ Parameters
124
+ ----------
125
+ logger : logging.Logger, optional
126
+ The logger to use for logging the elapsed time, by default LOGGER.
127
+ """
65
128
  self.logger = logger
66
129
  self.timers = defaultdict(_Timer)
67
130
 
68
- def __getitem__(self, name):
131
+ def __getitem__(self, name: str) -> _Timer:
132
+ """Get a timer by name.
133
+
134
+ Parameters
135
+ ----------
136
+ name : str
137
+ The name of the timer.
138
+
139
+ Returns
140
+ -------
141
+ _Timer
142
+ The timer with the given name.
143
+ """
69
144
  return self.timers[name]
70
145
 
71
- def report(self):
146
+ def report(self) -> None:
147
+ """Log the elapsed time for all timers."""
72
148
  length = max(len(name) for name in self.timers)
73
149
  for name, timer in sorted(self.timers.items()):
74
150
  self.logger.info("%s: %s.", f"{name:<{length}}", seconds_to_human(timer.elapsed))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: anemoi-utils
3
- Version: 0.4.12
3
+ Version: 0.4.13
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
6
  License: Apache License
@@ -226,13 +226,14 @@ Requires-Python: >=3.9
226
226
  License-File: LICENSE
227
227
  Requires-Dist: aniso8601
228
228
  Requires-Dist: importlib-metadata; python_version < "3.10"
229
+ Requires-Dist: multiurl
229
230
  Requires-Dist: numpy
230
231
  Requires-Dist: python-dateutil
231
232
  Requires-Dist: pyyaml
232
233
  Requires-Dist: tomli; python_version < "3.11"
233
234
  Requires-Dist: tqdm
234
235
  Provides-Extra: all
235
- Requires-Dist: anemoi-utils[grib,provenance,text]; extra == "all"
236
+ Requires-Dist: anemoi-utils[grib,provenance,s3,text]; extra == "all"
236
237
  Provides-Extra: dev
237
238
  Requires-Dist: anemoi-utils[all,docs,tests]; extra == "dev"
238
239
  Provides-Extra: docs
@@ -240,7 +241,7 @@ Requires-Dist: nbsphinx; extra == "docs"
240
241
  Requires-Dist: pandoc; extra == "docs"
241
242
  Requires-Dist: requests; extra == "docs"
242
243
  Requires-Dist: sphinx; extra == "docs"
243
- Requires-Dist: sphinx-argparse<0.5; extra == "docs"
244
+ Requires-Dist: sphinx-argparse; extra == "docs"
244
245
  Requires-Dist: sphinx-rtd-theme; extra == "docs"
245
246
  Requires-Dist: termcolor; extra == "docs"
246
247
  Provides-Extra: grib
@@ -248,6 +249,8 @@ Requires-Dist: requests; extra == "grib"
248
249
  Provides-Extra: provenance
249
250
  Requires-Dist: gitpython; extra == "provenance"
250
251
  Requires-Dist: nvsmi; extra == "provenance"
252
+ Provides-Extra: s3
253
+ Requires-Dist: boto3<1.36; extra == "s3"
251
254
  Provides-Extra: tests
252
255
  Requires-Dist: pytest; extra == "tests"
253
256
  Provides-Extra: text
@@ -0,0 +1,37 @@
1
+ anemoi/utils/__init__.py,sha256=uVhpF-VjIl_4mMywOVtgTutgsdIsqz-xdkwxeMhzuag,730
2
+ anemoi/utils/__main__.py,sha256=6LlE4MYrPvqqrykxXh7XMi50UZteUY59NeM8P9Zs2dU,910
3
+ anemoi/utils/_version.py,sha256=NEWZMsf9hAPHbHDxsYo2Rgs87lmnioXpPKJ62lRxhqs,513
4
+ anemoi/utils/caching.py,sha256=rXbeAmpBcMbbfN4EVblaHWKicsrtx1otER84FEBtz98,6183
5
+ anemoi/utils/checkpoints.py,sha256=N4WpAZXa4etrpSEKhHqUUtG2-x9w3FJMHcLO-dDAXPY,9600
6
+ anemoi/utils/cli.py,sha256=IyZfnSw0u0yYnrjOrzvm2RuuKvDk4cVb8pf8BkaChgA,6209
7
+ anemoi/utils/compatibility.py,sha256=wRBRMmxQP88rNcWiP5gqXliwYQbBv1iCAsDjcCRi5UY,2234
8
+ anemoi/utils/config.py,sha256=4K4_ePeuUPyIMsE7-r77OC87ntFGdVLskB0ow9XNzXI,16353
9
+ anemoi/utils/dates.py,sha256=CnY6JOdpk0T-waPEowMRTkcMzxcN0GcjPVtLkwH_byw,17196
10
+ anemoi/utils/devtools.py,sha256=vivYRQ1l2aMAkggqhpMJcJedfCrRfpy5XMQjZIsMJS0,3596
11
+ anemoi/utils/grib.py,sha256=201WcxjjAl92Y2HX2kZ2S8Qr5dN-oG7nV-vQLaybzP4,3610
12
+ anemoi/utils/grids.py,sha256=edTrMK8hpE9ZBzSfwcRftgk0jljNAK3i8CraadILQoM,4427
13
+ anemoi/utils/hindcasts.py,sha256=iYVIxSNFL2HJcc_k1abCFLkpJFGHT8WKRIR4wcAwA3s,2144
14
+ anemoi/utils/humanize.py,sha256=hCrHr5ppREuJR-tBqRqynqe58BHR6Ga_gCQqgEmmrfU,25301
15
+ anemoi/utils/logs.py,sha256=naTgrmPwWHD4eekFttXftS4gtcAGYHpCqG4iwYprNDA,1804
16
+ anemoi/utils/provenance.py,sha256=l6TRVadM5l3SKUvYM20EQn0TbolSY6vbbZ_WqekjxwM,14619
17
+ anemoi/utils/registry.py,sha256=J2onjVqR4LLYRAj5sioobsdxo_e4kxuBOSiNeAQbGe8,7061
18
+ anemoi/utils/s3.py,sha256=xMT48kbcelcjjqsaU567WI3oZ5eqo88Rlgyx5ECszAU,4074
19
+ anemoi/utils/sanitise.py,sha256=ZYGdSX6qihQANr3pHZjbKnoapnzP1KcrWdW1Ul1mOGk,3668
20
+ anemoi/utils/sanitize.py,sha256=43ZKDcfVpeXSsJ9TFEc9aZnD6oe2cUh151XnDspM98M,462
21
+ anemoi/utils/text.py,sha256=HkzIvi24obDceFLpJEwBJ9PmPrJUkQN2TrElJ-A87gU,14441
22
+ anemoi/utils/timer.py,sha256=_leKMYza2faM7JKlGE7LCNy13rbdPnwaCF7PSrI_NmI,3895
23
+ anemoi/utils/commands/__init__.py,sha256=5u_6EwdqYczIAgJfCwRSyQAYFEqh2ZuHHT57g9g7sdI,808
24
+ anemoi/utils/commands/config.py,sha256=nYvYbjcum9uumRa3gzPfmQCjNZKURXMA2XOUwz9b7ls,1369
25
+ anemoi/utils/commands/requests.py,sha256=AEbssF1OlpbmSwrV5Lj6amCCn0w_-nbajBWTwYV15vA,2059
26
+ anemoi/utils/mars/__init__.py,sha256=b-Lc3L1TAQd9ODs0Z1YSJzgZCO1K_M3DSgx_yd2qXvM,2724
27
+ anemoi/utils/mars/mars.yaml,sha256=R0dujp75lLA4wCWhPeOQnzJ45WZAYLT8gpx509cBFlc,66
28
+ anemoi/utils/mars/requests.py,sha256=VFMHBVAAl0_2lOcMBa1lvaKHctN0lDJsI6_U4BucGew,1142
29
+ anemoi/utils/remote/__init__.py,sha256=-uaYFi4yRYFRf46ubQbJo86GCn6HE5VQrcaoyrmyW28,20704
30
+ anemoi/utils/remote/s3.py,sha256=spQ8l0rwQjLZh9dZu5cOsYIvNwKihQfCJ6YsFYegeqI,17339
31
+ anemoi/utils/remote/ssh.py,sha256=xNtsawh8okytCKRehkRCVExbHZj-CRUQNormEHglfuw,8088
32
+ anemoi_utils-0.4.13.dist-info/LICENSE,sha256=8HznKF1Vi2IvfLsKNE5A2iVyiri3pRjRPvPC9kxs6qk,11354
33
+ anemoi_utils-0.4.13.dist-info/METADATA,sha256=WSExhiI_8UePoAsCE4h65G2moeuMEgWZcgECBsisx30,15338
34
+ anemoi_utils-0.4.13.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
35
+ anemoi_utils-0.4.13.dist-info/entry_points.txt,sha256=LENOkn88xzFQo-V59AKoA_F_cfYQTJYtrNTtf37YgHY,60
36
+ anemoi_utils-0.4.13.dist-info/top_level.txt,sha256=DYn8VPs-fNwr7fNH9XIBqeXIwiYYd2E2k5-dUFFqUz0,7
37
+ anemoi_utils-0.4.13.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,37 +0,0 @@
1
- anemoi/utils/__init__.py,sha256=0u0eIdu5-H1frf6V4KHpNmlh_SS-bJnxjzIejlsLqdw,702
2
- anemoi/utils/__main__.py,sha256=5NW2A3OgTimB4ptwYThivIRSeCrvabMuvnr8mmnVx0E,715
3
- anemoi/utils/_version.py,sha256=sg-lGJqAzZSE-Cr-6X2XM20x4P3h_gsFXHtA5vFf4qs,413
4
- anemoi/utils/caching.py,sha256=UkHQOKcBoB6xni83qgTEGfkyam7iqu1YiuBLZQIn9RM,3208
5
- anemoi/utils/checkpoints.py,sha256=q8QqKlZ6qChjzEfq7KM1gVXuyqgsVRGIb4dJFtkGk58,7774
6
- anemoi/utils/cli.py,sha256=rmMP60VY3em99rQP6TCrKibMngWwVe5h_0GDcf16c5U,4117
7
- anemoi/utils/compatibility.py,sha256=0_nIcbdQbNMrS6AkqrBgJGJlSJXW8R23ncaZaDwdJ4c,2190
8
- anemoi/utils/config.py,sha256=ADCksBl6qrJpU9eebVebwkthNanzgCOxBgzlqCUTwbg,10962
9
- anemoi/utils/dates.py,sha256=brsBEje1w8sJ1RbVJl-_nxbSUYsn1h0zaF6EY54zpDs,12785
10
- anemoi/utils/devtools.py,sha256=Mns5vU9o2HrO4zS1e0-W4gBIhk8xHrhcB7wLR_q6OiA,2172
11
- anemoi/utils/grib.py,sha256=zBICyOsYtR_9px1C5UDT6wL_D6kiIhUi_00kjFmas5c,3047
12
- anemoi/utils/grids.py,sha256=tqhH8ZiRS9Re7xQZHVKtl8bBtqH_kDVOGHfDTxu3RuI,2708
13
- anemoi/utils/hindcasts.py,sha256=TEYDmrZUajuhp_dfWeg6z5c6XfntE-mwugUQJyAgUco,1419
14
- anemoi/utils/humanize.py,sha256=ZD5UMD7m79I1h_IoIQFnd4FZR5K9VARw9cVaNrD1QdM,17579
15
- anemoi/utils/logs.py,sha256=o0xXiO2BdG_bZkljxxI2TKlCiA5QbWHgAUlYM53lirE,1058
16
- anemoi/utils/provenance.py,sha256=SqOiNoY1y36Zec83Pjt7OhihbwxMyknscfmogHCuriA,10894
17
- anemoi/utils/registry.py,sha256=Iit_CfTGuoVffXkZA2A5mUXb4AdGIUX9TpnUqWT4HJ0,4291
18
- anemoi/utils/s3.py,sha256=UOEETko08hnIXeFy8u10eQbqpcape9d-L6IgsjFMe18,2473
19
- anemoi/utils/sanitise.py,sha256=MqEMLwVZ1jSemLDBoQXuJyXKIfyR0gzYi7DoITBcir8,2866
20
- anemoi/utils/sanitize.py,sha256=43ZKDcfVpeXSsJ9TFEc9aZnD6oe2cUh151XnDspM98M,462
21
- anemoi/utils/text.py,sha256=Xfr_3wvsjg7m-BwvdJVz1bV6f5KNMnGIIFRtXaiMfbs,10496
22
- anemoi/utils/timer.py,sha256=Twnr3GZu-n0WzgboELRKJWs87qyDYqy6Dwr9cQ_JG18,1803
23
- anemoi/utils/commands/__init__.py,sha256=O5W3yHZywRoAqmRUioAr3zMCh0hGVV18wZYGvc00ioM,698
24
- anemoi/utils/commands/config.py,sha256=zt4PFATYJ-zs0C5mpUlrQ4Fj5m1kM3CcsszUP1VBbzA,816
25
- anemoi/utils/commands/requests.py,sha256=NZPtQ2-PEtj7w5nNzTq5Tvj5axtsVAeuTUOKIQt-Faw,1555
26
- anemoi/utils/mars/__init__.py,sha256=kvbu-gSaYI9jSNEzfQltrtHPVIameYGoLjOJKwI7x_U,1723
27
- anemoi/utils/mars/mars.yaml,sha256=R0dujp75lLA4wCWhPeOQnzJ45WZAYLT8gpx509cBFlc,66
28
- anemoi/utils/mars/requests.py,sha256=0khe_mbq4GNueR_B8fGPTBoWHtCfjQvtoKXOSVm6La4,759
29
- anemoi/utils/remote/__init__.py,sha256=-_AA1xm9GpagW5zP0PGpz-3SRKEUjw_AGSNd_bhuh7g,11639
30
- anemoi/utils/remote/s3.py,sha256=hykbVlh1_aFI00FWjgm_FWIMfVCTFiQf_cq8_gAo31s,11976
31
- anemoi/utils/remote/ssh.py,sha256=3lqFpY9CEor_DvIK9ZxSmj3rND-366Sm9R3Vw61sWSs,4695
32
- anemoi_utils-0.4.12.dist-info/LICENSE,sha256=8HznKF1Vi2IvfLsKNE5A2iVyiri3pRjRPvPC9kxs6qk,11354
33
- anemoi_utils-0.4.12.dist-info/METADATA,sha256=-9E31lmUv9bhpu_e4ZlLRgWtZdrRdeAo5KFzfJg42HU,15255
34
- anemoi_utils-0.4.12.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
35
- anemoi_utils-0.4.12.dist-info/entry_points.txt,sha256=LENOkn88xzFQo-V59AKoA_F_cfYQTJYtrNTtf37YgHY,60
36
- anemoi_utils-0.4.12.dist-info/top_level.txt,sha256=DYn8VPs-fNwr7fNH9XIBqeXIwiYYd2E2k5-dUFFqUz0,7
37
- anemoi_utils-0.4.12.dist-info/RECORD,,