ansys-hps-data-transfer-client 0.2.dev0__tar.gz → 0.3.0__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.
Files changed (28) hide show
  1. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/PKG-INFO +47 -24
  2. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/README.rst +35 -11
  3. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/pyproject.toml +38 -18
  4. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/api/__init__.py +2 -0
  5. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/api/api.py +62 -40
  6. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/api/async_api.py +65 -41
  7. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/api/retry.py +5 -3
  8. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/authenticate.py +23 -28
  9. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/binary.py +95 -44
  10. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/client.py +134 -54
  11. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/exceptions.py +44 -34
  12. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/models/__init__.py +3 -1
  13. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/models/common.py +8 -9
  14. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/models/core.py +4 -4
  15. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/models/metadata.py +8 -6
  16. ansys_hps_data_transfer_client-0.3.0/src/ansys/hps/data_transfer/client/models/msg.py +165 -0
  17. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/models/ops.py +18 -18
  18. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/models/permissions.py +11 -15
  19. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/models/rest.py +25 -4
  20. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/models/storage.py +1 -2
  21. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/token.py +3 -1
  22. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/utils/__init__.py +2 -0
  23. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/utils/jitter.py +18 -7
  24. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/utils/otel_config.py +10 -8
  25. ansys_hps_data_transfer_client-0.2.dev0/src/ansys/hps/data_transfer/client/models/msg.py +0 -142
  26. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/LICENSE +0 -0
  27. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/__init__.py +0 -0
  28. {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.3.0}/src/ansys/hps/data_transfer/client/__version__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ansys-hps-data-transfer-client
3
- Version: 0.2.dev0
3
+ Version: 0.3.0
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>
@@ -24,16 +24,15 @@ Requires-Dist: asyncio-atexit>=1.0.0
24
24
  Requires-Dist: build==1.2.2.post1 ; extra == "build"
25
25
  Requires-Dist: twine==6.1.0 ; extra == "build"
26
26
  Requires-Dist: wheel ; extra == "build"
27
- Requires-Dist: datamodel-code-generator==0.26.3 ; extra == "build"
27
+ Requires-Dist: datamodel-code-generator==0.32.0 ; extra == "build"
28
28
  Requires-Dist: pre-commit==4.2.0 ; extra == "build"
29
29
  Requires-Dist: importlib_metadata>=7.0 ; extra == "build"
30
- Requires-Dist: ansys-sphinx-theme==1.2.6 ; extra == "doc"
30
+ Requires-Dist: ansys-sphinx-theme==1.5.2 ; extra == "doc"
31
31
  Requires-Dist: autodoc_pydantic==2.2.0 ; extra == "doc"
32
32
  Requires-Dist: jupyter_sphinx==0.5.3 ; extra == "doc"
33
- Requires-Dist: nbsphinx==0.9.6 ; extra == "doc"
33
+ Requires-Dist: nbsphinx==0.9.7 ; extra == "doc"
34
34
  Requires-Dist: numpydoc==1.8.0 ; extra == "doc"
35
- Requires-Dist: myst-parser==4.0.0 ; extra == "doc"
36
- Requires-Dist: Sphinx==8.2.3 ; extra == "doc"
35
+ Requires-Dist: Sphinx==8.1.3 ; extra == "doc"
37
36
  Requires-Dist: sphinx-autoapi==3.6.0 ; extra == "doc"
38
37
  Requires-Dist: sphinx-autodoc-typehints==3.0.1 ; extra == "doc"
39
38
  Requires-Dist: sphinxcontrib-globalsubs==0.1.2 ; extra == "doc"
@@ -44,15 +43,15 @@ Requires-Dist: sphinx-jinja==2.0.2 ; extra == "doc"
44
43
  Requires-Dist: sphinxnotes-strike==1.2.1 ; extra == "doc"
45
44
  Requires-Dist: sphinx-tabs==3.4.7 ; extra == "doc"
46
45
  Requires-Dist: sphinx-gallery==0.19.0 ; extra == "doc"
