ansys-hps-data-transfer-client 0.2.dev0__tar.gz → 0.2.1__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.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/PKG-INFO +45 -22
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/README.rst +35 -11
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/pyproject.toml +36 -16
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/api/__init__.py +2 -0
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/api/api.py +40 -39
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/api/async_api.py +43 -41
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/api/retry.py +5 -3
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/authenticate.py +23 -28
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/binary.py +59 -43
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/client.py +68 -50
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/exceptions.py +21 -24
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/models/__init__.py +4 -0
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/models/common.py +8 -8
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/models/core.py +4 -3
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/models/metadata.py +11 -5
- ansys_hps_data_transfer_client-0.2.1/src/ansys/hps/data_transfer/client/models/msg.py +190 -0
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/models/ops.py +21 -17
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/models/permissions.py +26 -12
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/models/rest.py +4 -3
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/models/storage.py +3 -1
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/token.py +3 -1
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/utils/__init__.py +2 -0
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/utils/jitter.py +18 -7
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/utils/otel_config.py +10 -8
- ansys_hps_data_transfer_client-0.2.dev0/src/ansys/hps/data_transfer/client/models/msg.py +0 -142
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/LICENSE +0 -0
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/src/ansys/hps/data_transfer/client/__init__.py +0 -0
- {ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/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.
|
|
3
|
+
Version: 0.2.1
|
|
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.
|
|
27
|
+
Requires-Dist: datamodel-code-generator==0.30.1 ; 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.
|
|
30
|
+
Requires-Dist: ansys-sphinx-theme==1.4.4 ; 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.
|
|
33
|
+
Requires-Dist: nbsphinx==0.9.7 ; extra == "doc"
|
|
34
34
|
Requires-Dist: numpydoc==1.8.0 ; extra == "doc"
|
|
35
|
-
Requires-Dist:
|
|
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"
|
|
@@ -45,14 +44,14 @@ 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
46
|
Requires-Dist: pytest==8.3.5 ; extra == "tests"
|
|
48
|
-
Requires-Dist: pytest-cov==6.
|
|
49
|
-
Requires-Dist: pytest-timeout==2.
|
|
47
|
+
Requires-Dist: pytest-cov==6.1.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.
|
|
52
|
-
Requires-Dist: pytest-asyncio==0.
|
|
50
|
+
Requires-Dist: pytest-rerunfailures==15.1 ; extra == "tests"
|
|
51
|
+
Requires-Dist: pytest-asyncio==0.26.0 ; extra == "tests"
|
|
53
52
|
Requires-Dist: python-keycloak==5.3.1 ; extra == "tests"
|
|
54
53
|
Requires-Dist: python-slugify>=8.0.4 ; extra == "tests"
|
|
55
|
-
Requires-Dist: tox==4.
|
|
54
|
+
Requires-Dist: tox==4.26.0 ; 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
|
|
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
|
|
119
|
+
For more information, see `Getting started`_.
|
|
123
120
|
|
|
124
121
|
Basic usage
|
|
125
122
|
^^^^^^^^^^^
|
|
126
123
|
|
|
127
|
-
|
|
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`_
|
|
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/
|
|
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
|
|
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
|
|
57
|
+
For more information, see `Getting started`_.
|
|
60
58
|
|
|
61
59
|
Basic usage
|
|
62
60
|
^^^^^^^^^^^
|
|
63
61
|
|
|
64
|
-
|
|
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`_
|
|
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/
|
|
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/
|
{ansys_hps_data_transfer_client-0.2.dev0 → ansys_hps_data_transfer_client-0.2.1}/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.2.
|
|
8
|
+
version = "0.2.1"
|
|
9
9
|
description = "Python client library for hps data transfer service"
|
|
10
10
|
readme = "README.rst"
|
|
11
11
|
requires-python = ">=3.10,<4.0"
|
|
@@ -40,23 +40,22 @@ dependencies = [
|
|
|
40
40
|
[project.optional-dependencies]
|
|
41
41
|
tests = [
|
|
42
42
|
"pytest==8.3.5",
|
|
43
|
-
"pytest-cov==6.
|
|
44
|
-
"pytest-timeout==2.
|
|
43
|
+
"pytest-cov==6.1.1",
|
|
44
|
+
"pytest-timeout==2.4.0",
|
|
45
45
|
"pytest-mock-resources[redis]==2.12.2",
|
|
46
|
-
"pytest-rerunfailures==15.
|
|
47
|
-
"pytest-asyncio==0.
|
|
46
|
+
"pytest-rerunfailures==15.1",
|
|
47
|
+
"pytest-asyncio==0.26.0",
|
|
48
48
|
"python-keycloak==5.3.1",
|
|
49
49
|
"python-slugify>=8.0.4",
|
|
50
|
-
"tox==4.
|
|
50
|
+
"tox==4.26.0",
|
|
51
51
|
]
|
|
52
52
|
doc = [
|
|
53
|
-
"ansys-sphinx-theme==1.
|
|
53
|
+
"ansys-sphinx-theme==1.4.4",
|
|
54
54
|
"autodoc_pydantic==2.2.0",
|
|
55
55
|
"jupyter_sphinx==0.5.3",
|
|
56
|
-
"nbsphinx==0.9.
|
|
56
|
+
"nbsphinx==0.9.7",
|
|
57
57
|
"numpydoc==1.8.0",
|
|
58
|
-
"
|
|
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.
|
|
75
|
+
"datamodel-code-generator==0.30.1",
|
|
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",
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"
|
|
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
|
-
|
|
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,20 +20,18 @@
|
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
# SOFTWARE.
|
|
22
22
|
|
|
23
|
-
"""
|
|
24
|
-
|
|
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
|
|
28
30
|
import logging
|
|
29
31
|
import textwrap
|
|
30
32
|
import time
|
|
31
|
-
from typing import Dict, List
|
|
32
33
|
|
|
33
34
|
import backoff
|
|
34
|
-
|
|
35
|
-
log = logging.getLogger(__name__)
|
|
36
|
-
|
|
37
35
|
import humanfriendly as hf
|
|
38
36
|
|
|
39
37
|
from ..client import Client
|
|
@@ -55,9 +53,11 @@ from ..models.permissions import RoleAssignment, RoleQuery
|
|
|
55
53
|
from ..utils.jitter import get_expo_backoff
|
|
56
54
|
from .retry import retry
|
|
57
55
|
|
|
56
|
+
log = logging.getLogger(__name__)
|
|
57
|
+
|
|
58
58
|
|
|
59
59
|
class DataTransferApi:
|
|
60
|
-
"""
|
|
60
|
+
"""Provides the data transfer API.
|
|
61
61
|
|
|
62
62
|
Parameters
|
|
63
63
|
----------
|
|
@@ -66,12 +66,13 @@ class DataTransferApi:
|
|
|
66
66
|
"""
|
|
67
67
|
|
|
68
68
|
def __init__(self, client: Client):
|
|
69
|
+
"""Initializes the DataTransferApi class object."""
|
|
69
70
|
self.dump_mode = "json"
|
|
70
71
|
self.client = client
|
|
71
72
|
|
|
72
73
|
@retry()
|
|
73
74
|
def status(self, wait=False, sleep=5, jitter=True, timeout: float | None = 20.0):
|
|
74
|
-
"""
|
|
75
|
+
"""Get the status of the worker binary."""
|
|
75
76
|
|
|
76
77
|
def _sleep():
|
|
77
78
|
log.info(f"Waiting for the worker to be ready on port {self.client.binary_config.port} ...")
|
|
@@ -93,13 +94,13 @@ class DataTransferApi:
|
|
|
93
94
|
return s
|
|
94
95
|
|
|
95
96
|
@retry()
|
|
96
|
-
def operations(self, ids:
|
|
97
|
+
def operations(self, ids: list[str]):
|
|
97
98
|
"""Get a list of operations.
|
|
98
99
|
|
|
99
100
|
Parameters
|
|
100
101
|
----------
|
|
101
102
|
ids: List[str]
|
|
102
|
-
List of
|
|
103
|
+
List of IDs.
|
|
103
104
|
"""
|
|
104
105
|
return self._operations(ids)
|
|
105
106
|
|
|
@@ -110,8 +111,8 @@ class DataTransferApi:
|
|
|
110
111
|
json = resp.json()
|
|
111
112
|
return StorageConfigResponse(**json).storage
|
|
112
113
|
|
|
113
|
-
def copy(self, operations:
|
|
114
|
-
"""Get API response for copying a list of files.
|
|
114
|
+
def copy(self, operations: list[SrcDst]):
|
|
115
|
+
"""Get the API response for copying a list of files.
|
|
115
116
|
|
|
116
117
|
Parameters
|
|
117
118
|
----------
|
|
@@ -119,7 +120,7 @@ class DataTransferApi:
|
|
|
119
120
|
"""
|
|
120
121
|
return self._exec_operation_req("copy", operations)
|
|
121
122
|
|
|
122
|
-
def exists(self, operations:
|
|
123
|
+
def exists(self, operations: list[StoragePath]):
|
|
123
124
|
"""Check if a path exists.
|
|
124
125
|
|
|
125
126
|
Parameters
|
|
@@ -128,7 +129,7 @@ class DataTransferApi:
|
|
|
128
129
|
"""
|
|
129
130
|
return self._exec_operation_req("exists", operations)
|
|
130
131
|
|
|
131
|
-
def list(self, operations:
|
|
132
|
+
def list(self, operations: list[StoragePath]):
|
|
132
133
|
"""List files in a path.
|
|
133
134
|
|
|
134
135
|
Parameters
|
|
@@ -137,8 +138,8 @@ class DataTransferApi:
|
|
|
137
138
|
"""
|
|
138
139
|
return self._exec_operation_req("list", operations)
|
|
139
140
|
|
|
140
|
-
def mkdir(self, operations:
|
|
141
|
-
"""Create a
|
|
141
|
+
def mkdir(self, operations: builtins.list[StoragePath]):
|
|
142
|
+
"""Create a directory.
|
|
142
143
|
|
|
143
144
|
Parameters
|
|
144
145
|
----------
|
|
@@ -146,7 +147,7 @@ class DataTransferApi:
|
|
|
146
147
|
"""
|
|
147
148
|
return self._exec_operation_req("mkdir", operations)
|
|
148
149
|
|
|
149
|
-
def move(self, operations:
|
|
150
|
+
def move(self, operations: builtins.list[SrcDst]):
|
|
150
151
|
"""Move a file on the backend storage.
|
|
151
152
|
|
|
152
153
|
Parameters
|
|
@@ -155,7 +156,7 @@ class DataTransferApi:
|
|
|
155
156
|
"""
|
|
156
157
|
return self._exec_operation_req("move", operations)
|
|
157
158
|
|
|
158
|
-
def remove(self, operations:
|
|
159
|
+
def remove(self, operations: builtins.list[StoragePath]):
|
|
159
160
|
"""Delete a file.
|
|
160
161
|
|
|
161
162
|
Parameters
|
|
@@ -164,8 +165,8 @@ class DataTransferApi:
|
|
|
164
165
|
"""
|
|
165
166
|
return self._exec_operation_req("remove", operations)
|
|
166
167
|
|
|
167
|
-
def rmdir(self, operations:
|
|
168
|
-
"""Delete a
|
|
168
|
+
def rmdir(self, operations: builtins.list[StoragePath]):
|
|
169
|
+
"""Delete a directory.
|
|
169
170
|
|
|
170
171
|
Parameters
|
|
171
172
|
----------
|
|
@@ -174,7 +175,9 @@ class DataTransferApi:
|
|
|
174
175
|
return self._exec_operation_req("rmdir", operations)
|
|
175
176
|
|
|
176
177
|
@retry()
|
|
177
|
-
def _exec_operation_req(
|
|
178
|
+
def _exec_operation_req(
|
|
179
|
+
self, storage_operation: str, operations: builtins.list[StoragePath] | builtins.list[SrcDst]
|
|
180
|
+
):
|
|
178
181
|
url = f"/storage:{storage_operation}"
|
|
179
182
|
payload = {"operations": [operation.model_dump(mode=self.dump_mode) for operation in operations]}
|
|
180
183
|
resp = self.client.session.post(url, json=payload)
|
|
@@ -182,15 +185,15 @@ class DataTransferApi:
|
|
|
182
185
|
r = OpIdResponse(**json)
|
|
183
186
|
return r
|
|
184
187
|
|
|
185
|
-
def _operations(self, ids:
|
|
188
|
+
def _operations(self, ids: builtins.list[str]):
|
|
186
189
|
url = "/operations"
|
|
187
190
|
resp = self.client.session.get(url, params={"ids": ids})
|
|
188
191
|
json = resp.json()
|
|
189
192
|
return OpsResponse(**json).operations
|
|
190
193
|
|
|
191
194
|
@retry()
|
|
192
|
-
def check_permissions(self, permissions:
|
|
193
|
-
"""
|
|
195
|
+
def check_permissions(self, permissions: builtins.list[RoleAssignment]):
|
|
196
|
+
"""Check permissions of a path (including parent directory) using a list of ``RoleAssignment`` objects.
|
|
194
197
|
|
|
195
198
|
Parameters
|
|
196
199
|
----------
|
|
@@ -203,8 +206,8 @@ class DataTransferApi:
|
|
|
203
206
|
return CheckPermissionsResponse(**json)
|
|
204
207
|
|
|
205
208
|
@retry()
|
|
206
|
-
def get_permissions(self, permissions:
|
|
207
|
-
"""
|
|
209
|
+
def get_permissions(self, permissions: builtins.list[RoleQuery]):
|
|
210
|
+
"""Get permissions of a file from a list of ``RoleQuery`` objects.
|
|
208
211
|
|
|
209
212
|
Parameters
|
|
210
213
|
----------
|
|
@@ -217,8 +220,8 @@ class DataTransferApi:
|
|
|
217
220
|
return GetPermissionsResponse(**json)
|
|
218
221
|
|
|
219
222
|
@retry()
|
|
220
|
-
def remove_permissions(self, permissions:
|
|
221
|
-
"""Remove permissions using a list of RoleAssignment objects.
|
|
223
|
+
def remove_permissions(self, permissions: builtins.list[RoleAssignment]):
|
|
224
|
+
"""Remove permissions using a list of ``RoleAssignment`` objects.
|
|
222
225
|
|
|
223
226
|
Parameters
|
|
224
227
|
----------
|
|
@@ -227,11 +230,10 @@ class DataTransferApi:
|
|
|
227
230
|
url = "/permissions:remove"
|
|
228
231
|
payload = {"permissions": [permission.model_dump(mode=self.dump_mode) for permission in permissions]}
|
|
229
232
|
self.client.session.post(url, json=payload)
|
|
230
|
-
return None
|
|
231
233
|
|
|
232
234
|
@retry()
|
|
233
|
-
def set_permissions(self, permissions:
|
|
234
|
-
"""Set permissions using a list of RoleAssignment objects.
|
|
235
|
+
def set_permissions(self, permissions: builtins.list[RoleAssignment]):
|
|
236
|
+
"""Set permissions using a list of ``RoleAssignment`` objects.
|
|
235
237
|
|
|
236
238
|
Parameters
|
|
237
239
|
----------
|
|
@@ -240,11 +242,10 @@ class DataTransferApi:
|
|
|
240
242
|
url = "/permissions:set"
|
|
241
243
|
payload = {"permissions": [permission.model_dump(mode=self.dump_mode) for permission in permissions]}
|
|
242
244
|
self.client.session.post(url, json=payload)
|
|
243
|
-
return None
|
|
244
245
|
|
|
245
246
|
@retry()
|
|
246
|
-
def get_metadata(self, paths:
|
|
247
|
-
"""Get metadata of a path on backend storage.
|
|
247
|
+
def get_metadata(self, paths: builtins.list[str | StoragePath]):
|
|
248
|
+
"""Get metadata of a path on the backend storage.
|
|
248
249
|
|
|
249
250
|
Parameters
|
|
250
251
|
----------
|
|
@@ -258,13 +259,13 @@ class DataTransferApi:
|
|
|
258
259
|
return OpIdResponse(**json)
|
|
259
260
|
|
|
260
261
|
@retry()
|
|
261
|
-
def set_metadata(self, asgs:
|
|
262
|
-
"""
|
|
262
|
+
def set_metadata(self, asgs: dict[str | StoragePath, DataAssignment]):
|
|
263
|
+
"""Set metadata for a path on the backend storage.
|
|
263
264
|
|
|
264
265
|
Parameters
|
|
265
266
|
----------
|
|
266
267
|
asgs: Dict[str | StoragePath, DataAssignment]
|
|
267
|
-
List of paths with key of type string or StoragePath and value of DataAssignment
|
|
268
|
+
List of paths with key of type string or ``StoragePath`` and value of ``DataAssignment``.
|
|
268
269
|
"""
|
|
269
270
|
url = "/metadata:set"
|
|
270
271
|
d = {k if isinstance(k, str) else k.path: v for k, v in asgs.items()}
|
|
@@ -275,7 +276,7 @@ class DataTransferApi:
|
|
|
275
276
|
|
|
276
277
|
def wait_for(
|
|
277
278
|
self,
|
|
278
|
-
operation_ids:
|
|
279
|
+
operation_ids: builtins.list[str | Operation | OpIdResponse],
|
|
279
280
|
timeout: float | None = None,
|
|
280
281
|
interval: float = 0.1,
|
|
281
282
|
cap: float = 2.0,
|
|
@@ -284,7 +285,7 @@ class DataTransferApi:
|
|
|
284
285
|
"""Wait for operations to complete."""
|
|
285
286
|
if not isinstance(operation_ids, list):
|
|
286
287
|
operation_ids = [operation_ids]
|
|
287
|
-
operation_ids = [op.id if isinstance(op,
|
|
288
|
+
operation_ids = [op.id if isinstance(op, Operation | OpIdResponse) else op for op in operation_ids]
|
|
288
289
|
start = time.time()
|
|
289
290
|
attempt = 0
|
|
290
291
|
op_str = textwrap.wrap(", ".join(operation_ids), width=60, placeholder="...")
|