ansys-hps-data-transfer-client 0.4.dev0__tar.gz → 0.5.dev0__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.
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/PKG-INFO +20 -25
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/pyproject.toml +25 -26
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/__init__.py +1 -1
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/__version__.py +1 -1
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/api/__init__.py +1 -1
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/api/api.py +22 -17
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/api/async_api.py +20 -18
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/api/handler.py +33 -21
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/api/retry.py +1 -1
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/authenticate.py +1 -1
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/binary.py +56 -16
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/client.py +143 -11
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/exceptions.py +1 -1
- ansys_hps_data_transfer_client-0.4.dev0/src/ansys/hps/data_transfer/client/models/storage.py → ansys_hps_data_transfer_client-0.5.dev0/src/ansys/hps/data_transfer/client/models/__init__.py +3 -9
- ansys_hps_data_transfer_client-0.5.dev0/src/ansys/hps/data_transfer/client/models/models.py +527 -0
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/token.py +1 -1
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/utils/__init__.py +1 -1
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/utils/jitter.py +1 -1
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/src/ansys/hps/data_transfer/client/utils/otel_config.py +1 -1
- ansys_hps_data_transfer_client-0.4.dev0/src/ansys/hps/data_transfer/client/models/__init__.py +0 -31
- ansys_hps_data_transfer_client-0.4.dev0/src/ansys/hps/data_transfer/client/models/common.py +0 -37
- ansys_hps_data_transfer_client-0.4.dev0/src/ansys/hps/data_transfer/client/models/core.py +0 -31
- ansys_hps_data_transfer_client-0.4.dev0/src/ansys/hps/data_transfer/client/models/metadata.py +0 -45
- ansys_hps_data_transfer_client-0.4.dev0/src/ansys/hps/data_transfer/client/models/msg.py +0 -165
- ansys_hps_data_transfer_client-0.4.dev0/src/ansys/hps/data_transfer/client/models/ops.py +0 -62
- ansys_hps_data_transfer_client-0.4.dev0/src/ansys/hps/data_transfer/client/models/permissions.py +0 -67
- ansys_hps_data_transfer_client-0.4.dev0/src/ansys/hps/data_transfer/client/models/rest.py +0 -52
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/LICENSE +0 -0
- {ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/README.rst +0 -0
{ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: ansys-hps-data-transfer-client
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.dev0
|
|
4
4
|
Summary: Python client library for hps data transfer service
|
|
5
5
|
Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
6
6
|
Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
@@ -13,51 +13,46 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
15
|
Requires-Dist: pydantic>=2.7.1
|
|
16
|
-
Requires-Dist: httpx>=0.27.0
|
|
16
|
+
Requires-Dist: httpx>=0.27.0
|
|
17
17
|
Requires-Dist: backoff>=2.2.1
|
|
18
|
-
Requires-Dist:
|
|
18
|
+
Requires-Dist: humanize>=4.8.0
|
|
19
19
|
Requires-Dist: requests>=2.21.0
|
|
20
20
|
Requires-Dist: portend>=3.2.0
|
|
21
21
|
Requires-Dist: filelock>=3.14.0
|
|
22
22
|
Requires-Dist: psutil>=5.9.1
|
|
23
23
|
Requires-Dist: asyncio-atexit>=1.0.0
|
|
24
|
-
Requires-Dist: build==1.
|
|
25
|
-
Requires-Dist: twine==6.
|
|
24
|
+
Requires-Dist: build==1.4.2 ; extra == "build"
|
|
25
|
+
Requires-Dist: twine==6.2.0 ; extra == "build"
|
|
26
26
|
Requires-Dist: wheel ; extra == "build"
|
|
27
|
-
Requires-Dist: datamodel-code-generator==0.
|
|
28
|
-
Requires-Dist: pre-commit==4.
|
|
27
|
+
Requires-Dist: datamodel-code-generator==0.55.0 ; extra == "build"
|
|
28
|
+
Requires-Dist: pre-commit==4.5.1 ; extra == "build"
|
|
29
29
|
Requires-Dist: importlib_metadata>=7.0 ; extra == "build"
|
|
30
|
-
Requires-Dist: ansys-sphinx-theme==1.
|
|
30
|
+
Requires-Dist: ansys-sphinx-theme==1.7.2 ; extra == "doc"
|
|
31
31
|
Requires-Dist: autodoc_pydantic==2.2.0 ; extra == "doc"
|
|
32
|
-
Requires-Dist:
|
|
33
|
-
Requires-Dist: nbsphinx==0.9.7 ; extra == "doc"
|
|
34
|
-
Requires-Dist: numpydoc==1.8.0 ; extra == "doc"
|
|
32
|
+
Requires-Dist: numpydoc==1.10.0 ; extra == "doc"
|
|
35
33
|
Requires-Dist: Sphinx==8.1.3 ; extra == "doc"
|
|
36
|
-
Requires-Dist: sphinx-autoapi==3.
|
|
37
|
-
Requires-Dist: sphinx-autodoc-typehints==3.0.1 ; extra == "doc"
|
|
38
|
-
Requires-Dist: sphinxcontrib-globalsubs==0.1.2 ; extra == "doc"
|
|
39
|
-
Requires-Dist: sphinxcontrib-httpdomain==1.8.1 ; extra == "doc"
|
|
34
|
+
Requires-Dist: sphinx-autoapi==3.8.0 ; extra == "doc"
|
|
40
35
|
Requires-Dist: sphinx-copybutton==0.5.2 ; extra == "doc"
|
|
41
36
|
Requires-Dist: sphinx_design==0.6.1 ; extra == "doc"
|
|
42
37
|
Requires-Dist: sphinx-jinja==2.0.2 ; extra == "doc"
|
|
43
|
-
Requires-Dist:
|
|
44
|
-
Requires-Dist:
|
|
45
|
-
Requires-Dist:
|
|
46
|
-
Requires-Dist: pytest==
|
|
47
|
-
Requires-Dist: pytest-cov==6.2.1 ; extra == "tests"
|
|
38
|
+
Requires-Dist: sphinx-gallery==0.20.0 ; extra == "doc"
|
|
39
|
+
Requires-Dist: typer>=0.9.0 ; extra == "example"
|
|
40
|
+
Requires-Dist: pytest==9.0.2 ; extra == "tests"
|
|
41
|
+
Requires-Dist: pytest-cov==7.1.0 ; extra == "tests"
|
|
48
42
|
Requires-Dist: pytest-timeout==2.4.0 ; extra == "tests"
|
|
49
|
-
Requires-Dist: pytest-mock-resources[redis]==2.12.
|
|
50
|
-
Requires-Dist: pytest-rerunfailures==
|
|
51
|
-
Requires-Dist: pytest-asyncio==1.
|
|
52
|
-
Requires-Dist: python-keycloak==
|
|
43
|
+
Requires-Dist: pytest-mock-resources[redis]==2.12.4 ; extra == "tests"
|
|
44
|
+
Requires-Dist: pytest-rerunfailures==16.1 ; extra == "tests"
|
|
45
|
+
Requires-Dist: pytest-asyncio==1.3.0 ; extra == "tests"
|
|
46
|
+
Requires-Dist: python-keycloak==7.1.1 ; extra == "tests"
|
|
53
47
|
Requires-Dist: python-slugify>=8.0.4 ; extra == "tests"
|
|
54
|
-
Requires-Dist: tox==4.
|
|
48
|
+
Requires-Dist: tox==4.50.3 ; extra == "tests"
|
|
55
49
|
Project-URL: Documentation, https://data-transfer.hps.docs.pyansys.com
|
|
56
50
|
Project-URL: Homepage, https://github.com/ansys/pyhps-data-transfer/
|
|
57
51
|
Project-URL: Source, https://github.com/ansys/pyhps-data-transfer/
|
|
58
52
|
Project-URL: Tracker, https://github.com/ansys/pyhps-data-transfer/issues
|
|
59
53
|
Provides-Extra: build
|
|
60
54
|
Provides-Extra: doc
|
|
55
|
+
Provides-Extra: example
|
|
61
56
|
Provides-Extra: tests
|
|
62
57
|
|
|
63
58
|
PyHPS Data Transfer
|
{ansys_hps_data_transfer_client-0.4.dev0 → ansys_hps_data_transfer_client-0.5.dev0}/pyproject.toml
RENAMED
|
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
|
|
|
5
5
|
[project]
|
|
6
6
|
# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
|
|
7
7
|
name = "ansys-hps-data-transfer-client"
|
|
8
|
-
version = "0.
|
|
8
|
+
version = "0.5.dev0"
|
|
9
9
|
description = "Python client library for hps data transfer service"
|
|
10
10
|
readme = "README.rst"
|
|
11
11
|
requires-python = ">=3.10,<4.0"
|
|
@@ -27,9 +27,9 @@ classifiers = [
|
|
|
27
27
|
]
|
|
28
28
|
dependencies = [
|
|
29
29
|
"pydantic>=2.7.1",
|
|
30
|
-
"httpx>=0.27.0
|
|
30
|
+
"httpx>=0.27.0",
|
|
31
31
|
"backoff>=2.2.1",
|
|
32
|
-
"
|
|
32
|
+
"humanize>=4.8.0",
|
|
33
33
|
"requests>=2.21.0",
|
|
34
34
|
"portend>=3.2.0",
|
|
35
35
|
"filelock>=3.14.0",
|
|
@@ -39,41 +39,38 @@ dependencies = [
|
|
|
39
39
|
|
|
40
40
|
[project.optional-dependencies]
|
|
41
41
|
tests = [
|
|
42
|
-
"pytest==
|
|
43
|
-
"pytest-cov==
|
|
42
|
+
"pytest==9.0.2",
|
|
43
|
+
"pytest-cov==7.1.0",
|
|
44
44
|
"pytest-timeout==2.4.0",
|
|
45
|
-
"pytest-mock-resources[redis]==2.12.
|
|
46
|
-
"pytest-rerunfailures==
|
|
47
|
-
"pytest-asyncio==1.
|
|
48
|
-
"python-keycloak==
|
|
45
|
+
"pytest-mock-resources[redis]==2.12.4",
|
|
46
|
+
"pytest-rerunfailures==16.1",
|
|
47
|
+
"pytest-asyncio==1.3.0",
|
|
48
|
+
"python-keycloak==7.1.1",
|
|
49
49
|
"python-slugify>=8.0.4",
|
|
50
|
-
"tox==4.
|
|
50
|
+
"tox==4.50.3",
|
|
51
51
|
]
|
|
52
52
|
doc = [
|
|
53
|
-
"ansys-sphinx-theme==1.
|
|
53
|
+
"ansys-sphinx-theme==1.7.2",
|
|
54
54
|
"autodoc_pydantic==2.2.0",
|
|
55
|
-
"
|
|
56
|
-
"nbsphinx==0.9.7",
|
|
57
|
-
"numpydoc==1.8.0",
|
|
55
|
+
"numpydoc==1.10.0",
|
|
58
56
|
"Sphinx==8.1.3",
|
|
59
|
-
"sphinx-autoapi==3.
|
|
60
|
-
"sphinx-autodoc-typehints==3.0.1",
|
|
61
|
-
"sphinxcontrib-globalsubs==0.1.2",
|
|
62
|
-
"sphinxcontrib-httpdomain==1.8.1",
|
|
57
|
+
"sphinx-autoapi==3.8.0",
|
|
63
58
|
"sphinx-copybutton==0.5.2",
|
|
64
59
|
"sphinx_design==0.6.1",
|
|
65
60
|
"sphinx-jinja==2.0.2",
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
"sphinx-gallery==0.20.0",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
example = [
|
|
65
|
+
"typer>=0.9.0",
|
|
69
66
|
]
|
|
70
67
|
|
|
71
68
|
build = [
|
|
72
|
-
"build==1.
|
|
73
|
-
"twine==6.
|
|
69
|
+
"build==1.4.2",
|
|
70
|
+
"twine==6.2.0",
|
|
74
71
|
"wheel",
|
|
75
|
-
"datamodel-code-generator==0.
|
|
76
|
-
"pre-commit==4.
|
|
72
|
+
"datamodel-code-generator==0.55.0",
|
|
73
|
+
"pre-commit==4.5.1",
|
|
77
74
|
"importlib_metadata>=7.0",
|
|
78
75
|
]
|
|
79
76
|
|
|
@@ -144,10 +141,12 @@ ignore = []
|
|
|
144
141
|
[tool.ruff.lint.per-file-ignores]
|
|
145
142
|
"__init__.py" = ["F401"]
|
|
146
143
|
# ignore docstring requirements for module because it is autogenerated
|
|
147
|
-
|
|
144
|
+
# ignore line length for models because it is autogenerated
|
|
145
|
+
"src/ansys/hps/data_transfer/client/models/*.py" = ["D", "F821", "E501"]
|
|
148
146
|
# ignore docstring requirements amd equility comparisons issues for tests
|
|
149
147
|
"tests/**/*.py" = ["D", "PT011", "E712"]
|
|
150
148
|
|
|
149
|
+
|
|
151
150
|
[tool.ruff.lint.isort]
|
|
152
151
|
combine-as-imports = true
|
|
153
152
|
force-sort-within-sections = true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2022 -
|
|
1
|
+
# Copyright (C) 2022 - 2026 ANSYS, Inc. and/or its affiliates.
|
|
2
2
|
# SPDX-License-Identifier: MIT
|
|
3
3
|
#
|
|
4
4
|
#
|
|
@@ -36,20 +36,22 @@ import backoff
|
|
|
36
36
|
|
|
37
37
|
from ..client import Client
|
|
38
38
|
from ..exceptions import TimeoutError
|
|
39
|
-
from ..models
|
|
40
|
-
from ..models.msg import (
|
|
39
|
+
from ..models import (
|
|
41
40
|
CheckPermissionsResponse,
|
|
41
|
+
DataAssignment,
|
|
42
42
|
GetPermissionsResponse,
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
Operation,
|
|
44
|
+
OperationIdResponse,
|
|
45
|
+
OperationsResponse,
|
|
46
|
+
OperationState,
|
|
47
|
+
RoleAssignment,
|
|
48
|
+
RoleQuery,
|
|
45
49
|
SetMetadataRequest,
|
|
46
50
|
SrcDst,
|
|
47
|
-
|
|
51
|
+
StatusResponse,
|
|
48
52
|
StorageConfigResponse,
|
|
49
53
|
StoragePath,
|
|
50
54
|
)
|
|
51
|
-
from ..models.ops import Operation, OperationState
|
|
52
|
-
from ..models.permissions import RoleAssignment, RoleQuery
|
|
53
55
|
from ..utils.jitter import get_expo_backoff
|
|
54
56
|
from .handler import WaitHandler
|
|
55
57
|
from .retry import retry
|
|
@@ -89,7 +91,7 @@ class DataTransferApi:
|
|
|
89
91
|
|
|
90
92
|
resp = self.client.session.get(url)
|
|
91
93
|
json = resp.json()
|
|
92
|
-
s =
|
|
94
|
+
s = StatusResponse(**json)
|
|
93
95
|
if wait and not s.ready:
|
|
94
96
|
_sleep()
|
|
95
97
|
continue
|
|
@@ -184,7 +186,7 @@ class DataTransferApi:
|
|
|
184
186
|
payload = {"operations": [operation.model_dump(mode=self.dump_mode) for operation in operations]}
|
|
185
187
|
resp = self.client.session.post(url, json=payload)
|
|
186
188
|
json = resp.json()
|
|
187
|
-
r =
|
|
189
|
+
r = OperationIdResponse(**json)
|
|
188
190
|
return r
|
|
189
191
|
|
|
190
192
|
def _operations(self, ids: builtins.list[str], expand: bool = False):
|
|
@@ -192,9 +194,9 @@ class DataTransferApi:
|
|
|
192
194
|
params = {"ids": ids}
|
|
193
195
|
if expand:
|
|
194
196
|
params["expand"] = "true"
|
|
195
|
-
resp = self.client.session.get(url, params=params)
|
|
197
|
+
resp = self.client.session.get(url, params=params, timeout=1)
|
|
196
198
|
json = resp.json()
|
|
197
|
-
return
|
|
199
|
+
return OperationsResponse(**json).operations
|
|
198
200
|
|
|
199
201
|
@retry()
|
|
200
202
|
def check_permissions(self, permissions: builtins.list[RoleAssignment]):
|
|
@@ -261,7 +263,7 @@ class DataTransferApi:
|
|
|
261
263
|
payload = {"paths": paths}
|
|
262
264
|
resp = self.client.session.post(url, json=payload)
|
|
263
265
|
json = resp.json()
|
|
264
|
-
return
|
|
266
|
+
return OperationIdResponse(**json)
|
|
265
267
|
|
|
266
268
|
@retry()
|
|
267
269
|
def set_metadata(self, asgs: dict[str | StoragePath, DataAssignment]):
|
|
@@ -277,11 +279,11 @@ class DataTransferApi:
|
|
|
277
279
|
req = SetMetadataRequest(metadata=d)
|
|
278
280
|
resp = self.client.session.post(url, json=req.model_dump(mode=self.dump_mode))
|
|
279
281
|
json = resp.json()
|
|
280
|
-
return
|
|
282
|
+
return OperationIdResponse(**json)
|
|
281
283
|
|
|
282
284
|
def wait_for(
|
|
283
285
|
self,
|
|
284
|
-
operation_ids: builtins.list[str | Operation |
|
|
286
|
+
operation_ids: builtins.list[str | Operation | OperationIdResponse],
|
|
285
287
|
timeout: float | None = None,
|
|
286
288
|
interval: float = 0.1,
|
|
287
289
|
cap: float = 2.0,
|
|
@@ -292,7 +294,7 @@ class DataTransferApi:
|
|
|
292
294
|
|
|
293
295
|
Parameters
|
|
294
296
|
----------
|
|
295
|
-
operation_ids: List[str | Operation |
|
|
297
|
+
operation_ids: List[str | Operation | OperationIdResponse]
|
|
296
298
|
List of operation ids.
|
|
297
299
|
timeout: float | None
|
|
298
300
|
Timeout in seconds. Default is None.
|
|
@@ -310,7 +312,7 @@ class DataTransferApi:
|
|
|
310
312
|
|
|
311
313
|
if not isinstance(operation_ids, list):
|
|
312
314
|
operation_ids = [operation_ids]
|
|
313
|
-
operation_ids = [op.id if isinstance(op, Operation |
|
|
315
|
+
operation_ids = [op.id if isinstance(op, Operation | OperationIdResponse) else op for op in operation_ids]
|
|
314
316
|
start = time.time()
|
|
315
317
|
attempt = 0
|
|
316
318
|
while True:
|
|
@@ -326,11 +328,14 @@ class DataTransferApi:
|
|
|
326
328
|
log.debug(traceback.format_exc())
|
|
327
329
|
|
|
328
330
|
if all(op.state in [OperationState.Succeeded, OperationState.Failed] for op in ops):
|
|
331
|
+
log.debug("All operations have completed.")
|
|
329
332
|
break
|
|
330
333
|
except Exception as e:
|
|
331
334
|
log.debug(f"Error getting operations: {e}")
|
|
332
335
|
if raise_on_error:
|
|
333
336
|
raise
|
|
337
|
+
else:
|
|
338
|
+
break
|
|
334
339
|
|
|
335
340
|
if timeout is not None and (time.time() - start) > timeout:
|
|
336
341
|
raise TimeoutError("Timeout waiting for operations to complete")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2022 -
|
|
1
|
+
# Copyright (C) 2022 - 2026 ANSYS, Inc. and/or its affiliates.
|
|
2
2
|
# SPDX-License-Identifier: MIT
|
|
3
3
|
#
|
|
4
4
|
#
|
|
@@ -35,24 +35,26 @@ import time
|
|
|
35
35
|
import traceback
|
|
36
36
|
|
|
37
37
|
import backoff
|
|
38
|
-
import
|
|
38
|
+
import humanize as hz
|
|
39
39
|
|
|
40
40
|
from ..client import AsyncClient
|
|
41
41
|
from ..exceptions import TimeoutError
|
|
42
|
-
from ..models
|
|
43
|
-
from ..models.msg import (
|
|
42
|
+
from ..models import (
|
|
44
43
|
CheckPermissionsResponse,
|
|
44
|
+
DataAssignment,
|
|
45
45
|
GetPermissionsResponse,
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
Operation,
|
|
47
|
+
OperationIdResponse,
|
|
48
|
+
OperationsResponse,
|
|
49
|
+
OperationState,
|
|
50
|
+
RoleAssignment,
|
|
51
|
+
RoleQuery,
|
|
48
52
|
SetMetadataRequest,
|
|
49
53
|
SrcDst,
|
|
50
|
-
|
|
54
|
+
StatusResponse,
|
|
51
55
|
StorageConfigResponse,
|
|
52
56
|
StoragePath,
|
|
53
57
|
)
|
|
54
|
-
from ..models.ops import Operation, OperationState
|
|
55
|
-
from ..models.permissions import RoleAssignment, RoleQuery
|
|
56
58
|
from ..utils.jitter import get_expo_backoff
|
|
57
59
|
from .handler import AsyncWaitHandler
|
|
58
60
|
from .retry import retry
|
|
@@ -87,7 +89,7 @@ class AsyncDataTransferApi:
|
|
|
87
89
|
|
|
88
90
|
resp = await self.client.session.get(url)
|
|
89
91
|
json = resp.json()
|
|
90
|
-
s =
|
|
92
|
+
s = StatusResponse(**json)
|
|
91
93
|
if wait and not s.ready:
|
|
92
94
|
await _sleep()
|
|
93
95
|
continue
|
|
@@ -141,7 +143,7 @@ class AsyncDataTransferApi:
|
|
|
141
143
|
payload = {"operations": [operation.model_dump(mode=self.dump_mode) for operation in operations]}
|
|
142
144
|
resp = await self.client.session.post(url, json=payload)
|
|
143
145
|
json = resp.json()
|
|
144
|
-
return
|
|
146
|
+
return OperationIdResponse(**json)
|
|
145
147
|
|
|
146
148
|
async def _operations(self, ids: builtins.list[str], expand: bool = False):
|
|
147
149
|
url = "/operations"
|
|
@@ -150,7 +152,7 @@ class AsyncDataTransferApi:
|
|
|
150
152
|
params["expand"] = "true"
|
|
151
153
|
resp = await self.client.session.get(url, params=params)
|
|
152
154
|
json = resp.json()
|
|
153
|
-
return
|
|
155
|
+
return OperationsResponse(**json).operations
|
|
154
156
|
|
|
155
157
|
@retry()
|
|
156
158
|
async def check_permissions(self, permissions: builtins.list[RoleAssignment]):
|
|
@@ -192,7 +194,7 @@ class AsyncDataTransferApi:
|
|
|
192
194
|
payload = {"paths": paths}
|
|
193
195
|
resp = await self.client.session.post(url, json=payload)
|
|
194
196
|
json = resp.json()
|
|
195
|
-
return
|
|
197
|
+
return OperationIdResponse(**json)
|
|
196
198
|
|
|
197
199
|
@retry()
|
|
198
200
|
async def set_metadata(self, asgs: dict[str | StoragePath, DataAssignment]):
|
|
@@ -202,7 +204,7 @@ class AsyncDataTransferApi:
|
|
|
202
204
|
req = SetMetadataRequest(metadata=d)
|
|
203
205
|
resp = await self.client.session.post(url, json=req.model_dump(mode=self.dump_mode))
|
|
204
206
|
json = resp.json()
|
|
205
|
-
return
|
|
207
|
+
return OperationIdResponse(**json)
|
|
206
208
|
|
|
207
209
|
async def wait_for(
|
|
208
210
|
self,
|
|
@@ -235,7 +237,7 @@ class AsyncDataTransferApi:
|
|
|
235
237
|
|
|
236
238
|
if not isinstance(operation_ids, list):
|
|
237
239
|
operation_ids = [operation_ids]
|
|
238
|
-
operation_ids = [op.id if isinstance(op, Operation |
|
|
240
|
+
operation_ids = [op.id if isinstance(op, Operation | OperationIdResponse) else op for op in operation_ids]
|
|
239
241
|
start = time.time()
|
|
240
242
|
attempt = 0
|
|
241
243
|
op_str = textwrap.wrap(", ".join(operation_ids), width=60, placeholder="...")
|
|
@@ -258,16 +260,16 @@ class AsyncDataTransferApi:
|
|
|
258
260
|
log.debug(f"Error getting operations: {e}")
|
|
259
261
|
if raise_on_error:
|
|
260
262
|
raise
|
|
263
|
+
else:
|
|
264
|
+
break
|
|
261
265
|
|
|
262
266
|
if timeout is not None and (time.time() - start) > timeout:
|
|
263
267
|
raise TimeoutError("Timeout waiting for operations to complete")
|
|
264
268
|
|
|
265
269
|
# TODO: Adjust based on transfer speed and file size
|
|
266
270
|
duration = get_expo_backoff(interval, attempts=attempt, cap=cap, jitter=True)
|
|
267
|
-
# if self.client.binary_config.debug:
|
|
268
|
-
# log.debug(f"Next check in {hf.format_timespan(duration)} ...")
|
|
269
271
|
await asyncio.sleep(duration)
|
|
270
272
|
|
|
271
|
-
duration =
|
|
273
|
+
duration = hz.naturalsize(time.time() - start)
|
|
272
274
|
log.debug(f"Operations completed after {duration}: {op_str}")
|
|
273
275
|
return ops
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2025 ANSYS, Inc. and/or its affiliates.
|
|
1
|
+
# Copyright (C) 2025 - 2026 ANSYS, Inc. and/or its affiliates.
|
|
2
2
|
# SPDX-License-Identifier: MIT
|
|
3
3
|
#
|
|
4
4
|
#
|
|
@@ -26,10 +26,9 @@ import datetime
|
|
|
26
26
|
import logging
|
|
27
27
|
import time
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
import humanfriendly as hf
|
|
29
|
+
import humanize as hz
|
|
31
30
|
|
|
32
|
-
from ..models
|
|
31
|
+
from ..models import Operation, OperationState
|
|
33
32
|
|
|
34
33
|
log = logging.getLogger(__name__)
|
|
35
34
|
|
|
@@ -48,8 +47,9 @@ class WaitHandler:
|
|
|
48
47
|
"""Initializes the WaitHandler class object."""
|
|
49
48
|
self.start = time.time()
|
|
50
49
|
self.report_threshold = 2.0 # seconds
|
|
51
|
-
self.min_progress_interval =
|
|
52
|
-
self.last_progress =
|
|
50
|
+
self.min_progress_interval = 15.0 # seconds
|
|
51
|
+
self.last_progress = {}
|
|
52
|
+
self.completed_ids = []
|
|
53
53
|
|
|
54
54
|
def __call__(self, ops: list[Operation]):
|
|
55
55
|
"""Handle operations after they are fetched."""
|
|
@@ -59,10 +59,17 @@ class WaitHandler:
|
|
|
59
59
|
# so_far = time.time() - self.start
|
|
60
60
|
num_running = 0
|
|
61
61
|
for op in ops:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
if op.children_detail is not None and self.Meta.expand_group:
|
|
63
|
+
for ch in op.children_detail or []:
|
|
64
|
+
# For ops with lots of children, avoid logging completed children on every loop iteration
|
|
65
|
+
# If there are 29 small files and 1 large file in the group, we dont want to log 29 files
|
|
66
|
+
# are done 1000 times while the large file copies.
|
|
67
|
+
if ch.id not in self.completed_ids:
|
|
68
|
+
self._log_op(logging.DEBUG, ch)
|
|
69
|
+
if ch.state not in self.final:
|
|
70
|
+
num_running += 1
|
|
71
|
+
elif ch.id not in self.completed_ids:
|
|
72
|
+
self.completed_ids.append(ch.id)
|
|
66
73
|
|
|
67
74
|
if op.state not in self.final:
|
|
68
75
|
num_running += 1
|
|
@@ -70,35 +77,40 @@ class WaitHandler:
|
|
|
70
77
|
|
|
71
78
|
def _log_op(self, lvl: int, op: Operation):
|
|
72
79
|
"""Format the operation description."""
|
|
73
|
-
op_type = "operation" if len(op.children) == 0 else "operation group"
|
|
80
|
+
op_type = "operation" if op.children is None or len(op.children) == 0 else "operation group"
|
|
81
|
+
op_done = op.state in self.final
|
|
74
82
|
|
|
75
|
-
msg = f"Data transfer {op_type} '{op.description}'({op.id})"
|
|
83
|
+
msg = f"Data transfer {op_type} '{op.description}'({op.id}) {'finished. ' if op_done else 'is in progress. '}"
|
|
76
84
|
|
|
77
|
-
op_done = op.state in self.final
|
|
78
85
|
try:
|
|
79
|
-
start =
|
|
86
|
+
start = op.started_at
|
|
80
87
|
if op_done:
|
|
81
|
-
end =
|
|
88
|
+
end = op.ended_at
|
|
82
89
|
else:
|
|
83
90
|
end = datetime.datetime.now(start.tzinfo)
|
|
84
91
|
duration = (end - start).seconds
|
|
85
|
-
duration_str =
|
|
92
|
+
duration_str = hz.precisedelta(end - start)
|
|
86
93
|
except Exception as ex:
|
|
87
94
|
log.debug(f"Failed to parse operation duration: {ex}")
|
|
88
95
|
duration = 0
|
|
89
96
|
duration_str = "unknown"
|
|
90
97
|
|
|
98
|
+
# Initialize last progress time if not set, set it back in time
|
|
99
|
+
# so it logs right away (report threshold) the first time.
|
|
100
|
+
if self.last_progress.get(op.id, None) is None:
|
|
101
|
+
self.last_progress[op.id] = time.time() - self.min_progress_interval
|
|
102
|
+
|
|
91
103
|
state = op.state.value
|
|
92
104
|
if op_done:
|
|
93
|
-
msg += f"
|
|
105
|
+
msg += f"{state.title()} after {duration_str}"
|
|
94
106
|
msg += self._info_str(op)
|
|
95
107
|
# if op.messages:
|
|
96
108
|
# msg += f', messages="{"; ".join(op.messages)}"'
|
|
97
109
|
log.log(lvl, msg)
|
|
98
|
-
elif duration > self.report_threshold and time.time() - self.last_progress > self.min_progress_interval:
|
|
99
|
-
self.last_progress = time.time()
|
|
100
|
-
msg += f"
|
|
101
|
-
if op.
|
|
110
|
+
elif duration > self.report_threshold and time.time() - self.last_progress[op.id] > self.min_progress_interval:
|
|
111
|
+
self.last_progress[op.id] = time.time()
|
|
112
|
+
msg += f"{state.title()} for {duration_str}"
|
|
113
|
+
if op.progress and op.progress > 0.0:
|
|
102
114
|
msg += f", progress {op.progress * 100.0:.1f}%"
|
|
103
115
|
msg += self._info_str(op)
|
|
104
116
|
log.log(lvl, msg)
|