zrb 0.15.0__py3-none-any.whl → 0.17.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.
Files changed (97) hide show
  1. zrb/__init__.py +5 -0
  2. zrb/__main__.py +0 -3
  3. zrb/action/runner.py +12 -3
  4. zrb/advertisement.py +4 -0
  5. zrb/builtin/_helper/reccuring_action.py +0 -23
  6. zrb/builtin/devtool/install/_input.py +2 -4
  7. zrb/builtin/devtool/install/helix/resource/config.toml +2 -1
  8. zrb/builtin/process/pid/get_by_name.py +1 -1
  9. zrb/builtin/project/create/template/project.sh +1 -0
  10. zrb/builtin/schedule.py +14 -10
  11. zrb/builtin/watch_changes.py +15 -14
  12. zrb/config/config.py +21 -14
  13. zrb/helper/accessories/color.py +5 -2
  14. zrb/helper/accessories/icon.py +4 -0
  15. zrb/helper/accessories/name.py +4 -0
  16. zrb/helper/accessories/untyped_color.py +10 -0
  17. zrb/helper/advertisement.py +3 -0
  18. zrb/helper/callable.py +9 -1
  19. zrb/helper/cli.py +2 -0
  20. zrb/helper/codemod/add_argument_to_function.py +6 -0
  21. zrb/helper/codemod/add_argument_to_function_call.py +6 -0
  22. zrb/helper/codemod/add_assert_resource.py +4 -0
  23. zrb/helper/codemod/add_function_call.py +4 -0
  24. zrb/helper/codemod/add_import_module.py +4 -0
  25. zrb/helper/codemod/add_key_value_to_dict.py +6 -0
  26. zrb/helper/codemod/add_property_to_class.py +6 -0
  27. zrb/helper/codemod/add_upstream_to_task.py +4 -0
  28. zrb/helper/codemod/append_code_to_function.py +6 -0
  29. zrb/helper/codemod/format_code.py +4 -0
  30. zrb/helper/default_env.py +2 -0
  31. zrb/helper/docker_compose/fetch_external_env.py +6 -0
  32. zrb/helper/docker_compose/file.py +4 -0
  33. zrb/helper/docstring.py +5 -0
  34. zrb/helper/env_map/fetch.py +4 -0
  35. zrb/helper/file/copy_tree.py +3 -0
  36. zrb/helper/file/match.py +4 -0
  37. zrb/helper/file/text.py +4 -0
  38. zrb/helper/git/detect_changes.py +4 -0
  39. zrb/helper/loader/load_module.py +2 -0
  40. zrb/helper/log.py +1 -1
  41. zrb/helper/map/conversion.py +4 -0
  42. zrb/helper/python_task.py +3 -0
  43. zrb/helper/render_data.py +4 -0
  44. zrb/helper/string/conversion.py +13 -36
  45. zrb/helper/string/jinja.py +4 -0
  46. zrb/helper/string/modification.py +4 -0
  47. zrb/helper/string/parse_replacement.py +4 -0
  48. zrb/helper/string/untyped_conversion.py +49 -0
  49. zrb/helper/task.py +4 -0
  50. zrb/helper/typecheck.py +6 -7
  51. zrb/helper/typing.py +32 -12
  52. zrb/helper/util.py +4 -0
  53. zrb/runner.py +3 -0
  54. zrb/task/any_task.py +5 -0
  55. zrb/task/any_task_event_handler.py +4 -0
  56. zrb/task/base_remote_cmd_task.py +4 -0
  57. zrb/task/base_task/base_task.py +5 -1
  58. zrb/task/checker.py +7 -3
  59. zrb/task/cmd_task.py +14 -2
  60. zrb/task/decorator.py +4 -0
  61. zrb/task/docker_compose_task.py +4 -0
  62. zrb/task/flow_task.py +4 -0
  63. zrb/task/http_checker.py +14 -1
  64. zrb/task/looper.py +40 -0
  65. zrb/task/notifier.py +4 -0
  66. zrb/task/parallel.py +4 -0
  67. zrb/task/path_checker.py +14 -1
  68. zrb/task/path_watcher.py +65 -41
  69. zrb/task/port_checker.py +14 -1
  70. zrb/task/recurring_task.py +5 -0
  71. zrb/task/remote_cmd_task.py +4 -0
  72. zrb/task/resource_maker.py +14 -1
  73. zrb/task/rsync_task.py +4 -0
  74. zrb/task/server.py +190 -0
  75. zrb/task/task.py +4 -0
  76. zrb/task/time_watcher.py +50 -18
  77. zrb/task/watcher.py +100 -0
  78. zrb/task/wiki_task.py +4 -0
  79. zrb/task_env/constant.py +5 -0
  80. zrb/task_env/env.py +4 -0
  81. zrb/task_env/env_file.py +4 -0
  82. zrb/task_group/group.py +4 -0
  83. zrb/task_input/any_input.py +4 -0
  84. zrb/task_input/base_input.py +4 -0
  85. zrb/task_input/bool_input.py +4 -0
  86. zrb/task_input/choice_input.py +4 -0
  87. zrb/task_input/constant.py +5 -0
  88. zrb/task_input/float_input.py +4 -0
  89. zrb/task_input/int_input.py +4 -0
  90. zrb/task_input/password_input.py +4 -0
  91. zrb/task_input/str_input.py +4 -0
  92. zrb/task_input/task_input.py +4 -0
  93. {zrb-0.15.0.dist-info → zrb-0.17.0.dist-info}/METADATA +1 -1
  94. {zrb-0.15.0.dist-info → zrb-0.17.0.dist-info}/RECORD +97 -92
  95. {zrb-0.15.0.dist-info → zrb-0.17.0.dist-info}/LICENSE +0 -0
  96. {zrb-0.15.0.dist-info → zrb-0.17.0.dist-info}/WHEEL +0 -0
  97. {zrb-0.15.0.dist-info → zrb-0.17.0.dist-info}/entry_points.txt +0 -0
