zrb 0.26.0__py3-none-any.whl → 0.27.1__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 +0 -3
- zrb/builtin/monorepo/_common.sh +15 -0
- zrb/builtin/monorepo/_config.py +2 -2
- zrb/builtin/monorepo/_helper.py +140 -0
- zrb/builtin/monorepo/_task.py +98 -71
- zrb/builtin/monorepo/add-subrepo.sh +22 -0
- zrb/builtin/monorepo/add.py +9 -1
- zrb/builtin/monorepo/pull-monorepo.sh +18 -0
- zrb/builtin/monorepo/pull-subrepo.sh +18 -0
- zrb/builtin/monorepo/pull.py +2 -1
- zrb/builtin/monorepo/push-monorepo.sh +18 -0
- zrb/builtin/monorepo/push-subrepo.sh +18 -0
- zrb/builtin/monorepo/push.py +3 -14
- zrb/helper/asyncio_task.py +8 -5
- zrb/helper/cli.py +0 -1
- zrb/task/base_task/base_task.py +1 -1
- zrb/task/docker_compose_task.py +26 -26
- zrb/task/flow_task.py +0 -1
- zrb/task/remote_cmd_task.py +55 -18
- zrb/task/rsync_task.py +57 -23
- {zrb-0.26.0.dist-info → zrb-0.27.1.dist-info}/METADATA +2 -2
- {zrb-0.26.0.dist-info → zrb-0.27.1.dist-info}/RECORD +25 -21
- zrb/shell-scripts/rsync-util.sh +0 -12
- zrb/shell-scripts/ssh-util.sh +0 -12
- zrb/task/base_remote_cmd_task.py +0 -354
- {zrb-0.26.0.dist-info → zrb-0.27.1.dist-info}/LICENSE +0 -0
- {zrb-0.26.0.dist-info → zrb-0.27.1.dist-info}/WHEEL +0 -0
- {zrb-0.26.0.dist-info → zrb-0.27.1.dist-info}/entry_points.txt +0 -0
zrb/task/base_remote_cmd_task.py
DELETED
@@ -1,354 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import pathlib
|
3
|
-
from collections.abc import Callable, Iterable, Mapping
|
4
|
-
from typing import Any, Optional, TypeVar, Union
|
5
|
-
|
6
|
-
from zrb.helper.accessories.color import colored
|
7
|
-
from zrb.helper.log import logger
|
8
|
-
from zrb.helper.typecheck import typechecked
|
9
|
-
from zrb.helper.typing import JinjaTemplate
|
10
|
-
from zrb.helper.util import to_snake_case
|
11
|
-
from zrb.task.any_task import AnyTask
|
12
|
-
from zrb.task.any_task_event_handler import (
|
13
|
-
OnFailed,
|
14
|
-
OnReady,
|
15
|
-
OnRetry,
|
16
|
-
OnSkipped,
|
17
|
-
OnStarted,
|
18
|
-
OnTriggered,
|
19
|
-
OnWaiting,
|
20
|
-
)
|
21
|
-
from zrb.task.base_task.base_task import BaseTask
|
22
|
-
from zrb.task.cmd_task import CmdTask, CmdVal
|
23
|
-
from zrb.task_env.env import Env
|
24
|
-
from zrb.task_env.env_file import EnvFile
|
25
|
-
from zrb.task_group.group import Group
|
26
|
-
from zrb.task_input.any_input import AnyInput
|
27
|
-
|
28
|
-
logger.debug(colored("Loading zrb.task.base_remote_cmd_task", attrs=["dark"]))
|
29
|
-
|
30
|
-
TSingleBaseRemoteCmdTask = TypeVar(
|
31
|
-
"TSingleBaseRemoteCmdTask", bound="SingleBaseRemoteCmdTask"
|
32
|
-
)
|
33
|
-
TBaseRemoteCmdTask = TypeVar("TBaseRemoteCmdTask", bound="BaseRemoteCmdTask")
|
34
|
-
|
35
|
-
|
36
|
-
@typechecked
|
37
|
-
class RemoteConfig:
|
38
|
-
def __init__(
|
39
|
-
self,
|
40
|
-
host: JinjaTemplate,
|
41
|
-
user: JinjaTemplate = "",
|
42
|
-
password: JinjaTemplate = "",
|
43
|
-
ssh_key: JinjaTemplate = "",
|
44
|
-
port: Union[int, JinjaTemplate] = 22,
|
45
|
-
name: Optional[str] = None,
|
46
|
-
config_map: Optional[Mapping[str, JinjaTemplate]] = None,
|
47
|
-
):
|
48
|
-
self.name = name if name is not None else host
|
49
|
-
self.host = host
|
50
|
-
self.user = user
|
51
|
-
self.password = password
|
52
|
-
self.ssh_key = ssh_key
|
53
|
-
self.port = port
|
54
|
-
self.config_map = {} if config_map is None else config_map
|
55
|
-
|
56
|
-
|
57
|
-
@typechecked
|
58
|
-
class SingleBaseRemoteCmdTask(CmdTask):
|
59
|
-
def __init__(
|
60
|
-
self,
|
61
|
-
name: str,
|
62
|
-
remote_config: RemoteConfig,
|
63
|
-
group: Optional[Group] = None,
|
64
|
-
inputs: Iterable[AnyInput] = [],
|
65
|
-
envs: Iterable[Env] = [],
|
66
|
-
env_files: Iterable[EnvFile] = [],
|
67
|
-
icon: Optional[str] = None,
|
68
|
-
color: Optional[str] = None,
|
69
|
-
description: str = "",
|
70
|
-
executable: Optional[str] = None,
|
71
|
-
pre_cmd: CmdVal = "",
|
72
|
-
pre_cmd_path: CmdVal = "",
|
73
|
-
cmd: CmdVal = "",
|
74
|
-
cmd_path: CmdVal = "",
|
75
|
-
post_cmd: CmdVal = "",
|
76
|
-
post_cmd_path: CmdVal = "",
|
77
|
-
cwd: Optional[Union[str, pathlib.Path]] = None,
|
78
|
-
should_render_cwd: bool = True,
|
79
|
-
upstreams: Iterable[AnyTask] = [],
|
80
|
-
fallbacks: Iterable[AnyTask] = [],
|
81
|
-
on_triggered: Optional[OnTriggered] = None,
|
82
|
-
on_waiting: Optional[OnWaiting] = None,
|
83
|
-
on_skipped: Optional[OnSkipped] = None,
|
84
|
-
on_started: Optional[OnStarted] = None,
|
85
|
-
on_ready: Optional[OnReady] = None,
|
86
|
-
on_retry: Optional[OnRetry] = None,
|
87
|
-
on_failed: Optional[OnFailed] = None,
|
88
|
-
checkers: Iterable[AnyTask] = [],
|
89
|
-
checking_interval: Union[float, int] = 0.05,
|
90
|
-
retry: int = 2,
|
91
|
-
retry_interval: Union[float, int] = 1,
|
92
|
-
max_output_line: int = 1000,
|
93
|
-
max_error_line: int = 1000,
|
94
|
-
preexec_fn: Optional[Callable[[], Any]] = os.setsid,
|
95
|
-
should_execute: Union[bool, str, Callable[..., bool]] = True,
|
96
|
-
return_upstream_result: bool = False,
|
97
|
-
should_print_cmd_result: bool = True,
|
98
|
-
should_show_cmd: bool = True,
|
99
|
-
should_show_working_directory: bool = True,
|
100
|
-
):
|
101
|
-
CmdTask.__init__(
|
102
|
-
self,
|
103
|
-
name=name,
|
104
|
-
group=group,
|
105
|
-
inputs=inputs,
|
106
|
-
envs=envs,
|
107
|
-
env_files=env_files,
|
108
|
-
icon=icon,
|
109
|
-
color=color,
|
110
|
-
description=description,
|
111
|
-
executable=executable,
|
112
|
-
cmd=cmd,
|
113
|
-
cmd_path=cmd_path,
|
114
|
-
cwd=cwd,
|
115
|
-
should_render_cwd=should_render_cwd,
|
116
|
-
upstreams=upstreams,
|
117
|
-
fallbacks=fallbacks,
|
118
|
-
on_triggered=on_triggered,
|
119
|
-
on_waiting=on_waiting,
|
120
|
-
on_skipped=on_skipped,
|
121
|
-
on_started=on_started,
|
122
|
-
on_ready=on_ready,
|
123
|
-
on_retry=on_retry,
|
124
|
-
on_failed=on_failed,
|
125
|
-
checkers=checkers,
|
126
|
-
checking_interval=checking_interval,
|
127
|
-
retry=retry,
|
128
|
-
retry_interval=retry_interval,
|
129
|
-
max_output_line=max_output_line,
|
130
|
-
max_error_line=max_error_line,
|
131
|
-
preexec_fn=preexec_fn,
|
132
|
-
should_execute=should_execute,
|
133
|
-
return_upstream_result=return_upstream_result,
|
134
|
-
should_print_cmd_result=should_print_cmd_result,
|
135
|
-
should_show_cmd=should_show_cmd,
|
136
|
-
should_show_working_directory=should_show_working_directory,
|
137
|
-
)
|
138
|
-
self._pre_cmd = pre_cmd
|
139
|
-
self._pre_cmd_path = pre_cmd_path
|
140
|
-
self._post_cmd = post_cmd
|
141
|
-
self._post_cmd_path = post_cmd_path
|
142
|
-
self._remote_config = remote_config
|
143
|
-
|
144
|
-
def copy(self) -> TSingleBaseRemoteCmdTask:
|
145
|
-
return super().copy()
|
146
|
-
|
147
|
-
def inject_envs(self):
|
148
|
-
super().inject_envs()
|
149
|
-
# add remote config properties as env
|
150
|
-
self.add_env(
|
151
|
-
Env(
|
152
|
-
name="_CONFIG_HOST",
|
153
|
-
os_name="",
|
154
|
-
default=self.render_str(self._remote_config.host),
|
155
|
-
),
|
156
|
-
Env(
|
157
|
-
name="_CONFIG_PORT",
|
158
|
-
os_name="",
|
159
|
-
default=str(self.render_int(self._remote_config.port)),
|
160
|
-
),
|
161
|
-
Env(
|
162
|
-
name="_CONFIG_SSH_KEY",
|
163
|
-
os_name="",
|
164
|
-
default=self.render_str(self._remote_config.ssh_key),
|
165
|
-
),
|
166
|
-
Env(
|
167
|
-
name="_CONFIG_USER",
|
168
|
-
os_name="",
|
169
|
-
default=self.render_str(self._remote_config.user),
|
170
|
-
),
|
171
|
-
Env(
|
172
|
-
name="_CONFIG_PASSWORD",
|
173
|
-
os_name="",
|
174
|
-
default=self.render_str(self._remote_config.password),
|
175
|
-
),
|
176
|
-
)
|
177
|
-
for key, val in self._remote_config.config_map.items():
|
178
|
-
upper_snake_key = to_snake_case(key).upper()
|
179
|
-
rendered_val = self.render_str(val)
|
180
|
-
# add remote config map as env
|
181
|
-
self.add_env(
|
182
|
-
Env(
|
183
|
-
name="_CONFIG_MAP_" + upper_snake_key,
|
184
|
-
os_name="",
|
185
|
-
default=rendered_val,
|
186
|
-
)
|
187
|
-
)
|
188
|
-
|
189
|
-
def get_cmd_script(self, *args: Any, **kwargs: Any) -> str:
|
190
|
-
cmd_str = "\n".join(
|
191
|
-
[
|
192
|
-
self._create_cmd_script(
|
193
|
-
self._pre_cmd_path, self._pre_cmd, *args, **kwargs
|
194
|
-
),
|
195
|
-
super().get_cmd_script(*args, **kwargs),
|
196
|
-
self._create_cmd_script(
|
197
|
-
self._post_cmd_path, self._post_cmd, *args, **kwargs
|
198
|
-
),
|
199
|
-
]
|
200
|
-
)
|
201
|
-
return cmd_str
|
202
|
-
|
203
|
-
|
204
|
-
@typechecked
|
205
|
-
class BaseRemoteCmdTask(BaseTask):
|
206
|
-
def __init__(
|
207
|
-
self,
|
208
|
-
name: str,
|
209
|
-
remote_configs: Iterable[RemoteConfig],
|
210
|
-
group: Optional[Group] = None,
|
211
|
-
inputs: Iterable[AnyInput] = [],
|
212
|
-
envs: Iterable[Env] = [],
|
213
|
-
env_files: Iterable[EnvFile] = [],
|
214
|
-
icon: Optional[str] = None,
|
215
|
-
color: Optional[str] = None,
|
216
|
-
description: str = "",
|
217
|
-
executable: Optional[str] = None,
|
218
|
-
pre_cmd: CmdVal = "",
|
219
|
-
pre_cmd_path: CmdVal = "",
|
220
|
-
cmd: CmdVal = "",
|
221
|
-
cmd_path: CmdVal = "",
|
222
|
-
post_cmd: CmdVal = "",
|
223
|
-
post_cmd_path: CmdVal = "",
|
224
|
-
cwd: Optional[Union[JinjaTemplate, pathlib.Path]] = None,
|
225
|
-
should_render_cwd: bool = True,
|
226
|
-
upstreams: Iterable[AnyTask] = [],
|
227
|
-
fallbacks: Iterable[AnyTask] = [],
|
228
|
-
on_triggered: Optional[OnTriggered] = None,
|
229
|
-
on_waiting: Optional[OnWaiting] = None,
|
230
|
-
on_skipped: Optional[OnSkipped] = None,
|
231
|
-
on_started: Optional[OnStarted] = None,
|
232
|
-
on_ready: Optional[OnReady] = None,
|
233
|
-
on_retry: Optional[OnRetry] = None,
|
234
|
-
on_failed: Optional[OnFailed] = None,
|
235
|
-
checkers: Iterable[AnyTask] = [],
|
236
|
-
checking_interval: Union[float, int] = 0.05,
|
237
|
-
retry: int = 2,
|
238
|
-
retry_interval: Union[float, int] = 1,
|
239
|
-
max_output_line: int = 1000,
|
240
|
-
max_error_line: int = 1000,
|
241
|
-
preexec_fn: Optional[Callable[[], Any]] = os.setsid,
|
242
|
-
should_execute: Union[bool, str, Callable[..., bool]] = True,
|
243
|
-
return_upstream_result: bool = False,
|
244
|
-
should_print_cmd_result: bool = True,
|
245
|
-
should_show_cmd: bool = True,
|
246
|
-
should_show_working_directory: bool = True,
|
247
|
-
):
|
248
|
-
self._remote_configs = list(remote_configs)
|
249
|
-
self._sub_tasks = [
|
250
|
-
SingleBaseRemoteCmdTask(
|
251
|
-
name=f"{name}-{remote_config.name}",
|
252
|
-
remote_config=remote_config,
|
253
|
-
inputs=inputs,
|
254
|
-
envs=envs,
|
255
|
-
env_files=env_files,
|
256
|
-
description=description,
|
257
|
-
executable=executable,
|
258
|
-
pre_cmd=pre_cmd,
|
259
|
-
pre_cmd_path=pre_cmd_path,
|
260
|
-
cmd=cmd,
|
261
|
-
cmd_path=cmd_path,
|
262
|
-
post_cmd=post_cmd,
|
263
|
-
post_cmd_path=post_cmd_path,
|
264
|
-
cwd=cwd,
|
265
|
-
should_render_cwd=should_render_cwd,
|
266
|
-
upstreams=upstreams,
|
267
|
-
fallbacks=fallbacks,
|
268
|
-
on_triggered=on_triggered,
|
269
|
-
on_waiting=on_waiting,
|
270
|
-
on_skipped=on_skipped,
|
271
|
-
on_started=on_started,
|
272
|
-
on_ready=on_ready,
|
273
|
-
on_retry=on_retry,
|
274
|
-
on_failed=on_failed,
|
275
|
-
checkers=checkers,
|
276
|
-
checking_interval=checking_interval,
|
277
|
-
retry=retry,
|
278
|
-
retry_interval=retry_interval,
|
279
|
-
max_output_line=max_output_line,
|
280
|
-
max_error_line=max_error_line,
|
281
|
-
preexec_fn=preexec_fn,
|
282
|
-
should_execute=should_execute,
|
283
|
-
return_upstream_result=return_upstream_result,
|
284
|
-
should_print_cmd_result=should_print_cmd_result,
|
285
|
-
should_show_cmd=should_show_cmd,
|
286
|
-
should_show_working_directory=should_show_working_directory,
|
287
|
-
)
|
288
|
-
for remote_config in self._remote_configs
|
289
|
-
]
|
290
|
-
BaseTask.__init__(
|
291
|
-
self,
|
292
|
-
name=name,
|
293
|
-
icon=icon,
|
294
|
-
color=color,
|
295
|
-
group=group,
|
296
|
-
description=description,
|
297
|
-
upstreams=self._sub_tasks,
|
298
|
-
retry=0,
|
299
|
-
return_upstream_result=True,
|
300
|
-
)
|
301
|
-
|
302
|
-
def insert_input(self, *inputs: AnyInput):
|
303
|
-
super().insert_input(*inputs)
|
304
|
-
for subtask in self._sub_tasks:
|
305
|
-
subtask.insert_input(*inputs)
|
306
|
-
|
307
|
-
def add_input(self, *inputs: AnyInput):
|
308
|
-
super().add_input(*inputs)
|
309
|
-
for subtask in self._sub_tasks:
|
310
|
-
subtask.add_input(*inputs)
|
311
|
-
|
312
|
-
def insert_env(self, *envs: Env):
|
313
|
-
super().insert_env(*envs)
|
314
|
-
for subtask in self._sub_tasks:
|
315
|
-
subtask.insert_env(*envs)
|
316
|
-
|
317
|
-
def add_env(self, *envs: Env):
|
318
|
-
super().add_env(*envs)
|
319
|
-
for subtask in self._sub_tasks:
|
320
|
-
subtask.add_env(*envs)
|
321
|
-
|
322
|
-
def insert_env_file(self, *env_files: EnvFile):
|
323
|
-
super().insert_env_file(*env_files)
|
324
|
-
for subtask in self._sub_tasks:
|
325
|
-
subtask.insert_env_file(*env_files)
|
326
|
-
|
327
|
-
def add_env_file(self, *env_files: Env):
|
328
|
-
super().add_env_file(*env_files)
|
329
|
-
for subtask in self._sub_tasks:
|
330
|
-
subtask.add_env_file(*env_files)
|
331
|
-
|
332
|
-
def insert_upstream(self, *upstreams: AnyTask):
|
333
|
-
for subtask in self._sub_tasks:
|
334
|
-
subtask.insert_upstream(*upstreams)
|
335
|
-
|
336
|
-
def add_upstream(self, *upstreams: AnyTask):
|
337
|
-
for subtask in self._sub_tasks:
|
338
|
-
subtask.add_upstream(*upstreams)
|
339
|
-
|
340
|
-
def insert_fallback(self, *fallbacks: AnyTask):
|
341
|
-
for subtask in self._sub_tasks:
|
342
|
-
subtask.insert_fallbacks(*fallbacks)
|
343
|
-
|
344
|
-
def add_fallback(self, *fallbacks: AnyTask):
|
345
|
-
for subtask in self._sub_tasks:
|
346
|
-
subtask.add_fallback(*fallbacks)
|
347
|
-
|
348
|
-
def insert_checker(self, *checkers: AnyTask):
|
349
|
-
for subtask in self._sub_tasks:
|
350
|
-
subtask.insert_checkers(*checkers)
|
351
|
-
|
352
|
-
def add_checker(self, *checkers: AnyTask):
|
353
|
-
for subtask in self._sub_tasks:
|
354
|
-
subtask.add_checker(*checkers)
|
File without changes
|
File without changes
|
File without changes
|