anemoi-utils 0.3.0__tar.gz → 0.3.2__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 (51) hide show
  1. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/.github/workflows/python-publish.yml +1 -3
  2. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/.pre-commit-config.yaml +18 -29
  3. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/PKG-INFO +9 -4
  4. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/pyproject.toml +12 -5
  5. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/_version.py +2 -2
  6. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/cli.py +1 -1
  7. anemoi_utils-0.3.2/src/anemoi/utils/s3.py +57 -0
  8. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi_utils.egg-info/PKG-INFO +9 -4
  9. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi_utils.egg-info/SOURCES.txt +1 -1
  10. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi_utils.egg-info/requires.txt +9 -3
  11. anemoi_utils-0.3.0/tests/requirements.txt +0 -1
  12. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/.gitignore +0 -0
  13. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/.readthedocs.yaml +0 -0
  14. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/LICENSE +0 -0
  15. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/README.md +0 -0
  16. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/Makefile +0 -0
  17. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/_static/logo.png +0 -0
  18. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/_static/style.css +0 -0
  19. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/_templates/.gitkeep +0 -0
  20. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/conf.py +0 -0
  21. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/index.rst +0 -0
  22. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/installing.rst +0 -0
  23. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/modules/checkpoints.rst +0 -0
  24. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/modules/config.rst +0 -0
  25. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/modules/dates.rst +0 -0
  26. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/modules/grib.rst +0 -0
  27. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/modules/humanize.rst +0 -0
  28. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/modules/provenance.rst +0 -0
  29. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/modules/text.rst +0 -0
  30. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/docs/requirements.txt +0 -0
  31. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/setup.cfg +0 -0
  32. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/__init__.py +0 -0
  33. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/__main__.py +0 -0
  34. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/caching.py +0 -0
  35. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/checkpoints.py +0 -0
  36. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/commands/__init__.py +0 -0
  37. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/commands/checkpoint.py +0 -0
  38. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/config.py +0 -0
  39. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/dates.py +0 -0
  40. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/grib.py +0 -0
  41. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/humanize.py +0 -0
  42. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/mars/__init__.py +0 -0
  43. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/mars/mars.yaml +0 -0
  44. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/provenance.py +0 -0
  45. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/text.py +0 -0
  46. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi/utils/timer.py +0 -0
  47. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi_utils.egg-info/dependency_links.txt +0 -0
  48. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi_utils.egg-info/entry_points.txt +0 -0
  49. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/src/anemoi_utils.egg-info/top_level.txt +0 -0
  50. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/tests/test_dates.py +0 -0
  51. {anemoi_utils-0.3.0 → anemoi_utils-0.3.2}/tests/test_utils.py +0 -0
@@ -41,9 +41,7 @@ jobs:
41
41
 
42
42
  - name: Install
43
43
  run: |
44
- pip install pytest
45
- pip install -e .[all]
46
- pip install -r tests/requirements.txt
44
+ pip install -e .[all,tests]
47
45
  pip freeze
48
46
 
49
47
  - name: Tests
@@ -1,17 +1,14 @@
1
1
  repos:
2
-
3
2
  # Empty notebookds
4
3
  - repo: local
5
4
  hooks:
6
- - id: clear-notebooks-output
7
- name: clear-notebooks-output
8
- files: tools/.*\.ipynb$
9
- stages: [commit]
10
- language: python
11
- entry: jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace
12
- additional_dependencies: [jupyter]
13
-
14
-
5
+ - id: clear-notebooks-output
6
+ name: clear-notebooks-output
7
+ files: tools/.*\.ipynb$
8
+ stages: [commit]
9
+ language: python
10
+ entry: jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace
11
+ additional_dependencies: [jupyter]
15
12
  - repo: https://github.com/pre-commit/pre-commit-hooks
16
13
  rev: v4.6.0
17
14
  hooks:
@@ -23,13 +20,11 @@ repos:
23
20
  - id: no-commit-to-branch # Prevent committing to main / master
24
21
  - id: check-added-large-files # Check for large files added to git
25
22
  - id: check-merge-conflict # Check for files that contain merge conflict