zrb/helper/file/match.py CHANGED
@@ -1,9 +1,13 @@
1
1
  import fnmatch
2
2
  import glob
3
3
 
4
+ from zrb.helper.accessories.color import colored
5
+ from zrb.helper.log import logger
4
6
  from zrb.helper.typecheck import typechecked
5
7
  from zrb.helper.typing import Iterable, List
6
8
 
9
+ logger.debug(colored("Loading zrb.helper.file.match", attrs=["dark"]))
10
+
7
11
 
8
12
  @typechecked
9
13
  def get_file_names(glob_path: str, glob_ignored_paths: Iterable[str]) -> List[str]:
zrb/helper/file/text.py CHANGED
@@ -2,8 +2,12 @@ import os
2
2
 
3
3
  import aiofiles
4
4
 
5
+ from zrb.helper.accessories.color import colored
6
+ from zrb.helper.log import logger
5
7
  from zrb.helper.typecheck import typechecked
6
8
 
9
+ logger.debug(colored("Loading zrb.helper.file.text", attrs=["dark"]))
10
+
7
11
 
8
12
  @typechecked
9
13
  async def read_text_file_async(file_name: str) -> str:
@@ -1,8 +1,12 @@
1
1
  import subprocess
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
  from zrb.helper.typing import Mapping
5
7
 
8
+ logger.debug(colored("Loading zrb.helper.git.detect_changes", attrs=["dark"]))
9
+
6
10
 
7
11
  @typechecked
8
12
  class ModificationState:
@@ -8,6 +8,8 @@ from zrb.helper.accessories.color import colored
8
8
  from zrb.helper.log import logger
9
9
  from zrb.helper.typecheck import typechecked
10
10
 
11
+ logger.debug(colored("Loading zrb.helper.loader.load_module", attrs=["dark"]))
12
+
11
13
  pattern = re.compile("[^a-zA-Z0-9]")
12
14
 
13
15
 
zrb/helper/log.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
 
3
3
  from zrb.config.config import logging_level
4
- from zrb.helper.accessories.color import colored
4
+ from zrb.helper.accessories.untyped_color import untyped_colored as colored
5
5
 
