hid_data_transfer_lib 0.3.0__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/PKG-INFO +9 -1
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/README.md +8 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/conf/hid_dt.cfg +3 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/conf/hid_dt_configuration.py +10 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/nifi/nifi_client.py +23 -5
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/pyproject.toml +1 -1
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/__init__.py +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/conf/__init__.py +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/conf/hid_dt_local.cfg +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/conf/hid_dt_psnc.cfg +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/exceptions/__init__.py +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/exceptions/hid_dt_exceptions.py +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/hid_dt_lib.py +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/keycloak/__init__.py +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/keycloak/keycloak_rest.py +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/nifi/__init__.py +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/nifi/nifi_rest.py +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/py.typed +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/util/__init__.py +0 -0
- {hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/util/util.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: hid_data_transfer_lib
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: HiDALGO Data Transfer library provides methods to transfer data between different data providers and consumers using NIFI pipelines
|
|
5
5
|
License: APL-2.0
|
|
6
6
|
Author: Jesús Gorroñogoitia
|
|
@@ -72,6 +72,9 @@ nifi_secure_connection=True
|
|
|
72
72
|
keycloak_endpoint=https://idm.hidalgo2.eu
|
|
73
73
|
keycloak_client_id=nifi
|
|
74
74
|
keycloak_client_secret=<keycloak_nifi_client_secret>
|
|
75
|
+
|
|
76
|
+
[Network]
|
|
77
|
+
check_status_sleep_lapse=5
|
|
75
78
|
```
|
|
76
79
|
Under the NIFI section,
|
|
77
80
|
- We define the url of the NIFI service (*nifi_endpoint*),
|
|
@@ -84,6 +87,8 @@ Under the Keycloak section, you can configure the Keycloak integrated with NIFI,
|
|
|
84
87
|
- The NIFI client in Keycloak (*keycloak_client*)
|
|
85
88
|
- The NIFI secret in Keycloak (*keycloak_client_secret*)
|
|
86
89
|
|
|
90
|
+
Under the Network section, you can configure the lapse time (in seconds) each processor in the NIFI pipeline is checked for complation. Most of users should leave the default value.
|
|
91
|
+
|
|
87
92
|
HiDALGO2 developers can contact the Keycloak administrator for the *keycloak_client_secret*
|
|
88
93
|
|
|
89
94
|
### User's accounts in environment variables
|
|
@@ -166,6 +171,9 @@ dt_client.ckan2hpc(
|
|
|
166
171
|
)
|
|
167
172
|
```
|
|
168
173
|
|
|
174
|
+
## Support for HPC clusters that require a 2FA token
|
|
175
|
+
This library includes methods (suffixed as _2fa) to transfer data to/from HPC clusters that require a 2FA token. These methods offer an optional parameter *callback_2fa* that points to a method that should return (as str) the 2FA token when invoked by the library. If not set by the method caller, these methods call a default implementation that prompts the user (in the standard input) for the token.
|
|
176
|
+
|
|
169
177
|
## Data transfer process with NIFI
|
|
170
178
|
The following UML Sequence Diagram describes the data transfer process for each command, for instance *ckan2hpc*, leveraging the associated NIFI pipeline.
|
|
171
179
|
The Data Transfer (DT) Consumer (a client of this library) invokes a *ckan2hpc* command by following these steps:
|
|
@@ -54,6 +54,9 @@ nifi_secure_connection=True
|
|
|
54
54
|
keycloak_endpoint=https://idm.hidalgo2.eu
|
|
55
55
|
keycloak_client_id=nifi
|
|
56
56
|
keycloak_client_secret=<keycloak_nifi_client_secret>
|
|
57
|
+
|
|
58
|
+
[Network]
|
|
59
|
+
check_status_sleep_lapse=5
|
|
57
60
|
```
|
|
58
61
|
Under the NIFI section,
|
|
59
62
|
- We define the url of the NIFI service (*nifi_endpoint*),
|
|
@@ -66,6 +69,8 @@ Under the Keycloak section, you can configure the Keycloak integrated with NIFI,
|
|
|
66
69
|
- The NIFI client in Keycloak (*keycloak_client*)
|
|
67
70
|
- The NIFI secret in Keycloak (*keycloak_client_secret*)
|
|
68
71
|
|
|
72
|
+
Under the Network section, you can configure the lapse time (in seconds) each processor in the NIFI pipeline is checked for complation. Most of users should leave the default value.
|
|
73
|
+
|
|
69
74
|
HiDALGO2 developers can contact the Keycloak administrator for the *keycloak_client_secret*
|
|
70
75
|
|
|
71
76
|
### User's accounts in environment variables
|
|
@@ -148,6 +153,9 @@ dt_client.ckan2hpc(
|
|
|
148
153
|
)
|
|
149
154
|
```
|
|
150
155
|
|
|
156
|
+
## Support for HPC clusters that require a 2FA token
|
|
157
|
+
This library includes methods (suffixed as _2fa) to transfer data to/from HPC clusters that require a 2FA token. These methods offer an optional parameter *callback_2fa* that points to a method that should return (as str) the 2FA token when invoked by the library. If not set by the method caller, these methods call a default implementation that prompts the user (in the standard input) for the token.
|
|
158
|
+
|
|
151
159
|
## Data transfer process with NIFI
|
|
152
160
|
The following UML Sequence Diagram describes the data transfer process for each command, for instance *ckan2hpc*, leveraging the associated NIFI pipeline.
|
|
153
161
|
The Data Transfer (DT) Consumer (a client of this library) invokes a *ckan2hpc* command by following these steps:
|
|
@@ -43,6 +43,8 @@ class HidDataTransferConfiguration:
|
|
|
43
43
|
__keycloak_login = None
|
|
44
44
|
__keycloak_passwd = None
|
|
45
45
|
|
|
46
|
+
__check_status_sleep_lapse = 10 # seconds
|
|
47
|
+
|
|
46
48
|
def __init__(self, logging_level: Optional[int] = None) -> None:
|
|
47
49
|
self.__get_configuration(logging_level)
|
|
48
50
|
|
|
@@ -208,6 +210,10 @@ class HidDataTransferConfiguration:
|
|
|
208
210
|
if isinstance(handler, logging.FileHandler):
|
|
209
211
|
return handler
|
|
210
212
|
return None
|
|
213
|
+
|
|
214
|
+
def check_status_sleep_lapse(self):
|
|
215
|
+
"""Returns the NIFI login name"""
|
|
216
|
+
return self.__check_status_sleep_lapse
|
|
211
217
|
|
|
212
218
|
def __get_configuration(self, logging_level: Optional[int]):
|
|
213
219
|
"""
|
|
@@ -251,6 +257,10 @@ class HidDataTransferConfiguration:
|
|
|
251
257
|
logging_level_str = config.get("Logging", "logging_level")
|
|
252
258
|
self.__logging_level = getattr(
|
|
253
259
|
logging, logging_level_str.upper(), logging.INFO)
|
|
260
|
+
|
|
261
|
+
# Network section
|
|
262
|
+
self.__check_status_sleep_lapse = config.get(
|
|
263
|
+
"Network", "check_status_sleep_lapse")
|
|
254
264
|
|
|
255
265
|
except configparser.NoSectionError as ex:
|
|
256
266
|
raise HidDataTransferException(
|
|
@@ -64,9 +64,11 @@ def is_binary_file(filename: str) -> bool:
|
|
|
64
64
|
".pdf", ".doc", ".docx", ".ppt", ".pptx", ".xls", ".xlsx"
|
|
65
65
|
]
|
|
66
66
|
|
|
67
|
-
file_extension = filename.lower().rsplit(".", 1)[-1]
|
|
67
|
+
file_extension = filename.lower().rsplit(".", 1)[-1] \
|
|
68
|
+
if "." in filename else ""
|
|
68
69
|
return f".{file_extension}" in binary_extensions
|
|
69
70
|
|
|
71
|
+
|
|
70
72
|
# Helper enums
|
|
71
73
|
# An enum describing the types of processor exectution, either once or forever
|
|
72
74
|
class ExecutionType(Enum):
|
|
@@ -83,9 +85,6 @@ class NIFIClient:
|
|
|
83
85
|
(taken from configuration)
|
|
84
86
|
"""
|
|
85
87
|
|
|
86
|
-
# Requests constants
|
|
87
|
-
__CHECK_STATUS_SLEEP_LAPSE = 10
|
|
88
|
-
|
|
89
88
|
# Commands parameters
|
|
90
89
|
HPC_HOST = "hpc.host"
|
|
91
90
|
HPC_PORT = "hpc.port"
|
|
@@ -110,6 +109,8 @@ class NIFIClient:
|
|
|
110
109
|
self.keycloak_rest_client = KeycloakRESTClient(
|
|
111
110
|
conf, secure, refresh=True)
|
|
112
111
|
self.__logger = self.__conf.logger("nifi.v2.client")
|
|
112
|
+
self.check_status_sleep_lapse = int(
|
|
113
|
+
self.__conf.check_status_sleep_lapse())
|
|
113
114
|
|
|
114
115
|
def get_access_token(self) -> str:
|
|
115
116
|
"""gets the NIFI access token,
|
|
@@ -811,7 +812,7 @@ class NIFIClient:
|
|
|
811
812
|
f"Processor {processor_name} has failed with exception: "
|
|
812
813
|
f"{error_bulletins}"
|
|
813
814
|
)
|
|
814
|
-
sleep(self.
|
|
815
|
+
sleep(self.check_status_sleep_lapse)
|
|
815
816
|
self.stop_forever_running_processor(
|
|
816
817
|
execution_type[processor_name], processor)
|
|
817
818
|
|
|
@@ -996,6 +997,23 @@ class NIFIClient:
|
|
|
996
997
|
source=key,
|
|
997
998
|
target=__target,
|
|
998
999
|
)
|
|
1000
|
+
# Check if the key is accompanied by a certificate in the same folder
|
|
1001
|
+
# If so, upload the certificate as well
|
|
1002
|
+
cert_prefix = "-cert.pub"
|
|
1003
|
+
if os.path.exists(os.path.expanduser(key) + cert_prefix):
|
|
1004
|
+
__target_cert = os.path.join(
|
|
1005
|
+
self.__conf.nifi_upload_folder(),
|
|
1006
|
+
str(__key_name) + cert_prefix)
|
|
1007
|
+
sftp_put(
|
|
1008
|
+
server=self.__conf.nifi_server(),
|
|
1009
|
+
private_key=self.__conf.nifi_server_private_key(),
|
|
1010
|
+
username=self.__conf.nifi_server_user_name(),
|
|
1011
|
+
target_permissions="660",
|
|
1012
|
+
target_ownership=ownership,
|
|
1013
|
+
source=key + cert_prefix,
|
|
1014
|
+
target=__target_cert,
|
|
1015
|
+
)
|
|
1016
|
+
|
|
999
1017
|
return __target
|
|
1000
1018
|
|
|
1001
1019
|
def upload_files(self, local_folder: str,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "hid_data_transfer_lib"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.2"
|
|
4
4
|
description = "HiDALGO Data Transfer library provides methods to transfer data between different data providers and consumers using NIFI pipelines"
|
|
5
5
|
authors = [{name="Jesús Gorroñogoitia", email = "jesus.gorronogoitia@eviden.com"}]
|
|
6
6
|
license = "APL-2.0"
|
{hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/__init__.py
RENAMED
|
File without changes
|
{hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/conf/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/hid_dt_lib.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/nifi/__init__.py
RENAMED
|
File without changes
|
{hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/nifi/nifi_rest.py
RENAMED
|
File without changes
|
|
File without changes
|
{hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/util/__init__.py
RENAMED
|
File without changes
|
{hid_data_transfer_lib-0.3.0 → hid_data_transfer_lib-0.3.2}/hid_data_transfer_lib/util/util.py
RENAMED
|
File without changes
|