26
-
27
23
  - repo: https://github.com/psf/black-pre-commit-mirror
28
24
  rev: 24.4.2
29
25
  hooks:
30
- - id: black
31
- args: [--line-length=120]
32
-
26
+ - id: black
27
+ args: [--line-length=120]
33
28
  - repo: https://github.com/pycqa/isort
34
29
  rev: 5.13.2
35
30
  hooks:
@@ -38,44 +33,38 @@ repos:
38
33
  - -l 120
39
34
  - --force-single-line-imports
40
35
  - --profile black
41
-
42
-
43
36
  - repo: https://github.com/astral-sh/ruff-pre-commit
44
37
  rev: v0.4.6
45
38
  hooks:
46
39
  - id: ruff
47
- exclude: '(dev/.*|.*_)\.py$'
40
+ # Next line if for documenation cod snippets
41
+ exclude: '^(dev/.*|[A-Za-z].*_)\.py$'
48
42
  args:
49
43
  - --line-length=120
50
44
  - --fix
51
45
  - --exit-non-zero-on-fix
52
46
  - --preview
53
-
54
47
  - repo: https://github.com/sphinx-contrib/sphinx-lint
55
48
  rev: v0.9.1
56
49
  hooks:
57
- - id: sphinx-lint
58
-
50
+ - id: sphinx-lint
59
51
  # For now, we use it. But it does not support a lot of sphinx features
60
52
  - repo: https://github.com/dzhu/rstfmt
61
53
  rev: v0.0.14
62
54
  hooks:
63
- - id: rstfmt
64
- exclude: 'cli/.*' # Because we use argparse
65
-
55
+ - id: rstfmt
56
+ exclude: 'cli/.*' # Because we use argparse
66
57
  - repo: https://github.com/b8raoult/pre-commit-docconvert
67
- rev: "0.1.4"
58
+ rev: "0.1.5"
68
59
  hooks:
69
60
  - id: docconvert
70
61
  args: ["numpy"]
71
-
72
62
  - repo: https://github.com/b8raoult/optional-dependencies-all
73
- rev: "0.0.2"
63
+ rev: "0.0.6"
74
64
  hooks:
75
65
  - id: optional-dependencies-all
76
- args: ["--inplace", "--all-key", "all", "--exclude-keys", "dev,docs"]
77
-
66
+ args: ["--inplace", "--exclude-keys=dev,docs,tests", "--group=dev=all,docs,tests"]
78
67
  - repo: https://github.com/tox-dev/pyproject-fmt
79
68
  rev: "2.1.3"
80
69
  hooks:
81
- - id: pyproject-fmt
70
+ - id: pyproject-fmt
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: anemoi-utils
3
- Version: 0.3.0
3
+ Version: 0.3.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
@@ -229,15 +229,18 @@ Requires-Dist: tqdm
229
229
  Provides-Extra: all
230
230
  Requires-Dist: gitpython; extra == "all"
231
231
  Requires-Dist: nvsmi; extra == "all"
232
- Requires-Dist: pyyaml; extra == "all"
233
232
  Requires-Dist: requests; extra == "all"
234
233
  Requires-Dist: termcolor; extra == "all"
235
- Requires-Dist: tomli; extra == "all"
236
- Requires-Dist: tqdm; extra == "all"
237
234
  Provides-Extra: dev
238
235
  Requires-Dist: gitpython; extra == "dev"
236
+ Requires-Dist: nbsphinx; extra == "dev"
239
237
  Requires-Dist: nvsmi; extra == "dev"
238
+ Requires-Dist: pandoc; extra == "dev"
239
+ Requires-Dist: pytest; extra == "dev"
240
240
  Requires-Dist: requests; extra == "dev"
241
+ Requires-Dist: sphinx; extra == "dev"
242
+ Requires-Dist: sphinx-argparse; extra == "dev"
243
+ Requires-Dist: sphinx-rtd-theme; extra == "dev"
241
244
  Requires-Dist: termcolor; extra == "dev"
242
245
  Requires-Dist: tomli; extra == "dev"
243
246
  Provides-Extra: docs
