anemoi-utils 0.4.8__tar.gz → 0.4.10__tar.gz

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.

Files changed (82) hide show
  1. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.pre-commit-config.yaml +2 -3
  2. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/PKG-INFO +1 -1
  3. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/_version.py +2 -2
  4. anemoi_utils-0.4.10/src/anemoi/utils/commands/requests.py +44 -0
  5. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/config.py +30 -4
  6. anemoi_utils-0.4.10/src/anemoi/utils/logs.py +40 -0
  7. anemoi_utils-0.4.10/src/anemoi/utils/mars/requests.py +22 -0
  8. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/remote/__init__.py +2 -0
  9. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi_utils.egg-info/PKG-INFO +1 -1
  10. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi_utils.egg-info/SOURCES.txt +3 -0
  11. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.gitattributes +0 -0
  12. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.github/CODEOWNERS +0 -0
  13. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.github/ci-hpc-config.yml +0 -0
  14. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.github/workflows/changelog-pr-update.yml +0 -0
  15. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.github/workflows/changelog-release-update.yml +0 -0
  16. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.github/workflows/ci.yml +0 -0
  17. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.github/workflows/label-public-pr.yml +0 -0
  18. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.github/workflows/python-publish.yml +0 -0
  19. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.github/workflows/python-pull-request.yml +0 -0
  20. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.github/workflows/readthedocs-pr-update.yml +0 -0
  21. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.gitignore +0 -0
  22. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/.readthedocs.yaml +0 -0
  23. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/CHANGELOG.md +0 -0
  24. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/CONTRIBUTORS.md +0 -0
  25. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/LICENSE +0 -0
  26. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/README.md +0 -0
  27. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/Makefile +0 -0
  28. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/_static/logo.png +0 -0
  29. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/_static/style.css +0 -0
  30. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/_templates/.gitkeep +0 -0
  31. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/conf.py +0 -0
  32. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/index.rst +0 -0
  33. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/installing.rst +0 -0
  34. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/modules/checkpoints.rst +0 -0
  35. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/modules/config.rst +0 -0
  36. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/modules/dates.rst +0 -0
  37. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/modules/grib.rst +0 -0
  38. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/modules/humanize.rst +0 -0
  39. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/modules/provenance.rst +0 -0
  40. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/modules/s3.rst +0 -0
  41. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/docs/modules/text.rst +0 -0
  42. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/pyproject.toml +0 -0
  43. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/setup.cfg +0 -0
  44. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/__init__.py +0 -0
  45. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/__main__.py +0 -0
  46. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/caching.py +0 -0
  47. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/checkpoints.py +0 -0
  48. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/cli.py +0 -0
  49. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/commands/__init__.py +0 -0
  50. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/commands/config.py +0 -0
  51. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/compatibility.py +0 -0
  52. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/dates.py +0 -0
  53. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/grib.py +0 -0
  54. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/hindcasts.py +0 -0
  55. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/humanize.py +0 -0
  56. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/mars/__init__.py +0 -0
  57. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/mars/mars.yaml +0 -0
  58. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/provenance.py +0 -0
  59. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/registry.py +0 -0
  60. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/remote/s3.py +0 -0
  61. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/remote/ssh.py +0 -0
  62. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/s3.py +0 -0
  63. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/sanitise.py +0 -0
  64. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/sanitize.py +0 -0
  65. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/text.py +0 -0
  66. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi/utils/timer.py +0 -0
  67. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi_utils.egg-info/dependency_links.txt +0 -0
  68. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi_utils.egg-info/entry_points.txt +0 -0
  69. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi_utils.egg-info/requires.txt +0 -0
  70. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/src/anemoi_utils.egg-info/top_level.txt +0 -0
  71. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test-transfer-data/directory/b/c/x +0 -0
  72. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test-transfer-data/directory/b/y +0 -0
  73. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test-transfer-data/directory/exotic filename ;^/"'[=.,#]()/303/252/303/274/303/247/303/262/342/234/205.txt" +0 -0
  74. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test-transfer-data/directory/z +0 -0
  75. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test-transfer-data/file +0 -0
  76. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test_compatibility.py +0 -0
  77. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test_dates.py +0 -0
  78. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test_frequency.py +0 -0
  79. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test_provenance.py +0 -0
  80. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test_remote.py +0 -0
  81. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test_sanetise.py +0 -0
  82. {anemoi_utils-0.4.8 → anemoi_utils-0.4.10}/tests/test_utils.py +0 -0
@@ -40,7 +40,7 @@ repos:
40
40
  - --force-single-line-imports
41
41
  - --profile black
42
42
  - repo: https://github.com/astral-sh/ruff-pre-commit
43
- rev: v0.7.2
43
+ rev: v0.8.1
44
44
  hooks:
45
45
  - id: ruff
46
46
  args:
@@ -64,7 +64,7 @@ repos:
64
64
  hooks:
65
65
  - id: pyproject-fmt
66
66
  - repo: https://github.com/jshwi/docsig # Check docstrings against function sig
67
- rev: v0.64.0
67
+ rev: v0.65.0
68
68
  hooks:
69
69
  - id: docsig
70
70
  args:
@@ -74,7 +74,6 @@ repos:
74
74
  - --check-protected # Check protected methods
75
75
  - --check-class # Check class docstrings
76
76
  - --disable=E113 # Disable empty docstrings
77
- - --summary # Print a summary
78
77
  ci:
79
78
  autoupdate_schedule: monthly
80
79
  ci:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: anemoi-utils
3
- Version: 0.4.8
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
6
  License: Apache License
@@ -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.8'
16
- __version_tuple__ = version_tuple = (0, 4, 8)
15
+ __version__ = version = '0.4.10'
16
+ __version_tuple__ = version_tuple = (0, 4, 10)
@@ -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
@@ -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
@@ -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)
@@ -199,6 +199,8 @@ class Transfer:
199
199
  ):
200
200
  if target == ".":
201
201
  target = os.path.basename(source)
202
+ if not target:
203
+ target = os.path.basename(os.path.dirname(source))
202
204
 
203
205
  temporary_target = {
204
206
  False: None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: anemoi-utils
3
- Version: 0.4.8
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
6
  License: Apache License
@@ -43,6 +43,7 @@ src/anemoi/utils/dates.py
43
43
  src/anemoi/utils/grib.py
44
44
  src/anemoi/utils/hindcasts.py
45
45
  src/anemoi/utils/humanize.py
46
+ src/anemoi/utils/logs.py
46
47
  src/anemoi/utils/provenance.py
47
48
  src/anemoi/utils/registry.py
48
49
  src/anemoi/utils/s3.py
@@ -52,8 +53,10 @@ src/anemoi/utils/text.py
52
53
  src/anemoi/utils/timer.py
53
54
  src/anemoi/utils/commands/__init__.py
54
55
  src/anemoi/utils/commands/config.py
56
+ src/anemoi/utils/commands/requests.py
55
57
  src/anemoi/utils/mars/__init__.py
56
58
  src/anemoi/utils/mars/mars.yaml
59
+ src/anemoi/utils/mars/requests.py
57
60
  src/anemoi/utils/remote/__init__.py
58
61
  src/anemoi/utils/remote/s3.py
59
62
  src/anemoi/utils/remote/ssh.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes