anemoi-utils 0.3.1__tar.gz → 0.3.3__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.
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/PKG-INFO +1 -1
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/_version.py +2 -2
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/cli.py +1 -1
- anemoi_utils-0.3.3/src/anemoi/utils/s3.py +57 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/text.py +6 -7
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi_utils.egg-info/PKG-INFO +1 -1
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi_utils.egg-info/SOURCES.txt +1 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/.github/workflows/python-publish.yml +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/.gitignore +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/.pre-commit-config.yaml +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/.readthedocs.yaml +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/LICENSE +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/README.md +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/Makefile +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/_static/logo.png +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/_static/style.css +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/_templates/.gitkeep +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/conf.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/index.rst +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/installing.rst +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/modules/checkpoints.rst +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/modules/config.rst +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/modules/dates.rst +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/modules/grib.rst +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/modules/humanize.rst +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/modules/provenance.rst +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/modules/text.rst +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/docs/requirements.txt +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/pyproject.toml +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/setup.cfg +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/__init__.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/__main__.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/caching.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/checkpoints.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/commands/__init__.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/commands/checkpoint.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/config.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/dates.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/grib.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/humanize.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/mars/__init__.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/mars/mars.yaml +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/provenance.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi/utils/timer.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi_utils.egg-info/dependency_links.txt +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi_utils.egg-info/entry_points.txt +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi_utils.egg-info/requires.txt +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/src/anemoi_utils.egg-info/top_level.txt +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/tests/test_dates.py +0 -0
- {anemoi_utils-0.3.1 → anemoi_utils-0.3.3}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: anemoi-utils
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
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
|
|
@@ -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))
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
"""Text utilities"""
|
|
9
9
|
|
|
10
|
-
import sys
|
|
11
10
|
from collections import defaultdict
|
|
12
11
|
|
|
13
12
|
# https://en.wikipedia.org/wiki/Box-drawing_character
|
|
@@ -143,13 +142,13 @@ class Tree:
|
|
|
143
142
|
self._kids.append(node)
|
|
144
143
|
return node
|
|
145
144
|
|
|
146
|
-
def print(self
|
|
145
|
+
def print(self):
|
|
147
146
|
padding = []
|
|
148
147
|
|
|
149
148
|
while self._factorise():
|
|
150
149
|
pass
|
|
151
150
|
|
|
152
|
-
self._print(padding
|
|
151
|
+
self._print(padding)
|
|
153
152
|
|
|
154
153
|
def _leaves(self, result):
|
|
155
154
|
if self.is_leaf:
|
|
@@ -206,21 +205,21 @@ class Tree:
|
|
|
206
205
|
|
|
207
206
|
return result
|
|
208
207
|
|
|
209
|
-
def _print(self, padding
|
|
208
|
+
def _print(self, padding):
|
|
210
209
|
for i, p in enumerate(padding[:-1]):
|
|
211
210
|
if p == " └":
|
|
212
211
|
padding[i] = " "
|
|
213
212
|
if p == " ├":
|
|
214
213
|
padding[i] = " │"
|
|
215
214
|
if padding:
|
|
216
|
-
print(f"{''.join(padding)}─{self._text}"
|
|
215
|
+
print(f"{''.join(padding)}─{self._text}")
|
|
217
216
|
else:
|
|
218
|
-
print(self._text
|
|
217
|
+
print(self._text)
|
|
219
218
|
padding.append(" ")
|
|
220
219
|
for i, k in enumerate(self._kids):
|
|
221
220
|
sep = " ├" if i < len(self._kids) - 1 else " └"
|
|
222
221
|
padding[-1] = sep
|
|
223
|
-
k._print(padding
|
|
222
|
+
k._print(padding)
|
|
224
223
|
|
|
225
224
|
padding.pop()
|
|
226
225
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: anemoi-utils
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|