data-transfer-cli 0.4.1__tar.gz → 0.5.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.
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/PKG-INFO +108 -4
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/README.md +105 -2
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/data_transfer_cli/dtproxy.py +85 -0
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/data_transfer_cli/parser/cli_parser.py +105 -0
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/pyproject.toml +6 -4
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/data_transfer_cli/__init__.py +0 -0
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/data_transfer_cli/conf/cli.cfg +0 -0
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/data_transfer_cli/dtcli.cfg +0 -0
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/data_transfer_cli/dtcli.py +0 -0
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/data_transfer_cli/parser/__init__.py +0 -0
- {data_transfer_cli-0.4.1 → data_transfer_cli-0.5.0}/dtcli +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: data-transfer-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: HiDALGO Data Transfer CLI provides commands 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
|
|
@@ -12,7 +12,8 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
-
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
16
|
+
Requires-Dist: hid_data_transfer_lib (>=0.5.0)
|
|
16
17
|
Requires-Dist: paramiko (>=3.3.1)
|
|
17
18
|
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
18
19
|
Requires-Dist: requests (>=2.31.0)
|
|
@@ -23,8 +24,6 @@ This repository contains the implementation of the Hidalgo2 data transfer tool.
|
|
|
23
24
|
|
|
24
25
|
## Features
|
|
25
26
|
This tool is planning to support the following features:
|
|
26
|
-
- transfer datasets from Cloud Providers to HDFS
|
|
27
|
-
- transfer datasets from Cloud Providers to CKAN
|
|
28
27
|
- transfer datasets from/to Hadoop HDFS to/from HPC
|
|
29
28
|
- transfer datasets from/to Hadoop HDFS to/from CKAN
|
|
30
29
|
- transfer datasets from/to a CKAN to/from HPC
|
|
@@ -36,6 +35,8 @@ Current version supports the following features:
|
|
|
36
35
|
- transfer datasets from/to Hadoop HDFS to/from CKAN
|
|
37
36
|
- transfer datasets from/to a CKAN to/from HPC
|
|
38
37
|
- transfer datasets from/to local filesystem to/from CKAN
|
|
38
|
+
- transfer datasets from Cloud Providers to HDFS
|
|
39
|
+
- transfer datasets from Cloud Providers to CKAN
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
## Implementation
|
|
@@ -172,6 +173,10 @@ positional arguments:
|
|
|
172
173
|
hpc2ckan transfer data from HPC to a target CKAN
|
|
173
174
|
local2ckan transfer data from a local filesystem to a target CKAN
|
|
174
175
|
ckan2local transfer data from CKAN to a local filesystem
|
|
176
|
+
meteofrance2ckan download data from MeteoFrance service to a target CKAN
|
|
177
|
+
meteofrance2hdfs download data from MeteoFrance service to a target HDFS
|
|
178
|
+
ecmwf2ckan download data from the ECMWF open data service to a target CKAN
|
|
179
|
+
ecmwf2hdfs download data from the ECMWF open data service to a target HDFS
|
|
175
180
|
|
|
176
181
|
options:
|
|
177
182
|
-h, --help show this help message and exit
|
|
@@ -230,6 +235,105 @@ Transfer rate: 0.61 MB/s
|
|
|
230
235
|
Number of transferred files: 1
|
|
231
236
|
```
|
|
232
237
|
|
|
238
|
+
### Data Transfer from cloud providers usage
|
|
239
|
+
|
|
240
|
+
The Data Transfer CLI tool supports the transfer from MeteoFrance and the ECMWF open data service to either CKAN or HDFS. These commands are and their specific usage are as follows:
|
|
241
|
+
|
|
242
|
+
#### METEO FRANCE
|
|
243
|
+
Transfer data from Meteo France to CKAN or HDFS. Obtaining data from Meteo France requires that the user obtains an API_KEY for Meteo France's online API (available at [METEO FRANCE – API PORTAL](https://portail-api.meteofrance.fr/web/en/).
|
|
244
|
+
|
|
245
|
+
Both options (meteofrance2ckan and meteofrance2hdfs) require the API_KEY and a JSON-formatted configuration file where the data to download needs to be detailed. To get help for one of these commands execute:
|
|
246
|
+
|
|
247
|
+
`./dtcli meteofrance2ckan -h`
|
|
248
|
+
|
|
249
|
+
obtaining:
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
usage: ['meteofrance2ckan', '-h'] meteofrance2ckan [-h] -c CKAN_HOST -a CKAN_API_KEY -o CKAN_ORGANIZATION -d CKAN_DATASET -ma METEOFRANCE_API_KEY -mc METEOFRANCE_CONFIG
|
|
253
|
+
|
|
254
|
+
options:
|
|
255
|
+
-h, --help show this help message and exit
|
|
256
|
+
-c CKAN_HOST, --ckan-host CKAN_HOST
|
|
257
|
+
CKAN host endpoint
|
|
258
|
+
-a CKAN_API_KEY, --ckan-api-key CKAN_API_KEY
|
|
259
|
+
CKAN API key
|
|
260
|
+
-o CKAN_ORGANIZATION, --ckan-organization CKAN_ORGANIZATION
|
|
261
|
+
Identifier of the CKAN organization that hosts the dataset resource to transfer. Could be identified by the organization id, name or title
|
|
262
|
+
-d CKAN_DATASET, --ckan-dataset CKAN_DATASET
|
|
263
|
+
Identifier of the CKAN dataset that hosts the resource to transfer. Could be identified by the dataset id, name or title
|
|
264
|
+
-ma METEOFRANCE_APIKEY, --meteofrance-api-key METEOFRANCE_API_KEY
|
|
265
|
+
MeteoFrance API key
|
|
266
|
+
-mc METEOFRANCE_CONFIG, --meteofrance-api-key METEOFRANCE_CONFIG
|
|
267
|
+
MeteoFrance JSON configuration file
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
The configuration file has the following structure:
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
{
|
|
274
|
+
"url": "https://public-api.meteofrance.fr/public/arpege/1.0/wcs/MF-NWP-GLOBAL-ARPEGE-01-EUROPE-WCS/GetCoverage?service=WCS&version=2.0.1&format=image/tiff&REQUEST=GetCoverage",
|
|
275
|
+
"coverages": [
|
|
276
|
+
{
|
|
277
|
+
"coverageid": "TOTAL_PRECIPITATION__GROUND_OR_WATER_SURFACE___2026-06-04T00:00:00Z_PT1H",
|
|
278
|
+
"subsets": ["lat(34.50,66)", "long(-11,42)", "time(2026-06-04T06:00:00Z)"]},
|
|
279
|
+
{
|
|
280
|
+
"coverageid": "TOTAL_PRECIPITATION__GROUND_OR_WATER_SURFACE___2026-06-04T00:00:00Z_PT1H",
|
|
281
|
+
"subsets": ["lat(34.50,66)", "long(-11,42)", "time(2026-06-04T07:00:00Z)"]}
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
It requires the URL of the API that belongs to the target model and then a list of the coverages to obtain. These coverages will need the ID of the parameter as available in the API and the corresponding subsets. A detailed description of the coverageids available and their corresponding subsets is available on the API documentation.
|
|
287
|
+
|
|
288
|
+
#### ECMWF
|
|
289
|
+
Transfer data from the ECMWF model to CKAN or HDFS. Obtaining data from [ECMWF open data services](https://www.ecmwf.int/en/forecasts/datasets/open-data) requires that the user creates a Python script that will connect to the service and download the data specified in it. As per the [ECMWF-opendata documentation](https://github.com/ecmwf/ecmwf-opendata)
|
|
290
|
+
|
|
291
|
+
Here is an example of a simple script:
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
from ecmwf.opendata import Client
|
|
295
|
+
|
|
296
|
+
client = Client(source="google", beta=False)
|
|
297
|
+
client.retrieve(
|
|
298
|
+
time=0,
|
|
299
|
+
stream="oper",
|
|
300
|
+
type="fc",
|
|
301
|
+
step=24,
|
|
302
|
+
param="2t",
|
|
303
|
+
target="ecmwf_script.grib",
|
|
304
|
+
)
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Note that it is necessary to ensure that the *target* file name is the same as the one provided as **CKAN_RESOURCE** a parameter when using the command and also that the python script's name is something other than `ecmwf.py`
|
|
308
|
+
|
|
309
|
+
See the help of one of these commands:
|
|
310
|
+
|
|
311
|
+
`./dtcli ecmwf2ckan -h`
|
|
312
|
+
|
|
313
|
+
obtaining:
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
usage: ['ecmwf2ckan', '-h'] ecmwf2ckan [-h] -c CKAN_HOST -a CKAN_API_KEY -o CKAN_ORGANIZATION -d CKAN_DATASET -r CKAN_RESOURCE -s ECMWF_SCRIPT
|
|
317
|
+
|
|
318
|
+
options:
|
|
319
|
+
-h, --help show this help message and exit
|
|
320
|
+
-c CKAN_HOST, --ckan-host CKAN_HOST
|
|
321
|
+
CKAN host endpoint
|
|
322
|
+
-a CKAN_API_KEY, --ckan-api-key CKAN_API_KEY
|
|
323
|
+
CKAN API key
|
|
324
|
+
-o CKAN_ORGANIZATION, --ckan-organization CKAN_ORGANIZATION
|
|
325
|
+
Identifier of the CKAN organization that hosts the dataset resource to transfer. Could be identified by the organization id, name or title
|
|
326
|
+
-d CKAN_DATASET, --ckan-dataset CKAN_DATASET
|
|
327
|
+
Identifier of the CKAN dataset that hosts the resource to transfer. Could be identified by the dataset id, name or title
|
|
328
|
+
-r CKAN_RESOURCE, --ckan-resource CKAN_RESOURCE
|
|
329
|
+
CKAN resource to create from transferred sources. If omitted, target resource name will adopt the source file or folder name
|
|
330
|
+
-s ECMWF_SCRIPT, --ecmwf-script ECMWF_SCRIPT
|
|
331
|
+
Path to ECMWF open data service python script
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
233
337
|
## Support for HPC clusters that require a 2FA token
|
|
234
338
|
The Data Transfer CLI tool's commands support transferring data to/from HPC clusters that require a 2FA token. These commands offer an optional flag *_2fa*. If set by the user, the command prompts the user (in the standard input) for the token when required.
|
|
235
339
|
|
|
@@ -3,8 +3,6 @@ This repository contains the implementation of the Hidalgo2 data transfer tool.
|
|
|
3
3
|
|
|
4
4
|
## Features
|
|
5
5
|
This tool is planning to support the following features:
|
|
6
|
-
- transfer datasets from Cloud Providers to HDFS
|
|
7
|
-
- transfer datasets from Cloud Providers to CKAN
|
|
8
6
|
- transfer datasets from/to Hadoop HDFS to/from HPC
|
|
9
7
|
- transfer datasets from/to Hadoop HDFS to/from CKAN
|
|
10
8
|
- transfer datasets from/to a CKAN to/from HPC
|
|
@@ -16,6 +14,8 @@ Current version supports the following features:
|
|
|
16
14
|
- transfer datasets from/to Hadoop HDFS to/from CKAN
|
|
17
15
|
- transfer datasets from/to a CKAN to/from HPC
|
|
18
16
|
- transfer datasets from/to local filesystem to/from CKAN
|
|
17
|
+
- transfer datasets from Cloud Providers to HDFS
|
|
18
|
+
- transfer datasets from Cloud Providers to CKAN
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
## Implementation
|
|
@@ -152,6 +152,10 @@ positional arguments:
|
|
|
152
152
|
hpc2ckan transfer data from HPC to a target CKAN
|
|
153
153
|
local2ckan transfer data from a local filesystem to a target CKAN
|
|
154
154
|
ckan2local transfer data from CKAN to a local filesystem
|
|
155
|
+
meteofrance2ckan download data from MeteoFrance service to a target CKAN
|
|
156
|
+
meteofrance2hdfs download data from MeteoFrance service to a target HDFS
|
|
157
|
+
ecmwf2ckan download data from the ECMWF open data service to a target CKAN
|
|
158
|
+
ecmwf2hdfs download data from the ECMWF open data service to a target HDFS
|
|
155
159
|
|
|
156
160
|
options:
|
|
157
161
|
-h, --help show this help message and exit
|
|
@@ -210,6 +214,105 @@ Transfer rate: 0.61 MB/s
|
|
|
210
214
|
Number of transferred files: 1
|
|
211
215
|
```
|
|
212
216
|
|
|
217
|
+
### Data Transfer from cloud providers usage
|
|
218
|
+
|
|
219
|
+
The Data Transfer CLI tool supports the transfer from MeteoFrance and the ECMWF open data service to either CKAN or HDFS. These commands are and their specific usage are as follows:
|
|
220
|
+
|
|
221
|
+
#### METEO FRANCE
|
|
222
|
+
Transfer data from Meteo France to CKAN or HDFS. Obtaining data from Meteo France requires that the user obtains an API_KEY for Meteo France's online API (available at [METEO FRANCE – API PORTAL](https://portail-api.meteofrance.fr/web/en/).
|
|
223
|
+
|
|
224
|
+
Both options (meteofrance2ckan and meteofrance2hdfs) require the API_KEY and a JSON-formatted configuration file where the data to download needs to be detailed. To get help for one of these commands execute:
|
|
225
|
+
|
|
226
|
+
`./dtcli meteofrance2ckan -h`
|
|
227
|
+
|
|
228
|
+
obtaining:
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
usage: ['meteofrance2ckan', '-h'] meteofrance2ckan [-h] -c CKAN_HOST -a CKAN_API_KEY -o CKAN_ORGANIZATION -d CKAN_DATASET -ma METEOFRANCE_API_KEY -mc METEOFRANCE_CONFIG
|
|
232
|
+
|
|
233
|
+
options:
|
|
234
|
+
-h, --help show this help message and exit
|
|
235
|
+
-c CKAN_HOST, --ckan-host CKAN_HOST
|
|
236
|
+
CKAN host endpoint
|
|
237
|
+
-a CKAN_API_KEY, --ckan-api-key CKAN_API_KEY
|
|
238
|
+
CKAN API key
|
|
239
|
+
-o CKAN_ORGANIZATION, --ckan-organization CKAN_ORGANIZATION
|
|
240
|
+
Identifier of the CKAN organization that hosts the dataset resource to transfer. Could be identified by the organization id, name or title
|
|
241
|
+
-d CKAN_DATASET, --ckan-dataset CKAN_DATASET
|
|
242
|
+
Identifier of the CKAN dataset that hosts the resource to transfer. Could be identified by the dataset id, name or title
|
|
243
|
+
-ma METEOFRANCE_APIKEY, --meteofrance-api-key METEOFRANCE_API_KEY
|
|
244
|
+
MeteoFrance API key
|
|
245
|
+
-mc METEOFRANCE_CONFIG, --meteofrance-api-key METEOFRANCE_CONFIG
|
|
246
|
+
MeteoFrance JSON configuration file
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
The configuration file has the following structure:
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
{
|
|
253
|
+
"url": "https://public-api.meteofrance.fr/public/arpege/1.0/wcs/MF-NWP-GLOBAL-ARPEGE-01-EUROPE-WCS/GetCoverage?service=WCS&version=2.0.1&format=image/tiff&REQUEST=GetCoverage",
|
|
254
|
+
"coverages": [
|
|
255
|
+
{
|
|
256
|
+
"coverageid": "TOTAL_PRECIPITATION__GROUND_OR_WATER_SURFACE___2026-06-04T00:00:00Z_PT1H",
|
|
257
|
+
"subsets": ["lat(34.50,66)", "long(-11,42)", "time(2026-06-04T06:00:00Z)"]},
|
|
258
|
+
{
|
|
259
|
+
"coverageid": "TOTAL_PRECIPITATION__GROUND_OR_WATER_SURFACE___2026-06-04T00:00:00Z_PT1H",
|
|
260
|
+
"subsets": ["lat(34.50,66)", "long(-11,42)", "time(2026-06-04T07:00:00Z)"]}
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
It requires the URL of the API that belongs to the target model and then a list of the coverages to obtain. These coverages will need the ID of the parameter as available in the API and the corresponding subsets. A detailed description of the coverageids available and their corresponding subsets is available on the API documentation.
|
|
266
|
+
|
|
267
|
+
#### ECMWF
|
|
268
|
+
Transfer data from the ECMWF model to CKAN or HDFS. Obtaining data from [ECMWF open data services](https://www.ecmwf.int/en/forecasts/datasets/open-data) requires that the user creates a Python script that will connect to the service and download the data specified in it. As per the [ECMWF-opendata documentation](https://github.com/ecmwf/ecmwf-opendata)
|
|
269
|
+
|
|
270
|
+
Here is an example of a simple script:
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
from ecmwf.opendata import Client
|
|
274
|
+
|
|
275
|
+
client = Client(source="google", beta=False)
|
|
276
|
+
client.retrieve(
|
|
277
|
+
time=0,
|
|
278
|
+
stream="oper",
|
|
279
|
+
type="fc",
|
|
280
|
+
step=24,
|
|
281
|
+
param="2t",
|
|
282
|
+
target="ecmwf_script.grib",
|
|
283
|
+
)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Note that it is necessary to ensure that the *target* file name is the same as the one provided as **CKAN_RESOURCE** a parameter when using the command and also that the python script's name is something other than `ecmwf.py`
|
|
287
|
+
|
|
288
|
+
See the help of one of these commands:
|
|
289
|
+
|
|
290
|
+
`./dtcli ecmwf2ckan -h`
|
|
291
|
+
|
|
292
|
+
obtaining:
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
usage: ['ecmwf2ckan', '-h'] ecmwf2ckan [-h] -c CKAN_HOST -a CKAN_API_KEY -o CKAN_ORGANIZATION -d CKAN_DATASET -r CKAN_RESOURCE -s ECMWF_SCRIPT
|
|
296
|
+
|
|
297
|
+
options:
|
|
298
|
+
-h, --help show this help message and exit
|
|
299
|
+
-c CKAN_HOST, --ckan-host CKAN_HOST
|
|
300
|
+
CKAN host endpoint
|
|
301
|
+
-a CKAN_API_KEY, --ckan-api-key CKAN_API_KEY
|
|
302
|
+
CKAN API key
|
|
303
|
+
-o CKAN_ORGANIZATION, --ckan-organization CKAN_ORGANIZATION
|
|
304
|
+
Identifier of the CKAN organization that hosts the dataset resource to transfer. Could be identified by the organization id, name or title
|
|
305
|
+
-d CKAN_DATASET, --ckan-dataset CKAN_DATASET
|
|
306
|
+
Identifier of the CKAN dataset that hosts the resource to transfer. Could be identified by the dataset id, name or title
|
|
307
|
+
-r CKAN_RESOURCE, --ckan-resource CKAN_RESOURCE
|
|
308
|
+
CKAN resource to create from transferred sources. If omitted, target resource name will adopt the source file or folder name
|
|
309
|
+
-s ECMWF_SCRIPT, --ecmwf-script ECMWF_SCRIPT
|
|
310
|
+
Path to ECMWF open data service python script
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
213
316
|
## Support for HPC clusters that require a 2FA token
|
|
214
317
|
The Data Transfer CLI tool's commands support transferring data to/from HPC clusters that require a 2FA token. These commands offer an optional flag *_2fa*. If set by the user, the command prompts the user (in the standard input) for the token when required.
|
|
215
318
|
|
|
@@ -63,6 +63,11 @@ class DataTransferProxy:
|
|
|
63
63
|
f"data_target={args.data_target},"
|
|
64
64
|
if hasattr(args, "data_target")
|
|
65
65
|
else ""
|
|
66
|
+
),
|
|
67
|
+
(
|
|
68
|
+
f"data_script={args.data_script},"
|
|
69
|
+
if hasattr(args, "data_script")
|
|
70
|
+
else ""
|
|
66
71
|
),
|
|
67
72
|
f"hpc_host={args.hpc_host}," if hasattr(args, "hpc_host") else "",
|
|
68
73
|
f"hpc_port={args.hpc_port}," if hasattr(args, "hpc_port") else "",
|
|
@@ -333,6 +338,86 @@ class DataTransferProxy:
|
|
|
333
338
|
except Exception as ex:
|
|
334
339
|
raise HidDataTransferException(ex) from ex
|
|
335
340
|
|
|
341
|
+
def meteofrance2ckan(self, args) -> tuple[str, AccountingInfo]:
|
|
342
|
+
"""transfer data from meteofrance to CKAN"""
|
|
343
|
+
self.__logger.info(
|
|
344
|
+
"executing meteofrance2ckan command with args: %s",
|
|
345
|
+
self.format_args_to_string(args),
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
try:
|
|
349
|
+
return self.dt_client.meteofrance2ckan(
|
|
350
|
+
ckan_host=args.ckan_host
|
|
351
|
+
if args.ckan_host.startswith("https") else f"https://{args.ckan_host}",
|
|
352
|
+
ckan_api_key=args.ckan_api_key,
|
|
353
|
+
ckan_organization=args.ckan_organization,
|
|
354
|
+
ckan_dataset=args.ckan_dataset,
|
|
355
|
+
meteofrance_apikey=args.meteofrance_apikey,
|
|
356
|
+
meteofrance_config=args.meteofrance_config,
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
except Exception as ex:
|
|
360
|
+
raise HidDataTransferException(ex) from ex
|
|
361
|
+
|
|
362
|
+
def meteofrance2hdfs(self, args) -> tuple[str, AccountingInfo]:
|
|
363
|
+
"""transfer data from meteofrance to HDFS"""
|
|
364
|
+
self.__logger.info(
|
|
365
|
+
"executing meteofrance2hdfs command with args: %s",
|
|
366
|
+
self.format_args_to_string(args),
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
try:
|
|
370
|
+
return self.dt_client.meteofrance2hdfs(
|
|
371
|
+
data_target=args.data_target,
|
|
372
|
+
kerberos_principal=args.kerberos_principal,
|
|
373
|
+
kerberos_password=args.kerberos_password,
|
|
374
|
+
meteofrance_apikey=args.meteofrance_apikey,
|
|
375
|
+
meteofrance_config=args.meteofrance_config,
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
except Exception as ex:
|
|
379
|
+
raise HidDataTransferException(ex) from ex
|
|
380
|
+
|
|
381
|
+
def ecmwf2ckan(self, args) -> tuple[str, AccountingInfo]:
|
|
382
|
+
"""transfer data from ECMWF to CKAN"""
|
|
383
|
+
self.__logger.info(
|
|
384
|
+
"executing ecmwf2ckan command with args: %s",
|
|
385
|
+
self.format_args_to_string(args),
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
try:
|
|
389
|
+
return self.dt_client.ecmwf2ckan(
|
|
390
|
+
data_script=args.data_script,
|
|
391
|
+
ckan_host=args.ckan_host
|
|
392
|
+
if args.ckan_host.startswith("https") else f"https://{args.ckan_host}",
|
|
393
|
+
ckan_api_key=args.ckan_api_key,
|
|
394
|
+
ckan_organization=args.ckan_organization,
|
|
395
|
+
ckan_dataset=args.ckan_dataset,
|
|
396
|
+
ckan_resource=args.ckan_resource,
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
except Exception as ex:
|
|
400
|
+
raise HidDataTransferException(ex) from ex
|
|
401
|
+
|
|
402
|
+
def ecmwf2hdfs(self, args) -> tuple[str, AccountingInfo]:
|
|
403
|
+
"""transfer data from ECMWF to HDFS"""
|
|
404
|
+
self.__logger.info(
|
|
405
|
+
"executing ecmwf2hdfs command with args: %s",
|
|
406
|
+
self.format_args_to_string(args),
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
try:
|
|
410
|
+
return self.dt_client.ecmwf2hdfs(
|
|
411
|
+
data_script=args.data_script,
|
|
412
|
+
data_target=args.data_target,
|
|
413
|
+
data_source=args.data_source,
|
|
414
|
+
kerberos_principal=args.kerberos_principal,
|
|
415
|
+
kerberos_password=args.kerberos_password,
|
|
416
|
+
)
|
|
417
|
+
|
|
418
|
+
except Exception as ex:
|
|
419
|
+
raise HidDataTransferException(ex) from ex
|
|
420
|
+
|
|
336
421
|
def check_command_status(self, args):
|
|
337
422
|
"""Checks the status of a CLI command by ID"""
|
|
338
423
|
# Check process group state by id
|
|
@@ -178,6 +178,32 @@ class CLIParser(argparse.ArgumentParser):
|
|
|
178
178
|
)
|
|
179
179
|
return parser
|
|
180
180
|
|
|
181
|
+
def add_default_meteofrance_arguments(self, parser):
|
|
182
|
+
"""Add default MeteoFrance arguments to the parser"""
|
|
183
|
+
parser.add_argument(
|
|
184
|
+
"-ma",
|
|
185
|
+
"--meteofrance-apikey",
|
|
186
|
+
required=True,
|
|
187
|
+
help="MeteoFrance API key",
|
|
188
|
+
)
|
|
189
|
+
parser.add_argument(
|
|
190
|
+
"-mc",
|
|
191
|
+
"--meteofrance-config",
|
|
192
|
+
required=True,
|
|
193
|
+
help="MeteoFrance JSON configuration file",
|
|
194
|
+
)
|
|
195
|
+
return parser
|
|
196
|
+
|
|
197
|
+
def add_default_ecmwf_arguments(self, parser):
|
|
198
|
+
"""Add default ECMWF arguments to the parser"""
|
|
199
|
+
parser.add_argument(
|
|
200
|
+
"-s",
|
|
201
|
+
"--data-script",
|
|
202
|
+
required=True,
|
|
203
|
+
help="ECMWF data download script full path",
|
|
204
|
+
)
|
|
205
|
+
return parser
|
|
206
|
+
|
|
181
207
|
def parse_arguments(self, args, target):
|
|
182
208
|
"""parse the command line arguments
|
|
183
209
|
|
|
@@ -479,4 +505,83 @@ class CLIParser(argparse.ArgumentParser):
|
|
|
479
505
|
)
|
|
480
506
|
ckan2local_parser.set_defaults(func=target.ckan2local)
|
|
481
507
|
|
|
508
|
+
# meteofrance2ckan
|
|
509
|
+
meteofrance2ckan_parser = commands_parsers.add_parser(
|
|
510
|
+
"meteofrance2ckan", help="transfer data from MeteoFrance to a target CKAN"
|
|
511
|
+
)
|
|
512
|
+
meteofrance2ckan_parser = self.add_default_meteofrance_arguments(meteofrance2ckan_parser)
|
|
513
|
+
meteofrance2ckan_parser = self.add_default_ckan_arguments(meteofrance2ckan_parser)
|
|
514
|
+
|
|
515
|
+
meteofrance2ckan_parser.add_argument(
|
|
516
|
+
"-acct", "--accounting",
|
|
517
|
+
required=False, action="store_true", default=False,
|
|
518
|
+
help="[Optional] Enable returning accounting information of data transfer"
|
|
519
|
+
)
|
|
520
|
+
|
|
521
|
+
meteofrance2ckan_parser.set_defaults(func=target.meteofrance2ckan)
|
|
522
|
+
|
|
523
|
+
#meteofrance2hdfs
|
|
524
|
+
meteofrance2hdfs_parser = commands_parsers.add_parser(
|
|
525
|
+
"meteofrance2hdfs", help="transfer data from MeteoFrance to target HDFS"
|
|
526
|
+
)
|
|
527
|
+
|
|
528
|
+
meteofrance2hdfs_parser.add_argument(
|
|
529
|
+
"-t", "--data-target", required=True, help="HDFS folder"
|
|
530
|
+
)
|
|
531
|
+
meteofrance2hdfs_parser = self.add_default_kerberos_arguments(meteofrance2hdfs_parser)
|
|
532
|
+
meteofrance2hdfs_parser = self.add_default_meteofrance_arguments(meteofrance2hdfs_parser)
|
|
533
|
+
meteofrance2hdfs_parser.add_argument(
|
|
534
|
+
"-acct", "--accounting",
|
|
535
|
+
required=False, action="store_true", default=False,
|
|
536
|
+
help="[Optional] Enable returning accounting information of data transfer"
|
|
537
|
+
)
|
|
538
|
+
|
|
539
|
+
meteofrance2hdfs_parser.set_defaults(func=target.meteofrance2hdfs)
|
|
540
|
+
|
|
541
|
+
# ecmwf2ckan
|
|
542
|
+
ecmwf2ckan_parser = commands_parsers.add_parser(
|
|
543
|
+
"ecmwf2ckan", help="transfer data from ECMWF to a target CKAN"
|
|
544
|
+
)
|
|
545
|
+
ecmwf2ckan_parser = self.add_default_ecmwf_arguments(ecmwf2ckan_parser)
|
|
546
|
+
ecmwf2ckan_parser = self.add_default_ckan_arguments(ecmwf2ckan_parser)
|
|
547
|
+
ecmwf2ckan_parser.add_argument(
|
|
548
|
+
"-r",
|
|
549
|
+
"--ckan-resource",
|
|
550
|
+
required=False,
|
|
551
|
+
help="CKAN resource to create from transferred sources. \
|
|
552
|
+
It has to be the same name as the one configured in the download script.",
|
|
553
|
+
)
|
|
554
|
+
ecmwf2ckan_parser.add_argument(
|
|
555
|
+
"-acct", "--accounting",
|
|
556
|
+
required=False, action="store_true", default=False,
|
|
557
|
+
help="[Optional] Enable returning accounting information of data transfer"
|
|
558
|
+
)
|
|
559
|
+
|
|
560
|
+
ecmwf2ckan_parser.set_defaults(func=target.ecmwf2ckan)
|
|
561
|
+
|
|
562
|
+
# ecmwf2hdfs
|
|
563
|
+
ecmwf2hdfs_parser = commands_parsers.add_parser(
|
|
564
|
+
"ecmwf2hdfs", help="transfer data from ECMWF to a target HDFS"
|
|
565
|
+
)
|
|
566
|
+
ecmwf2hdfs_parser = self.add_default_ecmwf_arguments(ecmwf2hdfs_parser)
|
|
567
|
+
ecmwf2hdfs_parser.add_argument(
|
|
568
|
+
"-t", "--data-target", required=True, help="HDFS folder"
|
|
569
|
+
)
|
|
570
|
+
ecmwf2hdfs_parser.add_argument(
|
|
571
|
+
"-r",
|
|
572
|
+
"--data-source",
|
|
573
|
+
required=False,
|
|
574
|
+
help="Filename of the downloaded data. \
|
|
575
|
+
It has to be the same name as the one configured in the download script.",
|
|
576
|
+
)
|
|
577
|
+
ecmwf2hdfs_parser = self.add_default_kerberos_arguments(ecmwf2hdfs_parser)
|
|
578
|
+
|
|
579
|
+
ecmwf2hdfs_parser.add_argument(
|
|
580
|
+
"-acct", "--accounting",
|
|
581
|
+
required=False, action="store_true", default=False,
|
|
582
|
+
help="[Optional] Enable returning accounting information of data transfer"
|
|
583
|
+
)
|
|
584
|
+
|
|
585
|
+
ecmwf2hdfs_parser.set_defaults(func=target.ecmwf2hdfs)
|
|
586
|
+
|
|
482
587
|
return self.parse_args(args)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "data-transfer-cli"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.5.0"
|
|
4
4
|
description = "HiDALGO Data Transfer CLI provides commands to transfer data between different data providers and consumers using NIFI pipelines"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Jesús Gorroñogoitia", email = "jesus.gorronogoitia@eviden.com" },
|
|
7
|
+
{ name = "Angela Rivera", email = "angela@meteogrid.com" },
|
|
7
8
|
]
|
|
8
9
|
license = "APL-2.0"
|
|
9
10
|
readme = "README.md"
|
|
@@ -11,9 +12,9 @@ requires-python = ">=3.11, <4.0"
|
|
|
11
12
|
dependencies = [
|
|
12
13
|
"requests>=2.31.0",
|
|
13
14
|
"paramiko>=3.3.1",
|
|
14
|
-
"hid_data_transfer_lib>=0.
|
|
15
|
+
"hid_data_transfer_lib>=0.5.0",
|
|
15
16
|
"pyyaml (>=6.0.2,<7.0.0)",
|
|
16
|
-
# "hid-data-transfer-lib @ file:///home/yosu/Projects/Hidalgo2/git/hid-data-management/data-transfer/nifi/hid_data_transfer_lib
|
|
17
|
+
# "hid-data-transfer-lib @ file:///home/yosu/Projects/Hidalgo2/git/hid-data-management/data-transfer/nifi/hid_data_transfer_lib",
|
|
17
18
|
]
|
|
18
19
|
|
|
19
20
|
[tool.poetry]
|
|
@@ -25,7 +26,7 @@ include = ["dtcli", "setenv.sh"]
|
|
|
25
26
|
|
|
26
27
|
[tool.poetry.dependencies]
|
|
27
28
|
# Comment out when using the version installed in Pypi
|
|
28
|
-
# hid_data_transfer_lib = { path = "../hid_data_transfer_lib
|
|
29
|
+
# hid_data_transfer_lib = { path = "../hid_data_transfer_lib", develop = true }
|
|
29
30
|
|
|
30
31
|
[tool.poetry.group.dev.dependencies]
|
|
31
32
|
flake8 = "^6.1.0"
|
|
@@ -33,6 +34,7 @@ black = "^23.9.1"
|
|
|
33
34
|
pytest = "^7.4.2"
|
|
34
35
|
pytest-cov = "^5.0.0"
|
|
35
36
|
pytest-env = "^1.1.3"
|
|
37
|
+
python-dotenv = "^1.2.4"
|
|
36
38
|
|
|
37
39
|
[tool.poetry.group.types.dependencies]
|
|
38
40
|
types-paramiko = "^3.4.0.20240311"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|