47
- Requires-Dist: pytest==8.3.5 ; extra == "tests"
48
- Requires-Dist: pytest-cov==6.0.0 ; extra == "tests"
49
- Requires-Dist: pytest-timeout==2.3.1 ; extra == "tests"
46
+ Requires-Dist: pytest==8.4.1 ; extra == "tests"
47
+ Requires-Dist: pytest-cov==6.2.1 ; extra == "tests"
48
+ Requires-Dist: pytest-timeout==2.4.0 ; extra == "tests"
50
49
  Requires-Dist: pytest-mock-resources[redis]==2.12.2 ; extra == "tests"
51
- Requires-Dist: pytest-rerunfailures==15.0 ; extra == "tests"
52
- Requires-Dist: pytest-asyncio==0.25.3 ; extra == "tests"
53
- Requires-Dist: python-keycloak==5.3.1 ; extra == "tests"
50
+ Requires-Dist: pytest-rerunfailures==15.1 ; extra == "tests"
51
+ Requires-Dist: pytest-asyncio==1.1.0 ; extra == "tests"
52
+ Requires-Dist: python-keycloak==5.7.0 ; extra == "tests"
54
53
  Requires-Dist: python-slugify>=8.0.4 ; extra == "tests"
55
- Requires-Dist: tox==4.24.2 ; extra == "tests"
54
+ Requires-Dist: tox==4.28.4 ; extra == "tests"
56
55
  Project-URL: Documentation, https://data-transfer.hps.docs.pyansys.com
57
56
  Project-URL: Homepage, https://github.com/ansys/pyhps-data-transfer/
58
57
  Project-URL: Source, https://github.com/ansys/pyhps-data-transfer/
@@ -97,21 +96,19 @@ PyHPS Data Transfer
97
96
  Overview
98
97
  --------
99
98
 
100
- Python client library for HPS Data Transfer Service
99
+ PyHPS Data Transfer is a Python client library for the Ansys HPC Platform Services (HPS) data transfer service.
101
100
 
102
101
  .. contribute_start
103
102
 
104
103
  Installation
105
104
  ^^^^^^^^^^^^
106
-
107
- You can use `pip <https://pypi.org/project/pip/>`_ to install PyHPS Data Transfer.
108
- Note: This will be available only after released. For now, please install from git
105
+ You can use `pip <https://pypi.org/project/pip/>`_ to install PyHPS Data Transfer in user mode:
109
106
 
110
107
  .. code:: bash
111
108
 
112
109
  pip install ansys-hps-data-transfer-client
113
110
 
114
- To install the latest development version, run these commands:
111
+ To install the latest development version from the GitHub repository, run these commands:
115
112
 
116
113
  .. code:: bash
117
114
 
@@ -119,19 +116,45 @@ To install the latest development version, run these commands:
119
116
  cd pyhps-data-transfer
120
117
  pip install -e .
121
118
 
122
- For more information, see `Getting Started`_.
119
+ For more information, see `Getting started`_.
123
120
 
124
121
  Basic usage
125
122
  ^^^^^^^^^^^
126
123
 
127
- This code shows how to import PyHPS Data Transfer and use some basic capabilities:
124
+ The following sections show how to import PyHPS Data Transfer and use some basic capabilities.
125
+
126
+ Request access token
127
+ ~~~~~~~~~~~~~~~~~~~~
128
+
129
+ The client library requires an access token to connect to the HPS Data Transfer service.
130
+
131
+ .. code:: python
132
+
133
+ from ansys.hps.data_transfer.client.authenticate import authenticate
134
+
135
+ auth_url = "https://localhost:8443/hps/auth/realms/rep"
136
+
137
+ token = authenticate(username="repadmin", password="repadmin", verify=False, url=auth_url)
138
+ token = token.get("access_token", None)
139
+
140
+ Connect to data transfer service client
141
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142
+
143
+ After obtaining the access token, you can connect to the data transfer service client:
128
144
 
129
145
  .. code:: python
130
146
 
131
147
  from ansys.hps.data_transfer.client import Client # Import the Client class
148
+ dt_url = f"https://localhost:8443/hps/dt/api/v1"
132
149
  client = Client() # Create a client object
150
+ client.binary_config.update(verbosity=3, debug=True, insecure=True, token=token, data_transfer_url=dt_url, log=True)
151
+ client.start()
152
+
153
+ api = DataTransferApi(client)
154
+ api.status(wait=True)
155
+
133
156
 
