opentf-toolkit-nightly 0.59.0.dev1204__py3-none-any.whl → 0.59.0.dev1211__py3-none-any.whl
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.
- opentf/toolkit/channels.py +62 -19
- {opentf_toolkit_nightly-0.59.0.dev1204.dist-info → opentf_toolkit_nightly-0.59.0.dev1211.dist-info}/METADATA +1 -1
- {opentf_toolkit_nightly-0.59.0.dev1204.dist-info → opentf_toolkit_nightly-0.59.0.dev1211.dist-info}/RECORD +6 -6
- {opentf_toolkit_nightly-0.59.0.dev1204.dist-info → opentf_toolkit_nightly-0.59.0.dev1211.dist-info}/WHEEL +1 -1
- {opentf_toolkit_nightly-0.59.0.dev1204.dist-info → opentf_toolkit_nightly-0.59.0.dev1211.dist-info}/LICENSE +0 -0
- {opentf_toolkit_nightly-0.59.0.dev1204.dist-info → opentf_toolkit_nightly-0.59.0.dev1211.dist-info}/top_level.txt +0 -0
opentf/toolkit/channels.py
CHANGED
|
@@ -19,6 +19,7 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
|
|
19
19
|
|
|
20
20
|
from shlex import quote
|
|
21
21
|
|
|
22
|
+
import fnmatch
|
|
22
23
|
import ntpath
|
|
23
24
|
import os
|
|
24
25
|
import re
|
|
@@ -36,6 +37,7 @@ from opentf.toolkit import core
|
|
|
36
37
|
SETOUTPUT_COMMAND = re.compile(r'^::set-output\s+name=([a-zA-Z_][a-zA-Z0-9_-]*)::(.*)$')
|
|
37
38
|
ATTACH_COMMAND = re.compile(r'^::attach(\s+.*?)?::(.*?)\s*$')
|
|
38
39
|
UPLOAD_COMMAND = re.compile(r'^::upload(\s+.*?)?::(.*?)\s*$')
|
|
40
|
+
DOWNLOAD_COMMAND = re.compile(r'^::download(\s+.*?)?::(.*?)\s*$')
|
|
39
41
|
DEBUG_COMMAND = re.compile(r'^::debug::(.*)$')
|
|
40
42
|
WARNING_COMMAND = re.compile(r'^::warning(\s+(.*)+)?::(.*)$')
|
|
41
43
|
ERROR_COMMAND = re.compile(r'^::error(\s+(.*)+)?::(.*)$')
|
|
@@ -197,6 +199,18 @@ def _make_attachment_url(
|
|
|
197
199
|
return url, uuid
|
|
198
200
|
|
|
199
201
|
|
|
202
|
+
def _get_cmd_params(args: str, logs: List[str]):
|
|
203
|
+
details = {}
|
|
204
|
+
if args:
|
|
205
|
+
for parameter in args.strip().split(','):
|
|
206
|
+
if '=' not in parameter:
|
|
207
|
+
logs.append(f'ERROR,Invalid workflow command parameter: {parameter}.')
|
|
208
|
+
return 2
|
|
209
|
+
key, _, value = parameter.strip().partition('=')
|
|
210
|
+
details[key] = value
|
|
211
|
+
return details
|
|
212
|
+
|
|
213
|
+
|
|
200
214
|
## masks helpers
|
|
201
215
|
|
|
202
216
|
|
|
@@ -293,6 +307,7 @@ def process_upload(result: Dict[str, Any]):
|
|
|
293
307
|
'name': result['metadata'].get('step_id'),
|
|
294
308
|
'namespace': result['metadata']['namespace'],
|
|
295
309
|
'workflow_id': result['metadata']['workflow_id'],
|
|
310
|
+
'job_id': result['metadata']['job_id'],
|
|
296
311
|
}
|
|
297
312
|
return make_event(WORKFLOWRESULT, metadata=metadata, attachments=upload)
|
|
298
313
|
|
|
@@ -340,26 +355,24 @@ def process_output(
|
|
|
340
355
|
May raise exceptions.
|
|
341
356
|
"""
|
|
342
357
|
|
|
358
|
+
def _get_targeted_path(remote_path: str):
|
|
359
|
+
working_directory = core.join_path(
|
|
360
|
+
metadata['job_id'], event.get('working-directory'), is_windows
|
|
361
|
+
)
|
|
362
|
+
return core.join_path(working_directory, remote_path, is_windows)
|
|
363
|
+
|
|
343
364
|
def _attach(remote: str, args: str, is_artefact: bool = False):
|
|
344
365
|
if is_windows:
|
|
345
366
|
remote = ntpath.normpath(remote)
|
|
346
367
|
try:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
for parameter in args.strip().split(','):
|
|
350
|
-
if '=' not in parameter:
|
|
351
|
-
logs.append(
|
|
352
|
-
f'ERROR,Invalid workflow command parameter: {parameter}.'
|
|
353
|
-
)
|
|
354
|
-
return 2
|
|
355
|
-
key, _, value = parameter.strip().partition('=')
|
|
356
|
-
details[key] = value
|
|
368
|
+
if (params := _get_cmd_params(args, logs)) == 2:
|
|
369
|
+
return 2
|
|
357
370
|
attachment_url, uuid = _make_attachment_url(
|
|
358
|
-
metadata, remote, separator, is_artefact, name=
|
|
371
|
+
metadata, remote, separator, is_artefact, name=params.get('name')
|
|
359
372
|
)
|
|
360
|
-
|
|
373
|
+
params['uuid'] = uuid
|
|
361
374
|
_get(remote, attachment_url)
|
|
362
|
-
attachments_metadata[attachment_url] =
|
|
375
|
+
attachments_metadata[attachment_url] = params
|
|
363
376
|
attachments.append(attachment_url)
|
|
364
377
|
return resp
|
|
365
378
|
except Exception as err:
|
|
@@ -367,12 +380,7 @@ def process_output(
|
|
|
367
380
|
return 2
|
|
368
381
|
|
|
369
382
|
def _putfile(remote_path: str, data: str):
|
|
370
|
-
|
|
371
|
-
metadata['job_id'], event.get('working-directory'), is_windows
|
|
372
|
-
)
|
|
373
|
-
targeted_remote_path = core.join_path(
|
|
374
|
-
working_directory, remote_path, is_windows
|
|
375
|
-
)
|
|
383
|
+
targeted_remote_path = _get_targeted_path(remote_path)
|
|
376
384
|
try:
|
|
377
385
|
file_ = f'/tmp/in_{metadata["workflow_id"]}_{data}'
|
|
378
386
|
if not os.path.exists(file_):
|
|
@@ -386,6 +394,36 @@ def process_output(
|
|
|
386
394
|
)
|
|
387
395
|
return 2
|
|
388
396
|
|
|
397
|
+
def _download(remote_path: str, args: str):
|
|
398
|
+
if not (artifacts := event['metadata'].get('artifacts')):
|
|
399
|
+
logs.append('ERROR,No artifacts available at workflow level.')
|
|
400
|
+
return 2
|
|
401
|
+
try:
|
|
402
|
+
targeted_remote_path = _get_targeted_path(remote_path)
|
|
403
|
+
if (params := _get_cmd_params(args, logs)) == 2:
|
|
404
|
+
return 2
|
|
405
|
+
filename, pattern = params.get('file'), params.get('pattern')
|
|
406
|
+
for artifact in artifacts:
|
|
407
|
+
artifact_name = artifact.split('_')[-1]
|
|
408
|
+
if filename and filename == artifact_name:
|
|
409
|
+
if not remote_path:
|
|
410
|
+
targeted_remote_path = core.join_path(
|
|
411
|
+
targeted_remote_path, artifact_name, is_windows
|
|
412
|
+
)
|
|
413
|
+
_put(targeted_remote_path, artifact)
|
|
414
|
+
continue
|
|
415
|
+
if pattern and fnmatch.fnmatch(artifact_name, pattern):
|
|
416
|
+
pattern_path = core.join_path(
|
|
417
|
+
targeted_remote_path, artifact_name, is_windows
|
|
418
|
+
)
|
|
419
|
+
_put(pattern_path, artifact)
|
|
420
|
+
return resp
|
|
421
|
+
except Exception as err:
|
|
422
|
+
logs.append(
|
|
423
|
+
f'ERROR,Could not send artifacts to remote path {remote_path}: {err}.'
|
|
424
|
+
)
|
|
425
|
+
return 2
|
|
426
|
+
|
|
389
427
|
metadata: Dict[str, Any] = event['metadata']
|
|
390
428
|
is_windows: bool = metadata['channel_os'] == 'windows'
|
|
391
429
|
separator = '\\' if is_windows else '/'
|
|
@@ -407,6 +445,8 @@ def process_output(
|
|
|
407
445
|
elif wcmd := UPLOAD_COMMAND.match(line):
|
|
408
446
|
has_artefacts = True
|
|
409
447
|
resp = _attach(wcmd.group(2), wcmd.group(1), is_artefact=True)
|
|
448
|
+
elif wcmd := DOWNLOAD_COMMAND.match(line):
|
|
449
|
+
resp = _download(wcmd.group(2), wcmd.group(1))
|
|
410
450
|
elif wcmd := PUT_FILE_COMMAND.match(line):
|
|
411
451
|
resp = _putfile(wcmd.group(2), wcmd.group(1))
|
|
412
452
|
elif wcmd := SETOUTPUT_COMMAND.match(line):
|
|
@@ -421,6 +461,9 @@ def process_output(
|
|
|
421
461
|
for line in stderr:
|
|
422
462
|
logs.append(mask(line, jobstate).rstrip())
|
|
423
463
|
|
|
464
|
+
if metadata.get('artifacts'):
|
|
465
|
+
del metadata['artifacts']
|
|
466
|
+
|
|
424
467
|
result = make_event(EXECUTIONRESULT, metadata=metadata, status=resp)
|
|
425
468
|
|
|
426
469
|
if outputs:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: opentf-toolkit-nightly
|
|
3
|
-
Version: 0.59.0.
|
|
3
|
+
Version: 0.59.0.dev1211
|
|
4
4
|
Summary: OpenTestFactory Orchestrator Toolkit
|
|
5
5
|
Home-page: https://gitlab.com/henixdevelopment/open-source/opentestfactory/python-toolkit
|
|
6
6
|
Author: Martin Lafaix
|
|
@@ -56,10 +56,10 @@ opentf/schemas/opentestfactory.org/v1beta2/ServiceConfig.json,sha256=rEvK2YWL5lG
|
|
|
56
56
|
opentf/scripts/launch_java_service.sh,sha256=S0jAaCuv2sZy0Gf2NGBuPX-eD531rcM-b0fNyhmzSjw,2423
|
|
57
57
|
opentf/scripts/startup.py,sha256=sggwEpMx7PTaSgYzs-2uCF5YZzpsncMyTlfF_G60CrE,21518
|
|
58
58
|
opentf/toolkit/__init__.py,sha256=mYeJPZ92ulbTBItqEsZgF4nnuRh6G19QPY3Jxc92ifc,23028
|
|
59
|
-
opentf/toolkit/channels.py,sha256=
|
|
59
|
+
opentf/toolkit/channels.py,sha256=kXgygE4mBw1AihdwWWlONMvN4yhbBmML4ytxb1Bgskg,23384
|
|
60
60
|
opentf/toolkit/core.py,sha256=cscUkwdwvLkerqMRL05dgtKJ42QbBQQc28kRBiyZM9o,9883
|
|
61
|
-
opentf_toolkit_nightly-0.59.0.
|
|
62
|
-
opentf_toolkit_nightly-0.59.0.
|
|
63
|
-
opentf_toolkit_nightly-0.59.0.
|
|
64
|
-
opentf_toolkit_nightly-0.59.0.
|
|
65
|
-
opentf_toolkit_nightly-0.59.0.
|
|
61
|
+
opentf_toolkit_nightly-0.59.0.dev1211.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
62
|
+
opentf_toolkit_nightly-0.59.0.dev1211.dist-info/METADATA,sha256=Bhy1y4tVEqY9xVWE2JeEh192VHscQWYd-3OgaZGmNbg,1940
|
|
63
|
+
opentf_toolkit_nightly-0.59.0.dev1211.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
64
|
+
opentf_toolkit_nightly-0.59.0.dev1211.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
|
|
65
|
+
opentf_toolkit_nightly-0.59.0.dev1211.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|