6
6
  # create logger
7
7
  logger = logging.getLogger("zrb")
@@ -1,6 +1,10 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typecheck import typechecked
2
4
  from zrb.helper.typing import Any, Mapping
3
5
 
6
+ logger.debug(colored("Loading zrb.helper.map.conversion", attrs=["dark"]))
7
+
4
8
 
5
9
  @typechecked
6
10
  def to_str(
zrb/helper/python_task.py CHANGED
@@ -1,10 +1,13 @@
1
1
  import sys
2
2
 
3
3
  from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
4
5
  from zrb.helper.task import show_lines as task_show_lines
5
6
  from zrb.helper.typecheck import typechecked
6
7
  from zrb.task.task import Task
7
8
 
9
+ logger.debug(colored("Loading zrb.helper.python_task", attrs=["dark"]))
10
+
8
11
  _DEPRECATION_WARNING = """
9
12
  DEPRECATED: zrb.helper.python_task
10
13
  Use zrb.helper.task instead
zrb/helper/render_data.py CHANGED
@@ -3,6 +3,8 @@ import os
3
3
  import platform
4
4
  import time
5
5
 
6
+ from zrb.helper.accessories.color import colored
7
+ from zrb.helper.log import logger
6
8
  from zrb.helper.util import (
7
9
  coalesce,
8
10
  coalesce_str,
@@ -14,6 +16,8 @@ from zrb.helper.util import (
14
16
  to_snake_case,
15
17
  )
16
18
 
19
+ logger.debug(colored("Loading zrb.helper.render_data", attrs=["dark"]))
20
+
17
21
  DEFAULT_RENDER_DATA = {
18
22
  "datetime": datetime,
19
23
  "os": os,
@@ -1,54 +1,31 @@
1
- import keyword
2
- import logging
3
- import re
4
-
5
- from zrb.helper.string.constant import FALSE_STRS, TRUE_STRS
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
3
+ from zrb.helper.string.untyped_conversion import (
4
+ untyped_to_boolean,
5
+ untyped_to_cli_name,
6
+ untyped_to_logging_level,
7
+ untyped_to_variable_name,
8
+ )
6
9
  from zrb.helper.typecheck import typechecked
7
10
 
8
- NON_WORD = re.compile(r"[\W]+")
9
- LEADING_NUM = re.compile(r"^\d+")
10
- LOGGING_LEVEL_MAP = {
11
- "critical": logging.CRITICAL,
12
- "fatal": logging.FATAL,
13
- "error": logging.ERROR,
14
- "warning": logging.WARNING,
15
- "warn": logging.WARN,
16
- "info": logging.INFO,
17
- "debug": logging.DEBUG,
18
- "notset": logging.NOTSET,
19
- }
11
+ logger.debug(colored("Loading zrb.helper.string.conversion", attrs=["dark"]))
20
12
 
21
13
 
22
14
  @typechecked
23
15
  def to_cli_name(name: str) -> str:
24
- return NON_WORD.sub("-", name).strip("-").lower()
16
+ return untyped_to_cli_name((name))
25
17
 
26
18
 
27
19
  @typechecked
28
20
  def to_variable_name(string: str) -> str:
29
- # Replace any non-word characters with underscore
30
- string = NON_WORD.sub("_", string).strip()
31
- # Remove leading digits
32
- string = LEADING_NUM.sub("", string)
33
- # Convert to lowercase
34
- string = string.lower()
35
- if keyword.iskeyword(string):
36
- return string + "_"
37
- return string
21
+ return untyped_to_variable_name(string)
38
22
 
39
23
 
40
24
  @typechecked
41
25
  def to_boolean(string: str) -> bool:
42
- if string.lower() in TRUE_STRS:
43
- return True
44
- if string.lower() in FALSE_STRS:
45
- return False
46
- raise Exception(f'Cannot infer boolean value from "{string}"')
26
+ return untyped_to_boolean(string)
47
27
 
48
28
 
49
29
  @typechecked
50
30
  def to_logging_level(logging_level_str: str) -> int:
51
- lower_logging_level_str = logging_level_str.lower()
52
- if lower_logging_level_str in LOGGING_LEVEL_MAP:
53
- return LOGGING_LEVEL_MAP[lower_logging_level_str]
54
- return logging.WARNING
31
+ return untyped_to_logging_level(logging_level_str)
@@ -1,6 +1,10 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typecheck import typechecked
2
4
  from zrb.helper.typing import Any
3
5
 
6
+ logger.debug(colored("Loading zrb.helper.string.jinja", attrs=["dark"]))
7
+
4
8
 
5
9
  @typechecked
6
10
  def is_probably_jinja(value: Any) -> bool:
@@ -1,5 +1,9 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typecheck import typechecked
2
4
 
5
+ logger.debug(colored("Loading zrb.helper.string.modification", attrs=["dark"]))
6
+
3
7
 
4
8
  @typechecked
5
9
  def double_quote(text: str) -> str:
@@ -1,6 +1,10 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typecheck import typechecked
2
4
  from zrb.helper.typing import Mapping
3
5
 
6
+ logger.debug(colored("Loading zrb.helper.string.parse_replacment", attrs=["dark"]))
7
+
4
8
 
5
9
  @typechecked
6
10
  def parse_replacement(text: str, replacement: Mapping[str, str]):
@@ -0,0 +1,49 @@
1
+ import keyword
2
+ import logging
3
+ import re
4
+
5
+ from zrb.helper.string.constant import FALSE_STRS, TRUE_STRS
6
+
7
+ NON_WORD = re.compile(r"[\W]+")
8
+ LEADING_NUM = re.compile(r"^\d+")
9
+ LOGGING_LEVEL_MAP = {
10
+ "critical": logging.CRITICAL,
11
+ "fatal": logging.FATAL,
12
+ "error": logging.ERROR,
13
+ "warning": logging.WARNING,
14
+ "warn": logging.WARN,
15
+ "info": logging.INFO,
16
+ "debug": logging.DEBUG,
17
+ "notset": logging.NOTSET,
18
+ }
19
+
20
+
21
+ def untyped_to_cli_name(name: str) -> str:
22
+ return NON_WORD.sub("-", name).strip("-").lower()
23
+
24
+
25
+ def untyped_to_variable_name(string: str) -> str:
26
+ # Replace any non-word characters with underscore
27
+ string = NON_WORD.sub("_", string).strip()
28
+ # Remove leading digits
29
+ string = LEADING_NUM.sub("", string)
30
+ # Convert to lowercase
31
+ string = string.lower()
32
+ if keyword.iskeyword(string):
33
+ return string + "_"
34
+ return string
35
+
36
+
37
+ def untyped_to_boolean(string: str) -> bool:
38
+ if string.lower() in TRUE_STRS:
39
+ return True
40
+ if string.lower() in FALSE_STRS:
41
+ return False
42
+ raise Exception(f'Cannot infer boolean value from "{string}"')
43
+
44
+
45
+ def untyped_to_logging_level(logging_level_str: str) -> int:
46
+ lower_logging_level_str = logging_level_str.lower()
47
+ if lower_logging_level_str in LOGGING_LEVEL_MAP:
48
+ return LOGGING_LEVEL_MAP[lower_logging_level_str]
49
+ return logging.WARNING
zrb/helper/task.py CHANGED
@@ -1,6 +1,10 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typecheck import typechecked
2
4
  from zrb.task.task import Task
3
5
 
6
+ logger.debug(colored("Loading zrb.helper.task", attrs=["dark"]))
7
+
4
8
 
5
9
  @typechecked
6
10
  def show_lines(task: Task, *lines: str):
zrb/helper/typecheck.py CHANGED
@@ -1,17 +1,16 @@
1
- import os
2
1
  from typing import TypeVar
3
2
 
4
- from beartype import beartype
5
-
6
- from zrb.helper.string.constant import FALSE_STRS
7
-
8
- enable_type_checking_str = os.getenv("ZRB_ENABLE_TYPE_CHECKING", "1").lower()
9
- enable_type_checking = enable_type_checking_str not in FALSE_STRS
3
+ from zrb.config.config import enable_type_checking
4
+ from zrb.helper.accessories.untyped_color import untyped_colored as colored
5
+ from zrb.helper.log import logger
10
6
 
7
+ logger.debug(colored("Loading zrb.helper.typecheck", attrs=["dark"]))
11
8
  T = TypeVar("T")
12
9
 
13
10
 
14
11
  def typechecked(anything: T) -> T:
15
12
  if enable_type_checking:
13
+ from beartype import beartype
14
+
16
15
  return beartype(anything)
17
16
  return anything
zrb/helper/typing.py CHANGED
@@ -1,15 +1,35 @@
1
- from beartype.typing import (
2
- Any,
3
- Callable,
4
- Iterable,
5
- List,
6
- Mapping,
7
- Optional,
8
- Tuple,
9
- Type,
10
- TypeVar,
11
- Union,
12
- )
1
+ from zrb.config.config import enable_type_checking
2
+ from zrb.helper.accessories.untyped_color import untyped_colored as colored
3
+ from zrb.helper.log import logger
4
+
5
+ logger.debug(colored("Loading zrb.helper.typing", attrs=["dark"]))
6
+
7
+ if enable_type_checking:
8
+ from beartype.typing import (
9
+ Any,
10
+ Callable,
11
+ Iterable,
12
+ List,
13
+ Mapping,
14
+ Optional,
15
+ Tuple,
16
+ Type,
17
+ TypeVar,
18
+ Union,
19
+ )
20
+ else:
21
+ from typing import (
22
+ Any,
23
+ Callable,
24
+ Iterable,
25
+ List,
26
+ Mapping,
27
+ Optional,
28
+ Tuple,
29
+ Type,
30
+ TypeVar,
31
+ Union,
32
+ )
13
33
 
14
34
  JinjaTemplate = str
15
35
 
zrb/helper/util.py CHANGED
@@ -2,10 +2,14 @@ import re
2
2
 
3
3
  import jinja2
4
4
 
5
+ from zrb.helper.accessories.color import colored
6
+ from zrb.helper.log import logger
5
7
  from zrb.helper.string.conversion import to_boolean as conversion_to_boolean
6
8
  from zrb.helper.typecheck import typechecked
7
9
  from zrb.helper.typing import Any, Optional
8
10
 
11
+ logger.debug(colored("Loading zrb.helper.util", attrs=["dark"]))
12
+
9
13
  NON_ALPHA_NUM = re.compile(r"[^a-zA-Z0-9]+")
10
14
 
11
15
 
zrb/runner.py CHANGED
@@ -1,4 +1,7 @@
1
1
  from zrb.action.runner import Runner
2
2
  from zrb.config.config import env_prefix
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
 
6
+ logger.debug(colored("Loading zrb.runner", attrs=["dark"]))
4
7
  runner = Runner(env_prefix=env_prefix)
zrb/task/any_task.py CHANGED
@@ -1,5 +1,7 @@
1
1
  from abc import ABC, abstractmethod
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typing import (
4
6
  Any,
5
7
  Callable,
@@ -15,6 +17,8 @@ from zrb.task_env.env import Env
15
17
  from zrb.task_env.env_file import EnvFile
16
18
  from zrb.task_input.any_input import AnyInput
17
19
 
20
+ logger.debug(colored("Loading zrb.task.any_task", attrs=["dark"]))
21
+
18
22
  # flake8: noqa E501
19
23
  TAnyTask = TypeVar("TAnyTask", bound="AnyTask")
20
24
 
@@ -304,6 +308,7 @@ class AnyTask(ABC):
304
308
  is_async: bool = False,
305
309
  show_done_info: bool = True,
306
310
  should_clear_xcom: bool = False,
311
+ should_stop_looper: bool = False,
307
312
  ) -> Callable[..., Any]:
308
313
  """
309
314
  Converts the current task into a callable function.
@@ -1,6 +1,10 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typing import Any, Callable
2
4
  from zrb.task.any_task import AnyTask
3
5
 
6
+ logger.debug(colored("Loading zrb.task.any_task_event_handler", attrs=["dark"]))
7
+
4
8
  _TaskEventHandler = Callable[[AnyTask], Any]
5
9
  OnTriggered = _TaskEventHandler
6
10
  OnWaiting = _TaskEventHandler
@@ -2,6 +2,8 @@ import copy
2
2
  import os
3
3
  import pathlib
4
4
 
5
+ from zrb.helper.accessories.color import colored
6
+ from zrb.helper.log import logger
5
7
  from zrb.helper.typecheck import typechecked
6
8
  from zrb.helper.typing import (
7
9
  Any,
@@ -31,6 +33,8 @@ from zrb.task_env.env_file import EnvFile
31
33
  from zrb.task_group.group import Group
32
34
  from zrb.task_input.any_input import AnyInput
33
35
 
36
+ logger.debug(colored("Loading zrb.task.base_remote_cmd_task", attrs=["dark"]))
37
+
34
38
  TSingleBaseRemoteCmdTask = TypeVar(
35
39
  "TSingleBaseRemoteCmdTask", bound="SingleBaseRemoteCmdTask"
36
40
  )
@@ -26,6 +26,7 @@ from zrb.task.any_task_event_handler import (
26
26
  from zrb.task.base_task.component.base_task_model import BaseTaskModel
27
27
  from zrb.task.base_task.component.renderer import Renderer
28
28
  from zrb.task.base_task.component.trackers import AttemptTracker, FinishTracker
29
+ from zrb.task.looper import looper
29
30
  from zrb.task.parallel import AnyParallel
30
31
  from zrb.task_env.env import Env, PrivateEnv
31
32
  from zrb.task_env.env_file import EnvFile
@@ -140,7 +141,7 @@ class BaseTask(FinishTracker, AttemptTracker, Renderer, BaseTaskModel, AnyTask):
140
141
  xcom_dir = self.__get_xcom_dir()
141
142
  xcom_file = os.path.join(xcom_dir, key)
142
143
  with open(xcom_file, "w") as f:
143
- f.write(value)
144
+ f.write(f"{value}")
144
145
 
145
146
  def get_xcom(self, key: str) -> str:
146
147
  self.__ensure_xcom_dir_exists()
@@ -164,6 +165,7 @@ class BaseTask(FinishTracker, AttemptTracker, Renderer, BaseTaskModel, AnyTask):
164
165
  is_async: bool = False,
165
166
  show_done_info: bool = True,
166
167
  should_clear_xcom: bool = False,
168
+ should_stop_looper: bool = False,
167
169
  ) -> Callable[..., Any]:
168
170
  async def function(*args: Any, **kwargs: Any) -> Any:
169
171
  self.log_info("Copy task")
@@ -175,6 +177,8 @@ class BaseTask(FinishTracker, AttemptTracker, Renderer, BaseTaskModel, AnyTask):
175
177
  kwargs=kwargs,
176
178
  show_done_info=show_done_info,
177
179
  )
180
+ if should_stop_looper:
181
+ looper.stop()
178
182
  if should_clear_xcom:
179
183
  self_cp.clear_xcom()
180
184
  return result
zrb/task/checker.py CHANGED
@@ -1,5 +1,7 @@
1
1
  import asyncio
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
  from zrb.helper.typing import Any, Callable, Iterable, Optional, Union
5
7
  from zrb.task.any_task import AnyTask
@@ -18,6 +20,8 @@ from zrb.task_env.env_file import EnvFile
18
20
  from zrb.task_group.group import Group
19
21
  from zrb.task_input.any_input import AnyInput
20
22
 
23
+ logger.debug(colored("Loading zrb.task.checker", attrs=["dark"]))
24
+
21
25
 
22
26
  @typechecked
23
27
  class Checker(BaseTask):
@@ -79,15 +83,15 @@ class Checker(BaseTask):
79
83
  while True:
80
84
  self._should_show_progress = wait_time >= self._progress_interval
81
85
  inspect_result = await self.inspect(*args, **kwargs)
82
- if inspect_result == self._expected_result:
86
+ if inspect_result is not None and inspect_result == self._expected_result:
83
87
  return True
84
88
  if wait_time >= self._progress_interval:
85
89
  wait_time = 0
86
90
  await asyncio.sleep(self._checking_interval)
87
91
  wait_time += self._checking_interval
88
92
 
89
- async def inspect(self, *args: Any, **kwargs: Any) -> bool:
90
- return False
93
+ async def inspect(self, *args: Any, **kwargs: Any) -> Optional[bool]:
94
+ return None
91
95
 
92
96
  def show_progress(self, message: str):
93
97
  if self._should_show_progress:
zrb/task/cmd_task.py CHANGED
@@ -8,7 +8,8 @@ import sys
8
8
  import time
9
9
 
10
10
  from zrb.config.config import default_shell
11
- from zrb.helper.string.conversion import to_variable_name
11
+ from zrb.helper.accessories.color import colored
12
+ from zrb.helper.log import logger
12
13
  from zrb.helper.typecheck import typechecked
13
14
  from zrb.helper.typing import (
14
15
  Any,
@@ -36,6 +37,8 @@ from zrb.task_env.env_file import EnvFile
36
37
  from zrb.task_group.group import Group
37
38
  from zrb.task_input.any_input import AnyInput
38
39
 
40
+ logger.debug(colored("Loading zrb.task.cmd_task", attrs=["dark"]))
41
+
39
42
  _has_stty = True
40
43
  try:
41
44
  _original_stty = subprocess.getoutput("stty -g").rstrip()
@@ -196,8 +199,17 @@ class CmdTask(BaseTask):
196
199
  raise_error: bool = True,
197
200
  is_async: bool = False,
198
201
  show_done_info: bool = True,
202
+ should_clear_xcom: bool = False,
203
+ should_stop_looper: bool = False,
199
204
  ) -> Callable[..., CmdResult]:
200
- return super().to_function(env_prefix, raise_error, is_async, show_done_info)
205
+ return super().to_function(
206
+ env_prefix=env_prefix,
207
+ raise_error=raise_error,
208
+ is_async=is_async,
209
+ show_done_info=show_done_info,
210
+ should_clear_xcom=should_clear_xcom,
211
+ should_stop_looper=should_stop_looper,
212
+ )
201
213
 
202
214
  def print_result(self, result: CmdResult):
203
215
  if not self._should_print_cmd_result or result.output == "":
zrb/task/decorator.py CHANGED
@@ -1,4 +1,6 @@
1
1
  from zrb.action.runner import Runner
2
+ from zrb.helper.accessories.color import colored
3
+ from zrb.helper.log import logger
2
4
  from zrb.helper.typecheck import typechecked
3
5
  from zrb.helper.typing import Any, Callable, Iterable, Optional, Union
4
6
  from zrb.task.any_task import AnyTask
@@ -17,6 +19,8 @@ from zrb.task_env.env_file import EnvFile
17
19
  from zrb.task_group.group import Group
18
20
  from zrb.task_input.any_input import AnyInput
19
21
 
22
+ logger.debug(colored("Loading zrb.task.decorator", attrs=["dark"]))
23
+
20
24
  # flake8: noqa E501
21
25
 
22
26
 
@@ -2,9 +2,11 @@ import os
2
2
  import pathlib
3
3
 
4
4
  from zrb.config.config import container_backend
5
+ from zrb.helper.accessories.color import colored
5
6
  from zrb.helper.accessories.name import get_random_name
6
7
  from zrb.helper.docker_compose.fetch_external_env import fetch_compose_file_env_map
7
8
  from zrb.helper.docker_compose.file import read_compose_file, write_compose_file
9
+ from zrb.helper.log import logger
8
10
  from zrb.helper.string.conversion import to_cli_name
9
11
  from zrb.helper.string.modification import double_quote
10
12
  from zrb.helper.typecheck import typechecked
@@ -37,6 +39,8 @@ from zrb.task_env.env_file import EnvFile
37
39
  from zrb.task_group.group import Group
38
40
  from zrb.task_input.any_input import AnyInput
39
41
 
42
+ logger.debug(colored("Loading zrb.task.docker_compose_task", attrs=["dark"]))
43
+
40
44
 
41
45
  def _get_ensure_zrb_network_task(backend: str):
42
46
  CURRENT_DIR = os.path.dirname(__file__)
zrb/task/flow_task.py CHANGED
@@ -1,3 +1,5 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typecheck import typechecked
2
4
  from zrb.helper.typing import Callable, Iterable, List, Optional, TypeVar, Union
3
5
  from zrb.task.any_task import AnyTask
@@ -16,6 +18,8 @@ from zrb.task_env.env_file import EnvFile
16
18
  from zrb.task_group.group import Group
17
19
  from zrb.task_input.any_input import AnyInput
18
20
 
21
+ logger.debug(colored("Loading zrb.task.flow_task", attrs=["dark"]))
22
+
19
23
  TFlowTask = TypeVar("TFlowTask", bound="FlowTask")
20
24
 
21
25
 
zrb/task/http_checker.py CHANGED
@@ -1,5 +1,7 @@
1
1
  from http.client import HTTPConnection, HTTPSConnection
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
  from zrb.helper.typing import (
5
7
  Any,
@@ -26,6 +28,8 @@ from zrb.task_env.env_file import EnvFile
26
28
  from zrb.task_group.group import Group
27
29
  from zrb.task_input.any_input import AnyInput
28
30
 
31
+ logger.debug(colored("Loading zrb.task.http_checker", attrs=["dark"]))
32
+
29
33
  THTTPChecker = TypeVar("THTTPChecker", bound="HTTPChecker")
30
34
 
31
35
 
@@ -129,8 +133,17 @@ class HTTPChecker(Checker):
129
133
  raise_error: bool = True,
130
134
  is_async: bool = False,
131
135
  show_done_info: bool = True,
136
+ should_clear_xcom: bool = False,
137
+ should_stop_looper: bool = False,
132
138
  ) -> Callable[..., bool]:
133
- return super().to_function(env_prefix, raise_error, is_async, show_done_info)
139
+ return super().to_function(
140
+ env_prefix=env_prefix,
141
+ raise_error=raise_error,
142
+ is_async=is_async,
143
+ show_done_info=show_done_info,
144
+ should_clear_xcom=should_clear_xcom,
145
+ should_stop_looper=should_stop_looper,
146
+ )
134
147
 
135
148
  async def run(self, *args: Any, **kwargs: Any) -> bool:
136
149
  self._config = HttpConnectionConfig(
zrb/task/looper.py ADDED
@@ -0,0 +1,40 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.callable import run_async
3
+ from zrb.helper.log import logger
4
+ from zrb.helper.typing import Callable, List, Mapping, Optional
5
+
6
+ logger.debug(colored("Loading zrb.task.looper", attrs=["dark"]))
7
+
8
+
9
+ class Looper:
10
+ def __init__(self):
11
+ self._queue: Mapping[str, List[Optional[bool]]] = {}
12
+ self._should_stop = False
13
+
14
+ async def pop(self, identifier: str) -> Optional[bool]:
15
+ if identifier not in self._queue or len(self._queue[identifier]) == 0:
16
+ return None
17
+ return self._queue[identifier].pop(0)
18
+
19
+ def stop(self):
20
+ self._should_stop = True
21
+
22
+ def is_registered(self, identifier: str) -> bool:
23
+ return identifier in self._queue
24
+
25
+ async def register(self, identifier: str, function: Callable[..., Optional[bool]]):
26
+ if identifier in self._queue:
27
+ return
28
+ self._queue[identifier] = []
29
+ while not self._should_stop:
30
+ try:
31
+ result = await run_async(function)
32
+ if result is not None:
33
+ if not result:
34
+ continue
35
+ self._queue[identifier].append(result)
36
+ except KeyboardInterrupt:
37
+ break
38
+
39
+
40
+ looper = Looper()