134
- For comprehensive usage information, see `Examples`_ in the `PyHPS Data Transfer documentation`_.
157
+ For comprehensive usage information, see `Examples`_.
135
158
 
136
159
  Documentation and issues
137
160
  ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -150,7 +173,7 @@ To reach the project support team, email `pyansys.core@ansys.com <mailto:pyansys
150
173
 
151
174
 
152
175
  .. LINKS AND REFERENCES
153
- .. _Getting Started: https://hps.docs.pyansys.com/version/stable/getting_started/index.html
154
- .. _Examples: https://hps.docs.pyansys.com/version/stable/examples.html
155
- .. _PyHPS Data Transfer documentation: https://hps.docs.pyansys.com/version/stable/index.html
176
+ .. _Getting Started: https://data-transfer.hps.docs.pyansys.com/version/stable/getting_started/index.html
177
+ .. _Examples: https://data-transfer.hps.docs.pyansys.com/version/stable/examples/index.html
178
+ .. _PyHPS Data Transfer documentation: https://data-transfer.hps.docs.pyansys.com/
156
179
 
@@ -34,21 +34,19 @@ PyHPS Data Transfer
34
34
  Overview
35
35
  --------
36
36
 
37
- Python client library for HPS Data Transfer Service
37
+ PyHPS Data Transfer is a Python client library for the Ansys HPC Platform Services (HPS) data transfer service.
38
38
 
39
39
  .. contribute_start
40
40
 
41
41
  Installation
42
42
  ^^^^^^^^^^^^
43
-
44
- You can use `pip <https://pypi.org/project/pip/>`_ to install PyHPS Data Transfer.
45
- Note: This will be available only after released. For now, please install from git
43
+ You can use `pip <https://pypi.org/project/pip/>`_ to install PyHPS Data Transfer in user mode:
46
44
 
47
45
  .. code:: bash
48
46
 
49
47
  pip install ansys-hps-data-transfer-client
50
48
 
51
- To install the latest development version, run these commands:
49
+ To install the latest development version from the GitHub repository, run these commands:
52
50
 
53
51
  .. code:: bash
54
52
 
@@ -56,19 +54,45 @@ To install the latest development version, run these commands:
56
54
  cd pyhps-data-transfer
57
55
  pip install -e .
58
56
 
59
- For more information, see `Getting Started`_.
57
+ For more information, see `Getting started`_.
60
58
 
61
59
  Basic usage
62
60
  ^^^^^^^^^^^
63
61
 
64
- This code shows how to import PyHPS Data Transfer and use some basic capabilities:
62
+ The following sections show how to import PyHPS Data Transfer and use some basic capabilities.
63
+
64
+ Request access token
65
+ ~~~~~~~~~~~~~~~~~~~~
66
+
67
+ The client library requires an access token to connect to the HPS Data Transfer service.
68
+
69
+ .. code:: python
70
+
71
+ from ansys.hps.data_transfer.client.authenticate import authenticate
72
+
73
+ auth_url = "https://localhost:8443/hps/auth/realms/rep"
74
+
75
+ token = authenticate(username="repadmin", password="repadmin", verify=False, url=auth_url)
76
+ token = token.get("access_token", None)
77
+
78
+ Connect to data transfer service client
79
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80
+
81
+ After obtaining the access token, you can connect to the data transfer service client:
65
82
 
66
83
  .. code:: python
67
84
 
68
85
  from ansys.hps.data_transfer.client import Client # Import the Client class
86
+ dt_url = f"https://localhost:8443/hps/dt/api/v1"
69
87
  client = Client() # Create a client object
88
+ client.binary_config.update(verbosity=3, debug=True, insecure=True, token=token, data_transfer_url=dt_url, log=True)
89
+ client.start()
90
+
91
+ api = DataTransferApi(client)
92
+ api.status(wait=True)
93
+
70
94
 
71
- For comprehensive usage information, see `Examples`_ in the `PyHPS Data Transfer documentation`_.
95
+ For comprehensive usage information, see `Examples`_.
72
96
 
73
97
  Documentation and issues