@@ -254,5 +257,7 @@ Requires-Dist: requests; extra == "grib"
254
257
  Provides-Extra: provenance
255
258
  Requires-Dist: gitpython; extra == "provenance"
256
259
  Requires-Dist: nvsmi; extra == "provenance"
260
+ Provides-Extra: tests
261
+ Requires-Dist: pytest; extra == "tests"
257
262
  Provides-Extra: text
258
263
  Requires-Dist: termcolor; extra == "text"
@@ -57,18 +57,21 @@ dependencies = [
57
57
  optional-dependencies.all = [
58
58
  "gitpython",
59
59
  "nvsmi",
60
- "pyyaml",
61
60
  "requests",
62
61
  "termcolor",
63
- "tomli",
64
- "tqdm",
65
62
  ]
66
63
  optional-dependencies.dev = [
67
64
  "gitpython",
65
+ "nbsphinx",
68
66
  "nvsmi",
67
+ "pandoc",
68
+ "pytest",
69
69
  "requests",
70
+ "sphinx",
71
+ "sphinx-argparse",
72
+ "sphinx-rtd-theme",
70
73
  "termcolor",
71
- "tomli", # Only needed before 3.11
74
+ "tomli",
72
75
  ]
73
76
  # Loaded by read-the-docs
74
77
  # `pip install .[docs]`
@@ -80,7 +83,7 @@ optional-dependencies.docs = [
80
83
  "sphinx-argparse",
81
84
  "sphinx-rtd-theme",
82
85
  "termcolor",
83
- "tomli", # Only needed before 3.11
86
+ "tomli",
84
87
  ]
85
88
  optional-dependencies.grib = [
86
89
  "requests",
@@ -90,6 +93,10 @@ optional-dependencies.provenance = [
90
93
  "gitpython",
91
94
  "nvsmi",
92
95
  ]
96
+ optional-dependencies.tests = [
97
+ "pytest",
98
+ ]
99
+
93
100
  optional-dependencies.text = [
94
101
  "termcolor",
95
102
  ]
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.3.0'
16
- __version_tuple__ = version_tuple = (0, 3, 0)
15
+ __version__ = version = '0.3.2'
16
+ __version_tuple__ = version_tuple = (0, 3, 2)
@@ -41,7 +41,7 @@ def make_parser(description, commands):
41
41
 
42
42
  subparsers = parser.add_subparsers(help="commands:", dest="command")
43
43
  for name, command in commands.items():
44
- command_parser = subparsers.add_parser(name, help=command.__doc__)
44
+ command_parser = subparsers.add_parser(name, description=command.__doc__, help=command.__doc__)
45
45
  command.add_arguments(command_parser)
46
46
 
47
47
  return parser
@@ -0,0 +1,57 @@
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
+ import logging
8
+ import os
9
+ from contextlib import closing
10
+
11
+ import boto3
12
+ import tqdm
13
+
14
+ LOG = logging.getLogger(__name__)
15
+
16
+
17
+ def upload(source, target, overwrite=False, ignore_existing=False):
18
+ # https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html
19
+ assert target.startswith("s3://")
20
+
21
+ _, _, bucket, key = target.split("/", 3)
22
+
23
+ LOG.info(f"Uploading {source} to {target}")
24
+ s3_client = boto3.client("s3")
25
+
26
+ if not overwrite:
27
+ results = s3_client.list_objects(Bucket=bucket, Prefix=key)
28
+ if results.get("Contents"):
29
+ if ignore_existing:
30
+ LOG.info(f"{target} already exists, skipping")
31
+ return
32
+ else:
33
+ raise ValueError(f"{target} already exists, use --overwrite to replace")
34
+
35
+ size = os.path.getsize(source)
36
+ with closing(tqdm.tqdm(total=size, unit="B", unit_scale=True)) as t:
37
+ s3_client.upload_file(source, bucket, key, Callback=lambda x: t.update(x))
38
+
39
+ LOG.info(f"{target} is ready")
40
+
41
+
42
+ def download(source, target, overwrite=False):
43
+ assert source.startswith("s3://")
44
+
45
+ _, _, bucket, key = source.split("/", 3)
46
+
47
+ s3 = boto3.client("s3")
48
+ response = s3.head_object(Bucket=bucket, Key=key)
49
+ size = response["ContentLength"]
50
+
51
+ if not overwrite:
52
+ if os.path.exists(source) and os.path.getsize(source) == size:
53
+ LOG.info(f"{source} already exists, skipping")
54
+ return
55
+
56
+ with closing(tqdm.tqdm(total=size, unit="B", unit_scale=True)) as t:
57
+ s3.download_file(bucket, key, target, Callback=lambda x: t.update(x))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: anemoi-utils
3
- Version: 0.3.0
3
+ Version: 0.3.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
@@ -229,15 +229,18 @@ Requires-Dist: tqdm
229
229
  Provides-Extra: all
230
230
  Requires-Dist: gitpython; extra == "all"
231
231
  Requires-Dist: nvsmi; extra == "all"
232
- Requires-Dist: pyyaml; extra == "all"
233
232
  Requires-Dist: requests; extra == "all"
234
233
  Requires-Dist: termcolor; extra == "all"
235
- Requires-Dist: tomli; extra == "all"
236
- Requires-Dist: tqdm; extra == "all"
237
234
  Provides-Extra: dev
238
235
  Requires-Dist: gitpython; extra == "dev"
236
+ Requires-Dist: nbsphinx; extra == "dev"
239
237
  Requires-Dist: nvsmi; extra == "dev"
238
+ Requires-Dist: pandoc; extra == "dev"
239
+ Requires-Dist: pytest; extra == "dev"
240
240
  Requires-Dist: requests; extra == "dev"
241
+ Requires-Dist: sphinx; extra == "dev"
242
+ Requires-Dist: sphinx-argparse; extra == "dev"
243
+ Requires-Dist: sphinx-rtd-theme; extra == "dev"
241
244
  Requires-Dist: termcolor; extra == "dev"
242
245
  Requires-Dist: tomli; extra == "dev"
243
246
  Provides-Extra: docs
@@ -254,5 +257,7 @@ Requires-Dist: requests; extra == "grib"
254
257
  Provides-Extra: provenance
255
258
  Requires-Dist: gitpython; extra == "provenance"
256
259
  Requires-Dist: nvsmi; extra == "provenance"
260
+ Provides-Extra: tests
261
+ Requires-Dist: pytest; extra == "tests"
257
262
  Provides-Extra: text
258
263
  Requires-Dist: termcolor; extra == "text"
@@ -31,6 +31,7 @@ src/anemoi/utils/dates.py
31
31
  src/anemoi/utils/grib.py
32
32
  src/anemoi/utils/humanize.py
33
33
  src/anemoi/utils/provenance.py
34
+ src/anemoi/utils/s3.py
34
35
  src/anemoi/utils/text.py
35
36
  src/anemoi/utils/timer.py
36
37
  src/anemoi/utils/commands/__init__.py
@@ -43,6 +44,5 @@ src/anemoi_utils.egg-info/dependency_links.txt
43
44
  src/anemoi_utils.egg-info/entry_points.txt
44
45
  src/anemoi_utils.egg-info/requires.txt
45
46
  src/anemoi_utils.egg-info/top_level.txt
46
- tests/requirements.txt
47
47
  tests/test_dates.py
48
48
  tests/test_utils.py
@@ -5,16 +5,19 @@ tqdm
5
5
  [all]
6
6
  gitpython
7
7
  nvsmi
8
- pyyaml
9
8
  requests
10
9
  termcolor
11
- tomli
12
- tqdm
13
10
 
14
11
  [dev]
15
12
  gitpython
13
+ nbsphinx
16
14
  nvsmi
15
+ pandoc
16
+ pytest
17
17
  requests
18
+ sphinx
19
+ sphinx-argparse
20
+ sphinx-rtd-theme
18
21
  termcolor
19
22
  tomli
20
23
 
@@ -35,5 +38,8 @@ requests
35
38
  gitpython
36
39
  nvsmi
37
40
 
41
+ [tests]
42
+ pytest
43
+
38
44
  [text]
39
45
  termcolor
@@ -1 +0,0 @@
1
- # Empty for now
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes