zrb 0.0.120__py3-none-any.whl → 0.0.121__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.
zrb/__init__.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from zrb.runner import runner
2
2
  from zrb.task.decorator import python_task
3
3
  from zrb.task.any_task import AnyTask
4
+ from zrb.task.parallel import AnyParallel, Parallel
4
5
  from zrb.task.task import Task
5
6
  from zrb.task.cmd_task import CmdTask
6
7
  from zrb.task.docker_compose_task import DockerComposeTask, ServiceConfig
@@ -33,6 +34,8 @@ from zrb.helper.default_env import inject_default_env
33
34
 
34
35
  assert runner
35
36
  assert AnyTask
37
+ assert AnyParallel
38
+ assert Parallel
36
39
  assert python_task
37
40
  assert Task
38
41
  assert CmdTask
@@ -12,6 +12,7 @@ from zrb.task.base_task.component.trackers import (
12
12
  )
13
13
  from zrb.task.base_task.component.renderer import Renderer
14
14
  from zrb.task.base_task.component.base_task_model import BaseTaskModel
15
+ from zrb.task.parallel import AnyParallel
15
16
  from zrb.advertisement import advertisements
16
17
  from zrb.task_group.group import Group
17
18
  from zrb.task_env.env import Env
@@ -102,9 +103,15 @@ class BaseTask(
102
103
  self.__is_execution_triggered: bool = False
103
104
  self.__is_execution_started: bool = False
104
105
 
105
- def __rshift__(self, other_task: AnyTask):
106
- other_task.add_upstream(self)
107
- return other_task
106
+ def __rshift__(self, operand: Union[AnyParallel, AnyTask]):
107
+ if isinstance(operand, AnyTask):
108
+ operand.add_upstream(self)
109
+ return operand
110
+ if isinstance(operand, AnyParallel):
111
+ other_tasks: List[AnyTask] = operand.get_tasks()
112
+ for other_task in other_tasks:
113
+ other_task.add_upstream(self)
114
+ return operand
108
115
 
109
116
  def copy(self) -> AnyTask:
110
117
  return copy.deepcopy(self)
zrb/task/parallel.py ADDED
@@ -0,0 +1,36 @@
1
+ from zrb.helper.typing import TypeVar, List, Union
2
+ from abc import ABC, abstractmethod
3
+ from zrb.helper.typecheck import typechecked
4
+ from zrb.task.any_task import AnyTask
5
+
6
+
7
+ TParallel = TypeVar('TParallel', bound='Parallel')
8
+
9
+
10
+ class AnyParallel(ABC):
11
+ @abstractmethod
12
+ def get_tasks(self) -> List[AnyTask]:
13
+ pass
14
+
15
+
16
+ @typechecked
17
+ class Parallel(AnyParallel):
18
+ def __init__(self, *tasks: AnyTask):
19
+ self.__tasks = list(tasks)
20
+
21
+ def get_tasks(self) -> List[AnyTask]:
22
+ return self.__tasks
23
+
24
+ def __rshift__(
25
+ self, operand: Union[AnyTask, AnyParallel]
26
+ ) -> Union[AnyTask, AnyParallel]:
27
+ if isinstance(operand, AnyTask):
28
+ for task in self.__tasks:
29
+ operand.add_upstream(task)
30
+ return operand
31
+ if isinstance(operand, AnyParallel):
32
+ other_tasks: List[AnyTask] = operand.get_tasks()
33
+ for task in self.__tasks:
34
+ for other_task in other_tasks:
35
+ other_task.add_upstream(task)
36
+ return operand
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zrb
3
- Version: 0.0.120
3
+ Version: 0.0.121
4
4
  Summary: A Framework to Enhance Your Workflow
5
5
  Author-email: Go Frendi Gunawan <gofrendiasgard@gmail.com>
6
6
  Requires-Python: >=3.10.0
@@ -1,4 +1,4 @@
1
- zrb/__init__.py,sha256=uX1pE1kUwxy-RobzktNyzjP69cnZcM206JiSk7fJnKM,2040
1
+ zrb/__init__.py,sha256=1SSyh2yX2Zk3BnraVUTNiXDVsQOstiSC8cPR2ZukEtQ,2127
2
2
  zrb/__main__.py,sha256=CdfuYSxqlJhnsJPOBOL2_uzEaTZHC3MtpyTuz8QUfUI,314
3
3
  zrb/advertisement.py,sha256=e-1tFPlmEuz8IqaIJ_9-2p9x5cuGsxssJGu5F0wHthI,505
4
4
  zrb/runner.py,sha256=MPCNPMCyiYNZeubSxd1eM2Zr6PCIKF-9pkG385AXElw,118
@@ -1156,6 +1156,7 @@ zrb/task/docker_compose_task.py,sha256=clbq1OOKC_zAz7IL3iBpNnCGR96JCF056r4o0v0E7
1156
1156
  zrb/task/flow_task.py,sha256=l0xCb6mlaaNK5NVZxhKWE1qKXUI2akzC6CZfciGh7P8,3939
1157
1157
  zrb/task/http_checker.py,sha256=PoneoC9S7bTw41IP7hB9ewaWO-lF3ZWT75MXEPyThYA,5244
1158
1158
  zrb/task/notifier.py,sha256=UVhx1fLORhqyXprzqQqdoVYIFGrirwnTk-Ak18ZyucQ,5332
1159
+ zrb/task/parallel.py,sha256=OnCdh4aQwL-N2ICNf3gshhqx5-Hq_QPZD3ycMHqrFRg,1042
1159
1160
  zrb/task/path_checker.py,sha256=BSBf8ZXEcTwVI3UskSgdXXWrCLWggnwk6sHHbEI0z5g,3382
1160
1161
  zrb/task/path_watcher.py,sha256=9r36cMc7EaLehQVw0149TN-qOZitucR9mRW3S-w7SQw,4695
1161
1162
  zrb/task/port_checker.py,sha256=IvOUhefkpYcKZJ9zGr0RNUZju5yLvXoNJlLlODpLZZ8,4111
@@ -1166,7 +1167,7 @@ zrb/task/rsync_task.py,sha256=3vxENH-unD1VLgZI09Ts_lAQRMi2i1UiJpsaI1dltzI,3966
1166
1167
  zrb/task/task.py,sha256=l1jzJil7AqnsFn9e8WyO-rgCIG1JSvB6DaRBQZQo00I,246
1167
1168
  zrb/task/time_watcher.py,sha256=cbmmKtbeMrkRwpRZi_-jyJ_hC4KnsOPHUIpzvns2hPQ,3728
1168
1169
  zrb/task/base_task/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1169
- zrb/task/base_task/base_task.py,sha256=PBToO1WgljuxyQYAsoIvHOIb1Kffh5Ta1yG_FupufQ0,16216
1170
+ zrb/task/base_task/base_task.py,sha256=w593NE0-sfuV7WKjw4QxcdtT1lngnCIeXPg60ueJJcs,16540
1170
1171
  zrb/task/base_task/component/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1171
1172
  zrb/task/base_task/component/base_task_model.py,sha256=mi7v0ScvVlqkXSM6N0GUEWomVd3wwzL492LU60u2jZQ,9845
1172
1173
  zrb/task/base_task/component/common_task_model.py,sha256=9qwrnVARWafGm8PNpZtPmxlgVSD_3ZNt3hZxiOJO2m4,10478
@@ -1189,8 +1190,8 @@ zrb/task_input/int_input.py,sha256=VYduGcAE0m7eDItRQboTFDCW5whMur_uH1Y9qtBIwV4,1
1189
1190
  zrb/task_input/password_input.py,sha256=i6U-smP6zFo8Ts9x14YXVgx7PKkRWr4U_EzPFp9nucw,1687
1190
1191
  zrb/task_input/str_input.py,sha256=w9TTUMlMQtlOXh2ahHPbRnFyTiV94lXizucCc8SuWoo,1668
1191
1192
  zrb/task_input/task_input.py,sha256=HotqM1iYSzwE4PIj8grnEUsvJqjx1dS6Ek7i6ZJLq2Y,83
1192
- zrb-0.0.120.dist-info/entry_points.txt,sha256=xTgXc1kBKYhJHEujdaSPHUcJT3-hbyP1mLgwkv-5sSk,40
1193
- zrb-0.0.120.dist-info/LICENSE,sha256=WfnGCl8G60EYOPAEkuc8C9m9pdXWDe08NsKj3TBbxsM,728
1194
- zrb-0.0.120.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
1195
- zrb-0.0.120.dist-info/METADATA,sha256=kZ2WFfdx-ZLc-oZ4wZrZIMUzzkPHqbnOsG_KuqPQKWU,15079
1196
- zrb-0.0.120.dist-info/RECORD,,
1193
+ zrb-0.0.121.dist-info/entry_points.txt,sha256=xTgXc1kBKYhJHEujdaSPHUcJT3-hbyP1mLgwkv-5sSk,40
1194
+ zrb-0.0.121.dist-info/LICENSE,sha256=WfnGCl8G60EYOPAEkuc8C9m9pdXWDe08NsKj3TBbxsM,728
1195
+ zrb-0.0.121.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
1196
+ zrb-0.0.121.dist-info/METADATA,sha256=A07FBVLViYyRae2p0Efcs_hmBmnFojeeZeFk4hv-_8M,15079
1197
+ zrb-0.0.121.dist-info/RECORD,,
File without changes
File without changes