anemoi-utils 0.4.1__py3-none-any.whl → 0.4.2__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/__init__.py CHANGED
@@ -6,4 +6,10 @@
6
6
  # nor does it submit to any jurisdiction.
7
7
 
8
8
 
9
- from ._version import __version__ as __version__
9
+ try:
10
+ # NOTE: the `_version.py` file must not be present in the git repository
11
+ # as it is generated by setuptools at install time
12
+ from ._version import __version__ # type: ignore
13
+ except ImportError: # pragma: no cover
14
+ # Local copy or not installed with setuptools
15
+ __version__ = "999"
anemoi/utils/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.4.1'
16
- __version_tuple__ = version_tuple = (0, 4, 1)
15
+ __version__ = version = '0.4.2'
16
+ __version_tuple__ = version_tuple = (0, 4, 2)
anemoi/utils/caching.py CHANGED
@@ -1,10 +1,13 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
7
9
 
10
+
8
11
  import hashlib
9
12
  import json
10
13
  import os
@@ -1,11 +1,13 @@
1
- # (C) Copyright 2024 ECMWF.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
2
  #
3
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
4
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
5
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
6
7
  # granted to it by virtue of its status as an intergovernmental organisation
7
8
  # nor does it submit to any jurisdiction.
8
9
 
10
+
9
11
  """Read and write extra metadata in PyTorch checkpoints files. These files
10
12
  are zip archives containing the model weights.
11
13
  """
anemoi/utils/cli.py CHANGED
@@ -1,10 +1,13 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
7
9
 
10
+
8
11
  import argparse
9
12
  import importlib
10
13
  import logging
@@ -1,12 +1,12 @@
1
- #!/usr/bin/env python
2
- # (C) Copyright 2024 ECMWF.
1
+ #!/usr/bin/env python3
2
+ # (C) Copyright 2024 Anemoi contributors.
3
3
  #
4
4
  # This software is licensed under the terms of the Apache Licence Version 2.0
5
5
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ #
6
7
  # In applying this licence, ECMWF does not waive the privileges and immunities
7
8
  # granted to it by virtue of its status as an intergovernmental organisation
8
9
  # nor does it submit to any jurisdiction.
9
- #
10
10
 
11
11
 
12
12
  import json
anemoi/utils/config.py CHANGED
@@ -1,10 +1,13 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
7
9
 
10
+
8
11
  from __future__ import annotations
9
12
 
10
13
  import json
anemoi/utils/dates.py CHANGED
@@ -1,6 +1,8 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
anemoi/utils/grib.py CHANGED
@@ -1,10 +1,13 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
7
9
 
10
+
8
11
  """Utilities for working with GRIB parameters.
9
12
 
10
13
  See https://codes.ecmwf.int/grib/param-db/ for more information.
anemoi/utils/hindcasts.py CHANGED
@@ -1,6 +1,8 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
anemoi/utils/humanize.py CHANGED
@@ -1,11 +1,12 @@
1
- # (C) Copyright 2020 ECMWF.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
2
  #
3
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
4
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
5
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
6
7
  # granted to it by virtue of its status as an intergovernmental organisation
7
8
  # nor does it submit to any jurisdiction.
8
- #
9
+
9
10
 
10
11
  """Generate human readable strings"""
11
12
 
@@ -1,10 +1,13 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
7
9
 
10
+
8
11
  """Collect information about the current environment, like:
9
12
 
10
13
  - The Python version
anemoi/utils/s3.py CHANGED
@@ -1,10 +1,13 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
7
9
 
