codecraftai-interop-ext-tasker 1.3.0__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.
- ccai/interop/protocols/tasker/__init__.py +12 -0
- ccai/interop/protocols/tasker/examples/helloworldtasking.py +97 -0
- ccai/interop/protocols/tasker/itaskingsequencer.py +78 -0
- ccai/interop/protocols/tasker/linux/tasker-service.template +16 -0
- ccai/interop/protocols/tasker/linux/taskerservice +30 -0
- ccai/interop/protocols/tasker/py.typed +0 -0
- ccai/interop/protocols/tasker/taskeraspects.py +100 -0
- ccai/interop/protocols/tasker/taskercontroller.py +670 -0
- ccai/interop/protocols/tasker/taskerdaemon.py +509 -0
- ccai/interop/protocols/tasker/taskerexceptions.py +18 -0
- ccai/interop/protocols/tasker/taskernode.py +541 -0
- ccai/interop/protocols/tasker/taskerserver.py +159 -0
- ccai/interop/protocols/tasker/taskerservermanager.py +53 -0
- ccai/interop/protocols/tasker/taskerservice.py +806 -0
- ccai/interop/protocols/tasker/taskersession.py +856 -0
- ccai/interop/protocols/tasker/tasking.py +860 -0
- ccai/interop/protocols/tasker/taskingadapter.py +146 -0
- ccai/interop/protocols/tasker/taskingevent.py +84 -0
- ccai/interop/protocols/tasker/taskinggroupscope.py +416 -0
- ccai/interop/protocols/tasker/taskingprogressmonitor.py +187 -0
- ccai/interop/protocols/tasker/taskingresultpromise.py +351 -0
- ccai/landscaping/clients/taskers/clientroles.py +20 -0
- ccai/landscaping/clients/taskers/constants.py +15 -0
- ccai/landscaping/clients/taskers/linux/__init__.py +11 -0
- ccai/landscaping/clients/taskers/linux/ext/commandsext.py +305 -0
- ccai/landscaping/clients/taskers/linux/ext/configureext.py +496 -0
- ccai/landscaping/clients/taskers/linux/linuxtaskerclient.py +82 -0
- ccai/landscaping/clients/taskers/linux/linuxtaskerclientcoordinator.py +78 -0
- ccai/landscaping/clients/taskers/linux/linuxtaskerclientcoordinatorcoupling.py +50 -0
- ccai/landscaping/clients/taskers/py.typed +0 -0
- codecraftai_interop_ext_tasker-1.3.0.dist-info/METADATA +92 -0
- codecraftai_interop_ext_tasker-1.3.0.dist-info/RECORD +34 -0
- codecraftai_interop_ext_tasker-1.3.0.dist-info/WHEEL +4 -0
- codecraftai_interop_ext_tasker-1.3.0.dist-info/licenses/LICENSE.md +204 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: __init__
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: __init__ module.
|
|
5
|
+
|
|
6
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__author__ = "Myron Walker"
|
|
10
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
11
|
+
__credits__ = []
|
|
12
|
+
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
.. module:: helloworldtasking
|
|
4
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
5
|
+
:synopsis: helloworldtasking module.
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__author__ = "Myron Walker"
|
|
11
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
12
|
+
__credits__ = []
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
import time
|
|
16
|
+
|
|
17
|
+
from datetime import datetime
|
|
18
|
+
|
|
19
|
+
from ccai.testbase.results.model.progressinfo import ProgressInfo, ProgressType, ProgressCode
|
|
20
|
+
|
|
21
|
+
from ccai.interop.protocols.tasker.tasking import Tasking
|
|
22
|
+
|
|
23
|
+
class HelloWorldTasking(Tasking):
|
|
24
|
+
"""
|
|
25
|
+
Simple example tasking that writes a message a number of times.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
PREFIX = "helloworld"
|
|
29
|
+
|
|
30
|
+
def begin(self, kwparams: dict):
|
|
31
|
+
"""
|
|
32
|
+
Called when the task is beginning execution.
|
|
33
|
+
|
|
34
|
+
:param kwparams: Parameters describing the task execution.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
self._message = kwparams["message"]
|
|
38
|
+
self._iterations = kwparams["iterations"]
|
|
39
|
+
|
|
40
|
+
self._data = {
|
|
41
|
+
"pid": os.getpid(),
|
|
42
|
+
"message": self._message,
|
|
43
|
+
"iterations": self._iterations
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
time.sleep(5)
|
|
47
|
+
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
def mark_progress_start(self):
|
|
51
|
+
"""
|
|
52
|
+
Marks the start of progress for the tasking.
|
|
53
|
+
|
|
54
|
+
:returns: ``None``
|
|
55
|
+
"""
|
|
56
|
+
now = datetime.now()
|
|
57
|
+
self._current_progress = ProgressInfo(
|
|
58
|
+
self._tasking_id,
|
|
59
|
+
"hello",
|
|
60
|
+
self.full_name,
|
|
61
|
+
ProgressType.NumericRange,
|
|
62
|
+
0,
|
|
63
|
+
self._iterations,
|
|
64
|
+
0,
|
|
65
|
+
ProgressCode.Running,
|
|
66
|
+
now,
|
|
67
|
+
self._data,
|
|
68
|
+
)
|
|
69
|
+
return
|
|
70
|
+
|
|
71
|
+
def log_message(self, message) -> bool:
|
|
72
|
+
"""
|
|
73
|
+
Logs a message to the tasking logger.
|
|
74
|
+
|
|
75
|
+
:param message: Text to log.
|
|
76
|
+
|
|
77
|
+
:returns: ``True`` if the message was logged.
|
|
78
|
+
"""
|
|
79
|
+
self._logger.info(message)
|
|
80
|
+
return True
|
|
81
|
+
|
|
82
|
+
def perform(self):
|
|
83
|
+
"""
|
|
84
|
+
Performs one iteration of work.
|
|
85
|
+
|
|
86
|
+
:returns: ``True`` if additional iterations remain.
|
|
87
|
+
"""
|
|
88
|
+
position = self._current_progress.position
|
|
89
|
+
|
|
90
|
+
time.sleep(1)
|
|
91
|
+
|
|
92
|
+
morework = False
|
|
93
|
+
if position < self._current_progress.range_max:
|
|
94
|
+
morework = True
|
|
95
|
+
self._current_progress.position = position + 1
|
|
96
|
+
|
|
97
|
+
return morework
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: itaskingsequencer
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: itaskingsequencer module.
|
|
5
|
+
|
|
6
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__author__ = "Myron Walker"
|
|
10
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
11
|
+
__credits__ = []
|
|
12
|
+
|
|
13
|
+
from typing import Protocol
|
|
14
|
+
|
|
15
|
+
from ccai.errors.exceptions import AbstractMethodError
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
from ccai.testbase.results.recorders.resultrecorder import ResultRecorder
|
|
19
|
+
from ccai.testbase.results.model.taskinggroup import TaskingGroup
|
|
20
|
+
from ccai.testbase.results.model.taskingresult import TaskingResult
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ITaskingSequencer(Protocol):
|
|
24
|
+
"""
|
|
25
|
+
Protocol defining the interface for task sequencing helpers.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def create_tasking_result(
|
|
29
|
+
self, scope_id: str, name: str, parent_inst: str
|
|
30
|
+
) -> TaskingResult:
|
|
31
|
+
"""
|
|
32
|
+
Creates a :class:`TaskingResult` object used to capture the outcome of a task.
|
|
33
|
+
|
|
34
|
+
:param scope_id: The scope identifier for the result.
|
|
35
|
+
:param name: The name of the tasking instance.
|
|
36
|
+
:param parent_inst: The parent instance identifier.
|
|
37
|
+
|
|
38
|
+
:returns: A :class:`TaskingResult` instance.
|
|
39
|
+
"""
|
|
40
|
+
raise AbstractMethodError(
|
|
41
|
+
"ITaskingSequencer.create_tasking_result must be overloaded by derived types"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def create_tasking_group(
|
|
45
|
+
self, scope_id: str, name: str, parent_inst: str
|
|
46
|
+
) -> TaskingGroup:
|
|
47
|
+
"""
|
|
48
|
+
Creates a :class:`TaskingGroup` for grouping related tasking results.
|
|
49
|
+
|
|
50
|
+
:param scope_id: The scope identifier for the group.
|
|
51
|
+
:param name: The name of the tasking group.
|
|
52
|
+
:param parent_inst: The parent instance identifier.
|
|
53
|
+
|
|
54
|
+
:returns: A :class:`TaskingGroup` instance.
|
|
55
|
+
"""
|
|
56
|
+
raise AbstractMethodError(
|
|
57
|
+
"ITaskingSequencer.create_tasking_group must be overloaded by derived types"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
def get_recorder(self) -> ResultRecorder:
|
|
61
|
+
"""
|
|
62
|
+
Retrieves the :class:`ResultRecorder` used for recording results.
|
|
63
|
+
|
|
64
|
+
:returns: The active :class:`ResultRecorder` instance.
|
|
65
|
+
"""
|
|
66
|
+
raise AbstractMethodError(
|
|
67
|
+
"ITaskingSequencer.get_recorder must be overloaded by derived types"
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
def get_top_scope_id(self) -> str:
|
|
71
|
+
"""
|
|
72
|
+
Gets the identifier of the current top-level scope.
|
|
73
|
+
|
|
74
|
+
:returns: The active scope identifier.
|
|
75
|
+
"""
|
|
76
|
+
raise AbstractMethodError(
|
|
77
|
+
"ITaskingSequencer.get_top_scope_id must be overloaded by derived types"
|
|
78
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=The Tasker RPyC base tasking service
|
|
3
|
+
After=syslog.target network-online.target remote-fs.target nss-lookup.target
|
|
4
|
+
Wants=network-online.target
|
|
5
|
+
|
|
6
|
+
[Service]
|
|
7
|
+
User={username}
|
|
8
|
+
Group={group}
|
|
9
|
+
Type=forking
|
|
10
|
+
PIDFile=/var/run/tasker/tasker.pid
|
|
11
|
+
ExecStart={tasker-binary} start
|
|
12
|
+
ExecStop={tasker-binary} stop
|
|
13
|
+
PrivateTmp=true
|
|
14
|
+
|
|
15
|
+
[Install]
|
|
16
|
+
WantedBy=multi-user.target
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
4
|
+
|
|
5
|
+
VENV_DIR="$( dirname $THIS_DIR )"
|
|
6
|
+
REPOSITORY_DIR="$( dirname $VENV_DIR )"
|
|
7
|
+
|
|
8
|
+
REPOSITORY_ENV_FILE="$REPOSITORY_DIR/.env"
|
|
9
|
+
REPOSITORY_CONFIG_FILE="$REPOSITORY_DIR/repository-setup/repository-config.ini"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
set -a
|
|
13
|
+
|
|
14
|
+
source "$REPOSITORY_ENV_FILE"
|
|
15
|
+
source <( grep --color=never -E '^[\s]*[A-Za-z_]+[A-Za-z_0-9]*=' "$REPOSITORY_CONFIG_FILE" )
|
|
16
|
+
|
|
17
|
+
set +a
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
TASKER_DIR="$( $THIS_DIR/python3 -c 'import ccai.interop.protocols.tasker as tasker; print(tasker.__file__[:-12])' )"
|
|
21
|
+
|
|
22
|
+
echo "THIS_DIR=$THIS_DIR"
|
|
23
|
+
echo "VENV_DIR=$VENV_DIR"
|
|
24
|
+
echo "REPOSITORY_DIR=$REPOSITORY_DIR"
|
|
25
|
+
echo "REPOSITORY_ENV_FILE=$REPOSITORY_ENV_FILE"
|
|
26
|
+
echo "REPOSITORY_CONFIG_FILE=$REPOSITORY_CONFIG_FILE"
|
|
27
|
+
echo "TASKER_DIR=$TASKER_DIR"
|
|
28
|
+
|
|
29
|
+
$THIS_DIR/python3 $TASKER_DIR/taskerdaemon.py "$@"
|
|
30
|
+
|
|
File without changes
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: taskeraspects
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module containing the :class:`TaskerAspects` class which is used to instruct behavior
|
|
5
|
+
around tasking.
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__author__ = "Myron Walker"
|
|
12
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
13
|
+
__credits__ = []
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from typing import Dict, Optional
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
DEFAULT_COMPLETION_TIMEOUT = 7 * 24 * 60 * 60 # The Default Timeout is 1 Week
|
|
20
|
+
DEFAULT_COMPLETION_INTERVAL = 10
|
|
21
|
+
|
|
22
|
+
DEFAULT_INACTIVITY_TIMEOUT = 1200 # 20 Minutes
|
|
23
|
+
DEFAULT_INACTIVITY_INTERVAL = 0.5
|
|
24
|
+
|
|
25
|
+
DEFAULT_PROGRESS_INTERVAL = 30
|
|
26
|
+
|
|
27
|
+
from ccai.aspects.aspects import Aspects as AspectsBase
|
|
28
|
+
from ccai.testbase.results.model.progressdelivery import ProgressDeliveryMethod
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class TaskerAspects(AspectsBase):
|
|
32
|
+
"""
|
|
33
|
+
Parameterization object describing task execution behavior.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(
|
|
37
|
+
self,
|
|
38
|
+
completion_timeout: Optional[float] = DEFAULT_COMPLETION_TIMEOUT,
|
|
39
|
+
completion_interval: Optional[float] = DEFAULT_COMPLETION_INTERVAL,
|
|
40
|
+
inactivity_timeout: Optional[float] = DEFAULT_INACTIVITY_TIMEOUT,
|
|
41
|
+
inactivity_interval: Optional[float] = DEFAULT_INACTIVITY_INTERVAL,
|
|
42
|
+
progress_delivery: Optional[Dict[str, float]] = None,
|
|
43
|
+
sync_request_timeout: Optional[float] = None,
|
|
44
|
+
):
|
|
45
|
+
"""
|
|
46
|
+
Constructs a :class:`TaskerAspects` object describing task execution parameters.
|
|
47
|
+
|
|
48
|
+
:param completion_timeout: Maximum wait time for a task to complete.
|
|
49
|
+
:param completion_interval: Polling interval while waiting for completion.
|
|
50
|
+
:param inactivity_timeout: Timeout for detecting inactivity.
|
|
51
|
+
:param inactivity_interval: Polling interval for inactivity checks.
|
|
52
|
+
:param progress_delivery: Progress delivery settings.
|
|
53
|
+
:param sync_request_timeout: Timeout for synchronous requests.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
super().__init__(completion_interval=completion_interval, completion_timeout=completion_timeout)
|
|
57
|
+
|
|
58
|
+
self.inactivity_timeout = inactivity_timeout
|
|
59
|
+
self.inactivity_interval = inactivity_interval
|
|
60
|
+
self.progress_delivery = progress_delivery
|
|
61
|
+
self.sync_request_timeout = sync_request_timeout
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
def as_dict(self) -> dict:
|
|
65
|
+
"""
|
|
66
|
+
Returns this instance as a dictionary.
|
|
67
|
+
|
|
68
|
+
:returns: Dictionary representation of the aspects.
|
|
69
|
+
"""
|
|
70
|
+
data = {
|
|
71
|
+
"completion_timeout": self.completion_timeout,
|
|
72
|
+
"completion_interval": self.completion_interval,
|
|
73
|
+
"inactivity_timeout": self.inactivity_timeout,
|
|
74
|
+
"inactivity_interval": self.inactivity_interval,
|
|
75
|
+
"progress_delivery": self.progress_delivery,
|
|
76
|
+
"sync_request_timeout": self.sync_request_timeout,
|
|
77
|
+
}
|
|
78
|
+
return data
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def from_dict(cls, data: dict) -> "TaskerAspects":
|
|
82
|
+
"""
|
|
83
|
+
Creates a :class:`TaskerAspects` from a dictionary.
|
|
84
|
+
|
|
85
|
+
:param data: Dictionary of aspect values.
|
|
86
|
+
|
|
87
|
+
:returns: A new :class:`TaskerAspects` instance.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
obj = TaskerAspects(**data)
|
|
91
|
+
return obj
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
DEFAULT_TASKER_ASPECTS = TaskerAspects()
|
|
95
|
+
|
|
96
|
+
DEFAULT_SUMMARY_PROGRESS_TASKER_ASPECTS = TaskerAspects(
|
|
97
|
+
progress_delivery={
|
|
98
|
+
ProgressDeliveryMethod.SUMMARY_PULL_PROGRESS: DEFAULT_PROGRESS_INTERVAL
|
|
99
|
+
}
|
|
100
|
+
)
|