opentf-toolkit-nightly 0.63.0.dev1404__py3-none-any.whl → 0.63.0.dev1410__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 +46 -10
- {opentf_toolkit_nightly-0.63.0.dev1404.dist-info → opentf_toolkit_nightly-0.63.0.dev1410.dist-info}/METADATA +1 -1
- {opentf_toolkit_nightly-0.63.0.dev1404.dist-info → opentf_toolkit_nightly-0.63.0.dev1410.dist-info}/RECORD +6 -6
- {opentf_toolkit_nightly-0.63.0.dev1404.dist-info → opentf_toolkit_nightly-0.63.0.dev1410.dist-info}/WHEEL +1 -1
- {opentf_toolkit_nightly-0.63.0.dev1404.dist-info → opentf_toolkit_nightly-0.63.0.dev1410.dist-info}/licenses/LICENSE +0 -0
- {opentf_toolkit_nightly-0.63.0.dev1404.dist-info → opentf_toolkit_nightly-0.63.0.dev1410.dist-info}/top_level.txt +0 -0
opentf/toolkit/channels.py
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Set, Tuple, Union
|
|
19
19
|
|
|
20
|
+
from copy import deepcopy
|
|
20
21
|
from datetime import datetime
|
|
21
22
|
from shlex import quote
|
|
22
23
|
|
|
@@ -46,7 +47,6 @@ STOPCOMMANDS_COMMAND = re.compile(r'^::stop-commands::(\w+)$')
|
|
|
46
47
|
ADDMASK_COMMAND = re.compile(r'^::add-mask::(.*)$')
|
|
47
48
|
PUT_FILE_COMMAND = re.compile(r'^::put\s+file=(.*?)\s*::(.*?)\s*$')
|
|
48
49
|
|
|
49
|
-
|
|
50
50
|
## step sequence IDs
|
|
51
51
|
|
|
52
52
|
CHANNEL_REQUEST = -1
|
|
@@ -313,6 +313,10 @@ class JobState:
|
|
|
313
313
|
def __init__(self) -> None:
|
|
314
314
|
self.stop_command: Optional[str] = None
|
|
315
315
|
self.masks: List[str] = []
|
|
316
|
+
self.output_commands: List[str] = []
|
|
317
|
+
self.attachments: List[str] = []
|
|
318
|
+
self.attachments_metadata: Dict[str, Any] = {}
|
|
319
|
+
self.artifacts_resp: bool = False
|
|
316
320
|
|
|
317
321
|
|
|
318
322
|
def mask(line: str, state: JobState) -> str:
|
|
@@ -332,6 +336,9 @@ def _as_log(line: str, jobstate: JobState):
|
|
|
332
336
|
return mask(line, jobstate).rstrip()
|
|
333
337
|
|
|
334
338
|
|
|
339
|
+
## artifacts
|
|
340
|
+
|
|
341
|
+
|
|
335
342
|
def process_upload(result: Dict[str, Any]) -> Dict[str, Any]:
|
|
336
343
|
"""Process ExecutionResult event containing .metadata.upload flag.
|
|
337
344
|
|
|
@@ -427,7 +434,7 @@ def _download_artifacts(
|
|
|
427
434
|
|
|
428
435
|
def process_output(
|
|
429
436
|
event: Dict[str, Any],
|
|
430
|
-
resp: int,
|
|
437
|
+
resp: Optional[int],
|
|
431
438
|
stdout: List[str],
|
|
432
439
|
stderr: List[str],
|
|
433
440
|
jobstate: JobState,
|
|
@@ -538,9 +545,16 @@ def process_output(
|
|
|
538
545
|
outputs = {}
|
|
539
546
|
logs: List[str] = []
|
|
540
547
|
attachments: List[str] = []
|
|
541
|
-
attachments_metadata = {}
|
|
548
|
+
attachments_metadata: Dict[str, Any] = {}
|
|
549
|
+
|
|
550
|
+
is_channel_notify = False
|
|
551
|
+
step_sequence_id = metadata['step_sequence_id']
|
|
552
|
+
if resp is None:
|
|
553
|
+
resp, is_channel_notify = 0, True
|
|
554
|
+
if not is_channel_notify and jobstate.output_commands:
|
|
555
|
+
stdout.extend(jobstate.output_commands)
|
|
556
|
+
jobstate.output_commands.clear()
|
|
542
557
|
|
|
543
|
-
has_artifacts = False
|
|
544
558
|
for line in stdout:
|
|
545
559
|
# Parsing stdout for workflow commands
|
|
546
560
|
if jobstate.stop_command:
|
|
@@ -548,10 +562,14 @@ def process_output(
|
|
|
548
562
|
jobstate.stop_command = None
|
|
549
563
|
continue
|
|
550
564
|
|
|
565
|
+
if is_channel_notify and SETOUTPUT_COMMAND.match(line):
|
|
566
|
+
jobstate.output_commands.append(line)
|
|
567
|
+
continue
|
|
568
|
+
|
|
551
569
|
if wcmd := ATTACH_COMMAND.match(line):
|
|
552
570
|
resp = _attach(wcmd.group(2), wcmd.group(1))
|
|
553
571
|
elif wcmd := UPLOAD_COMMAND.match(line):
|
|
554
|
-
|
|
572
|
+
jobstate.artifacts_resp = True
|
|
555
573
|
resp = _attach(wcmd.group(2), wcmd.group(1), is_artifact=True)
|
|
556
574
|
elif wcmd := DOWNLOAD_COMMAND.match(line):
|
|
557
575
|
resp = _download(wcmd.group(2), wcmd.group(1))
|
|
@@ -569,11 +587,23 @@ def process_output(
|
|
|
569
587
|
for line in stderr:
|
|
570
588
|
logs.append(mask(line, jobstate).rstrip())
|
|
571
589
|
|
|
590
|
+
if is_channel_notify:
|
|
591
|
+
notify = make_event(EXECUTIONRESULT, metadata=deepcopy(metadata), status=resp)
|
|
592
|
+
notify['metadata']['step_sequence_id_origin'] = metadata['step_sequence_id']
|
|
593
|
+
notify['metadata']['step_sequence_id'] = CHANNEL_NOTIFY
|
|
594
|
+
notify['logs'] = logs
|
|
595
|
+
if notify['metadata'].get('artifacts'):
|
|
596
|
+
del notify['metadata']['artifacts']
|
|
597
|
+
if attachments:
|
|
598
|
+
jobstate.attachments.extend(attachments)
|
|
599
|
+
jobstate.attachments_metadata.update(attachments_metadata)
|
|
600
|
+
return notify
|
|
601
|
+
|
|
572
602
|
if metadata.get('artifacts'):
|
|
573
603
|
del metadata['artifacts']
|
|
574
604
|
|
|
575
605
|
opentf_variables = None
|
|
576
|
-
if
|
|
606
|
+
if step_sequence_id != CHANNEL_RELEASE:
|
|
577
607
|
if variables:
|
|
578
608
|
opentf_variables = _read_opentf_variables(variables)
|
|
579
609
|
else:
|
|
@@ -586,11 +616,17 @@ def process_output(
|
|
|
586
616
|
result['outputs'] = outputs
|
|
587
617
|
if logs:
|
|
588
618
|
result['logs'] = logs
|
|
589
|
-
if attachments:
|
|
590
|
-
result['attachments'] = attachments
|
|
591
|
-
result['metadata']['attachments'] =
|
|
592
|
-
|
|
619
|
+
if attachments or jobstate.attachments:
|
|
620
|
+
result['attachments'] = jobstate.attachments + attachments
|
|
621
|
+
result['metadata']['attachments'] = {
|
|
622
|
+
**jobstate.attachments_metadata,
|
|
623
|
+
**attachments_metadata,
|
|
624
|
+
}
|
|
625
|
+
jobstate.attachments.clear()
|
|
626
|
+
jobstate.attachments_metadata = {}
|
|
627
|
+
if jobstate.artifacts_resp:
|
|
593
628
|
result['metadata']['upload'] = resp
|
|
629
|
+
jobstate.artifacts_resp = False
|
|
594
630
|
if opentf_variables:
|
|
595
631
|
result['variables'] = opentf_variables
|
|
596
632
|
return result
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opentf-toolkit-nightly
|
|
3
|
-
Version: 0.63.0.
|
|
3
|
+
Version: 0.63.0.dev1410
|
|
4
4
|
Summary: OpenTestFactory Orchestrator Toolkit
|
|
5
5
|
Home-page: https://gitlab.com/henixdevelopment/open-source/opentestfactory/python-toolkit
|
|
6
6
|
Author: Martin Lafaix
|
|
@@ -58,11 +58,11 @@ opentf/schemas/opentestfactory.org/v1beta2/ServiceConfig.json,sha256=rEvK2YWL5lG
|
|
|
58
58
|
opentf/scripts/launch_java_service.sh,sha256=S0jAaCuv2sZy0Gf2NGBuPX-eD531rcM-b0fNyhmzSjw,2423
|
|
59
59
|
opentf/scripts/startup.py,sha256=DLanDaXutUTYcG2PwoJ34QH-5G0TwfLUY_xy1VkVOqA,23202
|
|
60
60
|
opentf/toolkit/__init__.py,sha256=YnH66dmePAIU7dq_xWFYTIEUrsL9qV9f82LRDiBzbzs,22057
|
|
61
|
-
opentf/toolkit/channels.py,sha256=
|
|
61
|
+
opentf/toolkit/channels.py,sha256=BQh5ztQmIKpxns6ozDNto4YpegktydPZyhOO9F3g-2Q,27731
|
|
62
62
|
opentf/toolkit/core.py,sha256=jMBDIYZ8Qn3BvsysfKoG0iTtjOnZsggetpH3eXygCsI,9636
|
|
63
63
|
opentf/toolkit/models.py,sha256=PNfXVQbeyOwDfaNrLjcfhYm6duMSlNWBtZsWZcs53ag,6583
|
|
64
|
-
opentf_toolkit_nightly-0.63.0.
|
|
65
|
-
opentf_toolkit_nightly-0.63.0.
|
|
66
|
-
opentf_toolkit_nightly-0.63.0.
|
|
67
|
-
opentf_toolkit_nightly-0.63.0.
|
|
68
|
-
opentf_toolkit_nightly-0.63.0.
|
|
64
|
+
opentf_toolkit_nightly-0.63.0.dev1410.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
65
|
+
opentf_toolkit_nightly-0.63.0.dev1410.dist-info/METADATA,sha256=JGYwdjQVyIzFakde1XO0lPfaQgH5qfY6RsHHSM6Bmfo,2215
|
|
66
|
+
opentf_toolkit_nightly-0.63.0.dev1410.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
|
67
|
+
opentf_toolkit_nightly-0.63.0.dev1410.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
|
|
68
|
+
opentf_toolkit_nightly-0.63.0.dev1410.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|