10
+
8
11
  """This module provides functions to upload, download, list and delete files and folders on S3.
9
12
  The functions of this package expect that the AWS credentials are set up in the environment
10
13
  typicaly by setting the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables or
anemoi/utils/sanitise.py CHANGED
@@ -1,6 +1,8 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
@@ -45,7 +47,7 @@ def _sanitise_string(obj):
45
47
 
46
48
  parsed = urlparse(obj, allow_fragments=True)
47
49
 
48
- if parsed.scheme:
50
+ if parsed.scheme and parsed.scheme[0].isalpha():
49
51
  return _sanitise_url(parsed)
50
52
 
51
53
  if obj.startswith("/") or obj.startswith("~"):
anemoi/utils/sanitize.py CHANGED
@@ -1,10 +1,13 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
7
9
 
10
+
8
11
  from .sanitise import sanitise as sanitize
9
12
 
10
13
  __all__ = ["sanitize"]
anemoi/utils/text.py CHANGED
@@ -1,10 +1,13 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
7
9
 
10
+
8
11
  """Text utilities"""
9
12
 
10
13
  import re
anemoi/utils/timer.py CHANGED
@@ -1,14 +1,18 @@
1
- # (C) Copyright 2024 European Centre for Medium-Range Weather Forecasts.
1
+ # (C) Copyright 2024 Anemoi contributors.
2
+ #
2
3
  # This software is licensed under the terms of the Apache Licence Version 2.0
3
4
  # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ #
4
6
  # In applying this licence, ECMWF does not waive the privileges and immunities
5
7
  # granted to it by virtue of its status as an intergovernmental organisation
6
8
  # nor does it submit to any jurisdiction.
7
9
 
10
+
8
11
  """Logging utilities."""
9
12
 
10
13
  import logging
11
14
  import time
15
+ from collections import defaultdict
12
16
 
13
17
  from .humanize import seconds_to_human
14
18
 
@@ -32,3 +36,39 @@ class Timer:
32
36
 
33
37
  def __exit__(self, *args):
34
38
  self.logger.info("%s: %s.", self.title, seconds_to_human(self.elapsed))
39
+
40
+
41
+ class _Timer:
42
+ """Internal timer class."""
43
+
44
+ def __init__(self):
45
+ self.elapsed = 0.0
46
+
47
+ def __enter__(self):
48
+ self.start()
49
+ return self
50
+
51
+ def __exit__(self, *args):
52
+ self.stop()
53
+
54
+ def start(self):
55
+ self._start = time.time()
56
+
57
+ def stop(self):
58
+ self.elapsed += time.time() - self._start
59
+
60
+
61
+ class Timers:
62
+ """A collection of timers."""
63
+
64
+ def __init__(self, logger=LOGGER):
65
+ self.logger = logger
66
+ self.timers = defaultdict(_Timer)
67
+
68
+ def __getitem__(self, name):
69
+ return self.timers[name]
70
+
71
+ def report(self):
72
+ length = max(len(name) for name in self.timers)
73
+ for name, timer in sorted(self.timers.items()):
74
+ self.logger.info("%s: %s.", f"{name:<{length}}", seconds_to_human(timer.elapsed))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: anemoi-utils
3
- Version: 0.4.1
3
+ Version: 0.4.2
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
@@ -0,0 +1,27 @@
1
+ anemoi/utils/__init__.py,sha256=se9GXELQQbXBN_5O8lolt4vAPuIavGDKzNWUMmsERWI,729
2
+ anemoi/utils/__main__.py,sha256=cLA2PidDTOUHaDGzd0_E5iioKYNe-PSTv567Y2fuwQk,723
3
+ anemoi/utils/_version.py,sha256=McNH31cVzymi4jtwoAHwNiyVAdDW8uY0z3IcBioCvQI,411
4
+ anemoi/utils/caching.py,sha256=0cznpvaaox14NSVi-Q3PqumfuGtXo0YNcEFwDPxvMZw,1948
5
+ anemoi/utils/checkpoints.py,sha256=irFLb0R2M7XkVNduYGrcs7lR1rZ8r6J6csQQyvyYqYs,5292
6
+ anemoi/utils/cli.py,sha256=teCHTgo77hcF75Tn0hHdfsPZ5_YEYJNN2VqKl30wWV8,3734
7
+ anemoi/utils/config.py,sha256=VtHzYO_fcRpXH2zrPJQDv3C3Bi2XhPZD7SvNEsvxelA,9784
8
+ anemoi/utils/dates.py,sha256=hlO32nkCVu8PCGyVfV2RRREqSujfpwEn75xhN1IZaTs,12314
9
+ anemoi/utils/grib.py,sha256=zBICyOsYtR_9px1C5UDT6wL_D6kiIhUi_00kjFmas5c,3047
10
+ anemoi/utils/hindcasts.py,sha256=OUOY2nDa3LBnzJ3ncgANzJDapouh82KgVyofDAu7K_Q,1426
11
+ anemoi/utils/humanize.py,sha256=tSQkiUHiDj3VYk-DeruHp9P79sJO1b0whsPBphqy9qA,16627
12
+ anemoi/utils/provenance.py,sha256=nMSmIbHUD_TKYbjF3hzedtBpzpdVs_SaC7DSAlK857E,10856
13
+ anemoi/utils/s3.py,sha256=LMljA5OoaVcgZcg_rmH-_LOX4uicMZl1FY64Bx4uOO8,18694
14
+ anemoi/utils/sanitise.py,sha256=MqEMLwVZ1jSemLDBoQXuJyXKIfyR0gzYi7DoITBcir8,2866
15
+ anemoi/utils/sanitize.py,sha256=43ZKDcfVpeXSsJ9TFEc9aZnD6oe2cUh151XnDspM98M,462
16
+ anemoi/utils/text.py,sha256=Xfr_3wvsjg7m-BwvdJVz1bV6f5KNMnGIIFRtXaiMfbs,10496
17
+ anemoi/utils/timer.py,sha256=Twnr3GZu-n0WzgboELRKJWs87qyDYqy6Dwr9cQ_JG18,1803
18
+ anemoi/utils/commands/__init__.py,sha256=qAybFZPBBQs0dyx7dZ3X5JsLpE90pwrqt1vSV7cqEIw,706
19
+ anemoi/utils/commands/config.py,sha256=cAt6yYF3rN1shr57c8wXsgMEvQMRN08l_fCdA1Ux9gE,839
20
+ anemoi/utils/mars/__init__.py,sha256=RAeY8gJ7ZvsPlcIvrQ4fy9xVHs3SphTAPw_XJDtNIKo,1750
21
+ anemoi/utils/mars/mars.yaml,sha256=R0dujp75lLA4wCWhPeOQnzJ45WZAYLT8gpx509cBFlc,66
22
+ anemoi_utils-0.4.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
23
+ anemoi_utils-0.4.2.dist-info/METADATA,sha256=mx6gC9I7VyUjjVvKPwPVdHGv-svjaK09oRBHShf6hl8,15171
24
+ anemoi_utils-0.4.2.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
25
+ anemoi_utils-0.4.2.dist-info/entry_points.txt,sha256=LENOkn88xzFQo-V59AKoA_F_cfYQTJYtrNTtf37YgHY,60
26
+ anemoi_utils-0.4.2.dist-info/top_level.txt,sha256=DYn8VPs-fNwr7fNH9XIBqeXIwiYYd2E2k5-dUFFqUz0,7
27
+ anemoi_utils-0.4.2.dist-info/RECORD,,
@@ -1,27 +0,0 @@
1
- anemoi/utils/__init__.py,sha256=cXvnZAd--_pmNMnaRQDb7Lqf_tVqdq0QXDC674EKxks,471
2
- anemoi/utils/__main__.py,sha256=cLA2PidDTOUHaDGzd0_E5iioKYNe-PSTv567Y2fuwQk,723
3
- anemoi/utils/_version.py,sha256=H6xAc33bJwmO0oYU-O7_wWInmGAifNGi6CO6khT0G1g,411
4
- anemoi/utils/caching.py,sha256=bCOjP1jcDbwi7BID3XaR9BbkD1k3UipkP74NbgJuEFA,1974
5
- anemoi/utils/checkpoints.py,sha256=qWtqkQvMDlPIcfqz_GmOyUf0mmHZ6QEInpvgSJYIQjY,5275
6
- anemoi/utils/cli.py,sha256=Or4pUnuFqpSTlkTvh_VqV5moP2aBHKYINomPkUJFS68,3760
7
- anemoi/utils/config.py,sha256=nOYVUmajh-9nlzX-fCCPjVCUDjjaL3zZ8SWr2gP8qNs,9810
8
- anemoi/utils/dates.py,sha256=dgGbTqpGOpYDGgWfXL_69HutXTCHDFI2DhvG-9I9WQI,12341
9
- anemoi/utils/grib.py,sha256=mrk1drJm2jaPYERQX45QfX2MP4eUqRv0J-Y8IRSRTRE,3073
10
- anemoi/utils/hindcasts.py,sha256=X8k-81ltmkTDHdviY0SJgvMg7XDu07xoc5ALlUxyPoo,1453
11
- anemoi/utils/humanize.py,sha256=IxPpplDPSaFFRbAsy84fmit0rxRuJX5XpPhZbBHPB00,16612
12
- anemoi/utils/provenance.py,sha256=iSq4Y5eoWK_SNBMpMfInOB3shQlMZqE8iMBp-LgKtJk,10882
13
- anemoi/utils/s3.py,sha256=MuY-PrHpt6iKM2RK7v74YoCdqvVJ8UjBDJh0wxUR9Co,18720
14
- anemoi/utils/sanitise.py,sha256=VKIUiwm0EHPdkFUR6FkAxe94933yQx2obQtN6YROH5M,2862
15
- anemoi/utils/sanitize.py,sha256=6HJrfCMnrmH5lfxydcBc-AjxkmkFXdCc1wotzm9NBCw,488
16
- anemoi/utils/text.py,sha256=2D2ZbAdoivCgIjktpLoxb1D62GfyZ8P5KwVS3KWixR8,10522
17
- anemoi/utils/timer.py,sha256=EQcucuwUaGeSpt2S1APJlwSOu6kC47MK9f4h-r8c_AY,990
18
- anemoi/utils/commands/__init__.py,sha256=qAybFZPBBQs0dyx7dZ3X5JsLpE90pwrqt1vSV7cqEIw,706
19
- anemoi/utils/commands/config.py,sha256=KEffXZh0ZQfn8t6LXresfd94kDY0gEyulx9Wto5ttW0,824
20
- anemoi/utils/mars/__init__.py,sha256=RAeY8gJ7ZvsPlcIvrQ4fy9xVHs3SphTAPw_XJDtNIKo,1750
21
- anemoi/utils/mars/mars.yaml,sha256=R0dujp75lLA4wCWhPeOQnzJ45WZAYLT8gpx509cBFlc,66
22
- anemoi_utils-0.4.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
23
- anemoi_utils-0.4.1.dist-info/METADATA,sha256=PoA_pFFYtvbx-ygG4g4UumwRLJ8kQx32xIadEE_6iSg,15171
24
- anemoi_utils-0.4.1.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
25
- anemoi_utils-0.4.1.dist-info/entry_points.txt,sha256=LENOkn88xzFQo-V59AKoA_F_cfYQTJYtrNTtf37YgHY,60
26
- anemoi_utils-0.4.1.dist-info/top_level.txt,sha256=DYn8VPs-fNwr7fNH9XIBqeXIwiYYd2E2k5-dUFFqUz0,7
27
- anemoi_utils-0.4.1.dist-info/RECORD,,