74
98
  ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -87,6 +111,6 @@ To reach the project support team, email `pyansys.core@ansys.com <mailto:pyansys
87
111
 
88
112
 
89
113
  .. LINKS AND REFERENCES
90
- .. _Getting Started: https://hps.docs.pyansys.com/version/stable/getting_started/index.html
91
- .. _Examples: https://hps.docs.pyansys.com/version/stable/examples.html
92
- .. _PyHPS Data Transfer documentation: https://hps.docs.pyansys.com/version/stable/index.html
114
+ .. _Getting Started: https://data-transfer.hps.docs.pyansys.com/version/stable/getting_started/index.html
115
+ .. _Examples: https://data-transfer.hps.docs.pyansys.com/version/stable/examples/index.html
116
+ .. _PyHPS Data Transfer documentation: https://data-transfer.hps.docs.pyansys.com/
@@ -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.2.dev0"
8
+ version = "0.3.0"
9
9
  description = "Python client library for hps data transfer service"
10
10
  readme = "README.rst"
11
11
  requires-python = ">=3.10,<4.0"
@@ -39,24 +39,23 @@ dependencies = [
39
39
 
40
40
  [project.optional-dependencies]
41
41
  tests = [
42
- "pytest==8.3.5",
43
- "pytest-cov==6.0.0",
44
- "pytest-timeout==2.3.1",
42
+ "pytest==8.4.1",
43
+ "pytest-cov==6.2.1",
44
+ "pytest-timeout==2.4.0",
45
45
  "pytest-mock-resources[redis]==2.12.2",
46
- "pytest-rerunfailures==15.0",
47
- "pytest-asyncio==0.25.3",
48
- "python-keycloak==5.3.1",
46
+ "pytest-rerunfailures==15.1",
47
+ "pytest-asyncio==1.1.0",
48
+ "python-keycloak==5.7.0",
49
49
  "python-slugify>=8.0.4",
50
- "tox==4.24.2",
50
+ "tox==4.28.4",
51
51
  ]
52
52
  doc = [
53
- "ansys-sphinx-theme==1.2.6",
53
+ "ansys-sphinx-theme==1.5.2",
54
54
  "autodoc_pydantic==2.2.0",
55
55
  "jupyter_sphinx==0.5.3",
56
- "nbsphinx==0.9.6",
56
+ "nbsphinx==0.9.7",
57
57
  "numpydoc==1.8.0",
58
- "myst-parser==4.0.0",
59
- "Sphinx==8.2.3",
58
+ "Sphinx==8.1.3",
60
59
  "sphinx-autoapi==3.6.0",
61
60
  "sphinx-autodoc-typehints==3.0.1",
62
61
  "sphinxcontrib-globalsubs==0.1.2",
@@ -73,7 +72,7 @@ build = [
73
72
  "build==1.2.2.post1",
74
73
  "twine==6.1.0",
75
74
  "wheel",
76
- "datamodel-code-generator==0.26.3",
75
+ "datamodel-code-generator==0.32.0",
77
76
  "pre-commit==4.2.0",
78
77
  "importlib_metadata>=7.0",
79
78
  ]
@@ -121,12 +120,33 @@ extend-exclude = ["examples/**/*.py"]
121
120
 
122
121
  [tool.ruff.lint]
123
122
  select = [
124
- "E", # pycodestyle, see https://beta.ruff.rs/docs/rules/#pycodestyle-e-w
125
- "F", # pyflakes, see https://beta.ruff.rs/docs/rules/#pyflakes-f
126
- "I", # isort, see https://beta.ruff.rs/docs/rules/#isort-i
127
- "N", # pep8-naming, see https://beta.ruff.rs/docs/rules/#pep8-naming-n
123
+ "E", # pycodestyle errors
124
+ "W", # pycodestyle warnings
125
+ "F", # pyflakes
126
+ "I", # isort
127
+ "N", # pep8-naming
128
+ "UP", # pyupgrade
129
+ "C4", # flake8-comprehensions
130
+ "B", # flake8-bugbear
131
+ "PLE", # Pylint errors
132
+ "PLC", # Pylint convention
133
+ "PLW", # Pylint warnings
134
+ "PLR1711", # useless-return
135
+ "PLR5501", # collapsible-else-if
136
+ "Q", # flake8-quotes
137
+ "PT", # flake8-pytest-style
138
+ "LOG", # flake8-logging
139
+ "D", # pydocstyle
128
140
  ]
129
- ignore = ["E402", "E712", "E722", "F401", "F841", "F821"]
141
+
142
+ ignore = []
143
+
144
+ [tool.ruff.lint.per-file-ignores]
145
+ "__init__.py" = ["F401"]
146
+ # ignore docstring requirements for module because it is autogenerated
147
+ "src/ansys/hps/data_transfer/client/models/*.py" = ["D", "F821"]
148
+ # ignore docstring requirements amd equility comparisons issues for tests
149
+ "tests/**/*.py" = ["D", "PT011", "E712"]
130
150
 
131
151
  [tool.ruff.lint.isort]
132
152
  combine-as-imports = true
@@ -20,5 +20,7 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
+ """PyHPS data transfer API subpackage."""
24
+
23
25
  from .api import DataTransferApi
24
26
  from .async_api import AsyncDataTransferApi
@@ -20,20 +20,19 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- """This module provides the core API functionality for interacting with the
24
- Ansys HPS Data Transfer Client. It includes methods and utilities for performing
23
+ """Provides the core API functionality for interacting with the Ansys HPS data transfer client.
24
+
25
+ This module includes methods and utilities for performing
25
26
  data transfer operations, managing resources, and handling client interactions.
26
27
  """
27
28
 
29
+ import builtins
30
+ from collections.abc import Callable
28
31
  import logging
29
32
  import textwrap
30
33
  import time
31
- from typing import Dict, List
32
34
 
33
35
  import backoff
34
-
35
- log = logging.getLogger(__name__)
36
-
37
36
  import humanfriendly as hf
38
37
 
39
38
  from ..client import Client
@@ -55,9 +54,11 @@ from ..models.permissions import RoleAssignment, RoleQuery
55
54
  from ..utils.jitter import get_expo_backoff
56
55
  from .retry import retry
57
56
 
57
+ log = logging.getLogger(__name__)
58
+
58
59
 
59
60
  class DataTransferApi:
60
- """Class for Data transfer API.
61
+ """Provides the data transfer API.
61
62
 
62
63
  Parameters
63
64
  ----------
@@ -66,12 +67,13 @@ class DataTransferApi:
66
67
  """
67
68
 
68
69
  def __init__(self, client: Client):
70
+ """Initializes the DataTransferApi class object."""
69
71
  self.dump_mode = "json"
70
72
  self.client = client
71
73
 
72
74
  @retry()
73
75
  def status(self, wait=False, sleep=5, jitter=True, timeout: float | None = 20.0):
74
- """Status of worker binary."""
76
+ """Get the status of the worker binary."""
75
77
 
76
78
  def _sleep():
77
79
  log.info(f"Waiting for the worker to be ready on port {self.client.binary_config.port} ...")
@@ -93,13 +95,13 @@ class DataTransferApi:
93
95
  return s
94
96
 
95
97
  @retry()
96
- def operations(self, ids: List[str]):
98
+ def operations(self, ids: list[str]):
97
99
  """Get a list of operations.
98
100
 
99
101
  Parameters
100
102
  ----------
101
103
  ids: List[str]
102
- List of ids.
104
+ List of IDs.
103
105
  """
104
106
  return self._operations(ids)
105
107
 
@@ -110,8 +112,8 @@ class DataTransferApi:
110
112
  json = resp.json()
111
113
  return StorageConfigResponse(**json).storage
112
114
 
113
- def copy(self, operations: List[SrcDst]):
114
- """Get API response for copying a list of files.
115
+ def copy(self, operations: list[SrcDst]):
116
+ """Get the API response for copying a list of files.
115
117
 
116
118
  Parameters
117
119
  ----------
@@ -119,7 +121,7 @@ class DataTransferApi:
119
121
  """
120
122
  return self._exec_operation_req("copy", operations)
121
123
 
122
- def exists(self, operations: List[StoragePath]):
124
+ def exists(self, operations: list[StoragePath]):
123
125
  """Check if a path exists.
124
126
 
125
127
  Parameters
@@ -128,7 +130,7 @@ class DataTransferApi:
128
130
  """
129
131
  return self._exec_operation_req("exists", operations)
130
132
 
131
- def list(self, operations: List[StoragePath]):
133
+ def list(self, operations: list[StoragePath]):
132
134
  """List files in a path.
133
135
 
134
136
  Parameters
@@ -137,8 +139,8 @@ class DataTransferApi:
137
139
  """
138
140
  return self._exec_operation_req("list", operations)
139
141
 
140
- def mkdir(self, operations: List[StoragePath]):
141
- """Create a dir.
142
+ def mkdir(self, operations: builtins.list[StoragePath]):
143
+ """Create a directory.
142
144
 
143
145
  Parameters
144
146
  ----------
@@ -146,7 +148,7 @@ class DataTransferApi:
146
148
  """
147
149
  return self._exec_operation_req("mkdir", operations)
148
150
 
149
- def move(self, operations: List[SrcDst]):
151
+ def move(self, operations: builtins.list[SrcDst]):
150
152
  """Move a file on the backend storage.
151
153
 
152
154
  Parameters
@@ -155,7 +157,7 @@ class DataTransferApi:
155
157
  """
156
158
  return self._exec_operation_req("move", operations)
157
159
 
158
- def remove(self, operations: List[StoragePath]):
160
+ def remove(self, operations: builtins.list[StoragePath]):
159
161
  """Delete a file.
160
162
 
161
163
  Parameters
@@ -164,8 +166,8 @@ class DataTransferApi:
164
166
  """
165
167
  return self._exec_operation_req("remove", operations)
166
168
 
167
- def rmdir(self, operations: List[StoragePath]):
168
- """Delete a dir.
169
+ def rmdir(self, operations: builtins.list[StoragePath]):
170
+ """Delete a directory.
169
171
 
170
172
  Parameters
171
173
  ----------
@@ -174,7 +176,9 @@ class DataTransferApi:
174
176
  return self._exec_operation_req("rmdir", operations)
175
177
 
176
178
  @retry()
177
- def _exec_operation_req(self, storage_operation: str, operations: List[StoragePath] | List[SrcDst]):
179
+ def _exec_operation_req(
180
+ self, storage_operation: str, operations: builtins.list[StoragePath] | builtins.list[SrcDst]
181
+ ):
178
182
  url = f"/storage:{storage_operation}"
179
183
  payload = {"operations": [operation.model_dump(mode=self.dump_mode) for operation in operations]}
180
184
  resp = self.client.session.post(url, json=payload)
@@ -182,15 +186,15 @@ class DataTransferApi:
182
186
  r = OpIdResponse(**json)
183
187
  return r
184
188
 
185
- def _operations(self, ids: List[str]):
189
+ def _operations(self, ids: builtins.list[str]):
186
190
  url = "/operations"
187
191
  resp = self.client.session.get(url, params={"ids": ids})
188
192
  json = resp.json()
189
193
  return OpsResponse(**json).operations
190
194
 
191
195
  @retry()
192
- def check_permissions(self, permissions: List[RoleAssignment]):
193
- """Checks permissions of a path (including parent directory) using a list of RoleAssignment objects.
196
+ def check_permissions(self, permissions: builtins.list[RoleAssignment]):
197
+ """Check permissions of a path (including parent directory) using a list of ``RoleAssignment`` objects.
194
198
 
195
199
  Parameters
196
200
  ----------
@@ -203,8 +207,8 @@ class DataTransferApi:
203
207
  return CheckPermissionsResponse(**json)
204
208
 
205
209
  @retry()
206
- def get_permissions(self, permissions: List[RoleQuery]):
207
- """Return permissions of a file from a list of RoleQuery objects.
210
+ def get_permissions(self, permissions: builtins.list[RoleQuery]):
211
+ """Get permissions of a file from a list of ``RoleQuery`` objects.
208
212
 
209
213
  Parameters
210
214
  ----------
@@ -217,8 +221,8 @@ class DataTransferApi:
217
221
  return GetPermissionsResponse(**json)
218
222
 
219
223
  @retry()
220
- def remove_permissions(self, permissions: List[RoleAssignment]):
221
- """Remove permissions using a list of RoleAssignment objects.
224
+ def remove_permissions(self, permissions: builtins.list[RoleAssignment]):
225
+ """Remove permissions using a list of ``RoleAssignment`` objects.
222
226
 
223
227
  Parameters
224
228
  ----------
@@ -227,11 +231,10 @@ class DataTransferApi:
227
231
  url = "/permissions:remove"
228
232
  payload = {"permissions": [permission.model_dump(mode=self.dump_mode) for permission in permissions]}
229
233
  self.client.session.post(url, json=payload)
230
- return None
231
234
 
232
235
  @retry()
233
- def set_permissions(self, permissions: List[RoleAssignment]):
234
- """Set permissions using a list of RoleAssignment objects.
236
+ def set_permissions(self, permissions: builtins.list[RoleAssignment]):
237
+ """Set permissions using a list of ``RoleAssignment`` objects.
235
238
 
236
239
  Parameters
237
240
  ----------
@@ -240,11 +243,10 @@ class DataTransferApi:
240
243
  url = "/permissions:set"
241
244
  payload = {"permissions": [permission.model_dump(mode=self.dump_mode) for permission in permissions]}
242
245
  self.client.session.post(url, json=payload)
243
- return None
244
246
 
245
247
  @retry()
246
- def get_metadata(self, paths: List[str | StoragePath]):
247
- """Get metadata of a path on backend storage.
248
+ def get_metadata(self, paths: builtins.list[str | StoragePath]):
249
+ """Get metadata of a path on the backend storage.
248
250
 
249
251
  Parameters
250
252
  ----------
@@ -258,13 +260,13 @@ class DataTransferApi:
258
260
  return OpIdResponse(**json)
259
261
 
260
262
  @retry()
261
- def set_metadata(self, asgs: Dict[str | StoragePath, DataAssignment]):
262
- """Setting metadata for a path on backend storage.
263
+ def set_metadata(self, asgs: dict[str | StoragePath, DataAssignment]):
264
+ """Set metadata for a path on the backend storage.
263
265
 
264
266
  Parameters
265
267
  ----------
266
268
  asgs: Dict[str | StoragePath, DataAssignment]
267
- List of paths with key of type string or StoragePath and value of DataAssignment
269
+ List of paths with key of type string or ``StoragePath`` and value of ``DataAssignment``.
268
270
  """
269
271
  url = "/metadata:set"
270
272
  d = {k if isinstance(k, str) else k.path: v for k, v in asgs.items()}
@@ -275,16 +277,33 @@ class DataTransferApi:
275
277
 
276
278
  def wait_for(
277
279
  self,
278
- operation_ids: List[str | Operation | OpIdResponse],
280
+ operation_ids: builtins.list[str | Operation | OpIdResponse],
279
281
  timeout: float | None = None,
280
282
  interval: float = 0.1,
281
283
  cap: float = 2.0,
282
284
  raise_on_error: bool = False,
285
+ progress_handler: Callable[[str, float], None] = None,
283
286
  ):
284
- """Wait for operations to complete."""
287
+ """Wait for operations to complete.
288
+
289
+ Parameters
290
+ ----------
291
+ operation_ids: List[str | Operation | OpIdResponse]
292
+ List of operation ids.
293
+ timeout: float | None
294
+ Timeout in seconds. Default is None.
295
+ interval: float
296
+ Interval in seconds. Default is 0.1.
297
+ cap: float
298
+ The maximum backoff value used to calculate the next wait time. Default is 2.0.
299
+ raise_on_error: bool
300
+ Raise an exception if an error occurs. Default is False.
301
+ progress_handler: Callable[[str, float], None]
302
+ A function to handle progress updates. Default is None.
303
+ """
285
304
  if not isinstance(operation_ids, list):
286
305
  operation_ids = [operation_ids]
287
- operation_ids = [op.id if isinstance(op, (Operation, OpIdResponse)) else op for op in operation_ids]
306
+ operation_ids = [op.id if isinstance(op, Operation | OpIdResponse) else op for op in operation_ids]
288
307
  start = time.time()
289
308
  attempt = 0
290
309
  op_str = textwrap.wrap(", ".join(operation_ids), width=60, placeholder="...")
@@ -306,6 +325,9 @@ class DataTransferApi:
306
325
  if op.progress > 0:
307
326
  fields.append(f"progress={op.progress:.3f}")
308
327
  log.debug(f"- Operation '{op.description}' {' '.join(fields)}")
328
+ if progress_handler is not None:
329
+ for op in ops:
330
+ progress_handler(op.id, op.progress)
309
331
  if all(op.state in [OperationState.Succeeded, OperationState.Failed] for op in ops):
310
332
  break
311
333
  except Exception as e: