zrb 0.24.0__py3-none-any.whl → 0.25.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/action/runner.py +6 -5
- zrb/advertisement.py +1 -2
- zrb/builtin/base64/decode.py +1 -1
- zrb/builtin/base64/encode.py +1 -1
- zrb/builtin/devtool/install/_helper.py +2 -1
- zrb/builtin/env/get.py +3 -2
- zrb/builtin/eval.py +2 -1
- zrb/builtin/git/get_file_changes.py +2 -1
- zrb/builtin/md5/hash.py +1 -1
- zrb/builtin/md5/sum.py +1 -1
- zrb/builtin/project/_helper.py +3 -3
- zrb/builtin/project/add/app/generator/generator.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/snake_zrb_generator_name.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/remove.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/start.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/stop.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/src/kebab-zrb-app-name/docker-compose.yml +0 -2
- zrb/builtin/project/add/app/python/python.py +1 -1
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/remove.py +1 -1
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/start.py +1 -1
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/stop.py +1 -1
- zrb/builtin/project/add/app/python/template/src/kebab-zrb-app-name/docker-compose.yml +0 -2
- zrb/builtin/project/add/fastapp/app/app.py +3 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_helper.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_service_config.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/_helper.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/_helper.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/stop.py +2 -0
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/_helper.py +5 -3
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/frontend/build-once.sh +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/frontend/build.sh +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/_helper.py +3 -5
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/start.py +3 -3
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/{start_microservices.py → start_services.py} +2 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/.generator-version +1 -0
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/deployment/_common.py +5 -5
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/deployment/app_helper.py +5 -5
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/docker-compose.yml +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/error.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/kafka/admin.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/kafka/consumer.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/messagebus.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/mock.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/rabbitmq/admin.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/rabbitmq/consumer.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/model/repo_model.py +3 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/db_repo.py +7 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/repo.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/search_filter.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/messagebus/caller.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/messagebus/server.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/rpc.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/serializer/serializer.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/config.py +3 -4
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/helper/async_task.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/component/access_token/scheme.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/component/access_token/util.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/group/repo.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/group/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/api.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/model.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/repo.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/rpc.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/register_permission.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/group.py +3 -5
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/permission.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/request.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/user.py +5 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/entity/activity/event.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/entity/activity/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/schema/activity.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_permission_crud.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_login.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/test_liveness_and_readiness.py +1 -1
- zrb/builtin/project/add/fastapp/crud/_task_factory.py +1 -2
- zrb/builtin/project/add/fastapp/crud/crud.py +1 -1
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/schema/snake_zrb_entity_name.py +2 -2
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/test/snake_zrb_module_name/test_snake_zrb_entity_name.py +1 -1
- zrb/builtin/project/add/fastapp/field/field.py +1 -1
- zrb/builtin/project/add/fastapp/module/_helper/create_microservice_config.py +7 -8
- zrb/builtin/project/add/fastapp/module/module.py +1 -1
- zrb/builtin/project/add/plugin/plugin.py +1 -1
- zrb/builtin/project/add/project_task/add.py +1 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/build.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/container/remove.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/container/start.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/container/stop.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/deploy.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/destroy.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/get_env.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/image/build.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/image/push.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/publish.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/start.py +2 -1
- zrb/builtin/project/add/task/cmd/add.py +1 -1
- zrb/builtin/project/add/task/docker_compose/add.py +1 -1
- zrb/builtin/project/add/task/docker_compose/template/src/kebab-zrb-task-name/docker-compose.yml +0 -2
- zrb/builtin/project/add/task/python/add.py +1 -1
- zrb/builtin/project/add/task/python/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/project/create/_helper.py +1 -1
- zrb/builtin/project/create/create.py +1 -1
- zrb/builtin/say.py +3 -3
- zrb/builtin/version.py +2 -1
- zrb/config/config.py +12 -2
- zrb/helper/accessories/color.py +2 -1
- zrb/helper/advertisement.py +2 -1
- zrb/helper/callable.py +2 -1
- zrb/helper/cli.py +17 -3
- zrb/helper/codemod/add_import_module.py +3 -2
- zrb/helper/codemod/add_property_to_class.py +2 -1
- zrb/helper/default_env.py +2 -1
- zrb/helper/docker_compose/fetch_external_env.py +4 -2
- zrb/helper/docker_compose/file.py +3 -1
- zrb/helper/env_map/fetch.py +3 -2
- zrb/helper/file/copy_tree.py +2 -1
- zrb/helper/file/match.py +2 -2
- zrb/helper/git/detect_changes.py +1 -1
- zrb/helper/loader/load_module.py +7 -46
- zrb/helper/loader/load_script.py +57 -0
- zrb/helper/map/conversion.py +3 -1
- zrb/helper/string/jinja.py +2 -1
- zrb/helper/string/parse_replacement.py +1 -1
- zrb/helper/typing.py +5 -27
- zrb/helper/util.py +1 -1
- zrb/task/any_task.py +9 -17
- zrb/task/any_task_event_handler.py +3 -1
- zrb/task/base_remote_cmd_task.py +3 -10
- zrb/task/base_task/base_task.py +12 -8
- zrb/task/base_task/component/base_task_model.py +6 -13
- zrb/task/base_task/component/common_task_model.py +15 -22
- zrb/task/base_task/component/renderer.py +3 -1
- zrb/task/base_task/component/trackers.py +1 -1
- zrb/task/checker.py +2 -1
- zrb/task/cmd_task.py +4 -11
- zrb/task/decorator.py +3 -1
- zrb/task/docker_compose_start_task.py +27 -32
- zrb/task/docker_compose_task.py +27 -35
- zrb/task/flow_task.py +19 -17
- zrb/task/http_checker.py +3 -9
- zrb/task/looper.py +4 -2
- zrb/task/notifier.py +3 -1
- zrb/task/parallel.py +4 -4
- zrb/task/path_checker.py +6 -12
- zrb/task/path_watcher.py +5 -13
- zrb/task/port_checker.py +3 -9
- zrb/task/recurring_task.py +5 -4
- zrb/task/remote_cmd_task.py +2 -1
- zrb/task/resource_maker.py +6 -13
- zrb/task/rsync_task.py +3 -1
- zrb/task/server.py +13 -12
- zrb/task/time_watcher.py +3 -10
- zrb/task/watcher.py +2 -1
- zrb/task/wiki_task.py +4 -3
- zrb/task_env/env.py +2 -1
- zrb/task_env/env_file.py +7 -6
- zrb/task_group/group.py +8 -7
- zrb/task_input/any_input.py +4 -3
- zrb/task_input/base_input.py +5 -3
- zrb/task_input/bool_input.py +2 -1
- zrb/task_input/choice_input.py +3 -1
- zrb/task_input/float_input.py +2 -1
- zrb/task_input/int_input.py +2 -1
- zrb/task_input/multiline_input.py +3 -1
- zrb/task_input/password_input.py +2 -1
- zrb/task_input/str_input.py +2 -1
- {zrb-0.24.0.dist-info → zrb-0.25.1.dist-info}/METADATA +1 -1
- {zrb-0.24.0.dist-info → zrb-0.25.1.dist-info}/RECORD +174 -172
- {zrb-0.24.0.dist-info → zrb-0.25.1.dist-info}/LICENSE +0 -0
- {zrb-0.24.0.dist-info → zrb-0.25.1.dist-info}/WHEEL +0 -0
- {zrb-0.24.0.dist-info → zrb-0.25.1.dist-info}/entry_points.txt +0 -0
zrb/helper/map/conversion.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
from collections.abc import Mapping
|
2
|
+
from typing import Any
|
3
|
+
|
1
4
|
from zrb.helper.accessories.color import colored
|
2
5
|
from zrb.helper.log import logger
|
3
6
|
from zrb.helper.typecheck import typechecked
|
4
|
-
from zrb.helper.typing import Any, Mapping
|
5
7
|
|
6
8
|
logger.debug(colored("Loading zrb.helper.map.conversion", attrs=["dark"]))
|
7
9
|
|
zrb/helper/string/jinja.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
from typing import Any
|
2
|
+
|
1
3
|
from zrb.helper.accessories.color import colored
|
2
4
|
from zrb.helper.log import logger
|
3
5
|
from zrb.helper.typecheck import typechecked
|
4
|
-
from zrb.helper.typing import Any
|
5
6
|
|
6
7
|
logger.debug(colored("Loading zrb.helper.string.jinja", attrs=["dark"]))
|
7
8
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import re
|
2
|
+
from collections.abc import Mapping
|
2
3
|
|
3
4
|
from zrb.helper.accessories.color import colored
|
4
5
|
from zrb.helper.log import logger
|
5
6
|
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.typing import Mapping
|
7
7
|
|
8
8
|
logger.debug(colored("Loading zrb.helper.string.parse_replacment", attrs=["dark"]))
|
9
9
|
|
zrb/helper/typing.py
CHANGED
@@ -1,35 +1,13 @@
|
|
1
|
-
from
|
1
|
+
from collections.abc import Callable, Iterable, Mapping
|
2
|
+
from typing import Any, Optional, Type, TypeVar, Union
|
3
|
+
|
2
4
|
from zrb.helper.accessories.untyped_color import untyped_colored as colored
|
3
5
|
from zrb.helper.log import logger
|
4
6
|
|
5
7
|
logger.debug(colored("Loading zrb.helper.typing", attrs=["dark"]))
|
6
8
|
|
7
|
-
|
8
|
-
|
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
|
-
)
|
9
|
+
Tuple = tuple
|
10
|
+
List = list
|
33
11
|
|
34
12
|
JinjaTemplate = str
|
35
13
|
|
zrb/helper/util.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import re
|
2
2
|
from functools import lru_cache
|
3
|
+
from typing import Any, Optional
|
3
4
|
|
4
5
|
import jinja2
|
5
6
|
|
@@ -7,7 +8,6 @@ from zrb.helper.accessories.color import colored
|
|
7
8
|
from zrb.helper.log import logger
|
8
9
|
from zrb.helper.string.conversion import to_boolean as conversion_to_boolean
|
9
10
|
from zrb.helper.typecheck import typechecked
|
10
|
-
from zrb.helper.typing import Any, Optional
|
11
11
|
|
12
12
|
logger.debug(colored("Loading zrb.helper.util", attrs=["dark"]))
|
13
13
|
|
zrb/task/any_task.py
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
|
+
from collections.abc import Callable, Iterable, Mapping
|
3
|
+
from typing import Any, Optional, TypeVar, Union
|
2
4
|
|
3
5
|
from zrb.helper.accessories.color import colored
|
4
6
|
from zrb.helper.log import logger
|
5
|
-
from zrb.helper.typing import
|
6
|
-
Any,
|
7
|
-
Callable,
|
8
|
-
Iterable,
|
9
|
-
JinjaTemplate,
|
10
|
-
List,
|
11
|
-
Mapping,
|
12
|
-
Optional,
|
13
|
-
TypeVar,
|
14
|
-
Union,
|
15
|
-
)
|
7
|
+
from zrb.helper.typing import JinjaTemplate
|
16
8
|
from zrb.task_env.env import Env
|
17
9
|
from zrb.task_env.env_file import EnvFile
|
18
10
|
from zrb.task_input.any_input import AnyInput
|
@@ -824,7 +816,7 @@ class AnyTask(ABC):
|
|
824
816
|
pass
|
825
817
|
|
826
818
|
@abstractmethod
|
827
|
-
def _get_env_files(self) ->
|
819
|
+
def _get_env_files(self) -> list[EnvFile]:
|
828
820
|
"""
|
829
821
|
Retrieves the list of environment variable files associated with the task.
|
830
822
|
|
@@ -832,7 +824,7 @@ class AnyTask(ABC):
|
|
832
824
|
uses to load environment variables, primarily for setup and configuration purposes.
|
833
825
|
|
834
826
|
Returns:
|
835
|
-
|
827
|
+
list[EnvFile]: A list of `EnvFile` instances associated with the task.
|
836
828
|
"""
|
837
829
|
pass
|
838
830
|
|
@@ -850,7 +842,7 @@ class AnyTask(ABC):
|
|
850
842
|
pass
|
851
843
|
|
852
844
|
@abstractmethod
|
853
|
-
def _get_envs(self) ->
|
845
|
+
def _get_envs(self) -> list[Env]:
|
854
846
|
"""
|
855
847
|
Retrieves the list of environment variables set for the task.
|
856
848
|
|
@@ -858,7 +850,7 @@ class AnyTask(ABC):
|
|
858
850
|
configured for the task, essential for understanding and debugging the task's environment setup.
|
859
851
|
|
860
852
|
Returns:
|
861
|
-
|
853
|
+
list[Env]: A list of `Env` instances representing the environment variables of the task.
|
862
854
|
"""
|
863
855
|
pass
|
864
856
|
|
@@ -880,7 +872,7 @@ class AnyTask(ABC):
|
|
880
872
|
pass
|
881
873
|
|
882
874
|
@abstractmethod
|
883
|
-
def _get_inputs(self) ->
|
875
|
+
def _get_inputs(self) -> list[AnyInput]:
|
884
876
|
"""
|
885
877
|
Retrieves the list of inputs associated with the task.
|
886
878
|
|
@@ -889,7 +881,7 @@ class AnyTask(ABC):
|
|
889
881
|
for introspection and debugging purposes.
|
890
882
|
|
891
883
|
Returns:
|
892
|
-
|
884
|
+
list[AnyInput]: A list of `AnyInput` instances representing the inputs for the task.
|
893
885
|
"""
|
894
886
|
pass
|
895
887
|
|
@@ -1,6 +1,8 @@
|
|
1
|
+
from collections.abc import Callable
|
2
|
+
from typing import Any
|
3
|
+
|
1
4
|
from zrb.helper.accessories.color import colored
|
2
5
|
from zrb.helper.log import logger
|
3
|
-
from zrb.helper.typing import Any, Callable
|
4
6
|
from zrb.task.any_task import AnyTask
|
5
7
|
|
6
8
|
logger.debug(colored("Loading zrb.task.any_task_event_handler", attrs=["dark"]))
|
zrb/task/base_remote_cmd_task.py
CHANGED
@@ -1,19 +1,12 @@
|
|
1
1
|
import os
|
2
2
|
import pathlib
|
3
|
+
from collections.abc import Callable, Iterable, Mapping
|
4
|
+
from typing import Any, Optional, TypeVar, Union
|
3
5
|
|
4
6
|
from zrb.helper.accessories.color import colored
|
5
7
|
from zrb.helper.log import logger
|
6
8
|
from zrb.helper.typecheck import typechecked
|
7
|
-
from zrb.helper.typing import
|
8
|
-
Any,
|
9
|
-
Callable,
|
10
|
-
Iterable,
|
11
|
-
JinjaTemplate,
|
12
|
-
Mapping,
|
13
|
-
Optional,
|
14
|
-
TypeVar,
|
15
|
-
Union,
|
16
|
-
)
|
9
|
+
from zrb.helper.typing import JinjaTemplate
|
17
10
|
from zrb.helper.util import to_snake_case
|
18
11
|
from zrb.task.any_task import AnyTask
|
19
12
|
from zrb.task.any_task_event_handler import (
|
zrb/task/base_task/base_task.py
CHANGED
@@ -2,6 +2,8 @@ import asyncio
|
|
2
2
|
import copy
|
3
3
|
import os
|
4
4
|
import shutil
|
5
|
+
from collections.abc import Callable, Iterable, Mapping
|
6
|
+
from typing import Any, Optional, Union
|
5
7
|
|
6
8
|
from zrb.advertisement import advertisements
|
7
9
|
from zrb.config.config import SHOW_ADVERTISEMENT, TMP_DIR
|
@@ -12,7 +14,6 @@ from zrb.helper.map.conversion import to_str as map_to_str
|
|
12
14
|
from zrb.helper.string.conversion import to_variable_name
|
13
15
|
from zrb.helper.string.modification import double_quote
|
14
16
|
from zrb.helper.typecheck import typechecked
|
15
|
-
from zrb.helper.typing import Any, Callable, Iterable, List, Mapping, Optional, Union
|
16
17
|
from zrb.task.any_task import AnyTask
|
17
18
|
from zrb.task.any_task_event_handler import (
|
18
19
|
OnFailed,
|
@@ -41,14 +42,14 @@ class BaseTask(FinishTracker, AttemptTracker, Renderer, BaseTaskModel, AnyTask):
|
|
41
42
|
Every Task definition should be extended from this class.
|
42
43
|
"""
|
43
44
|
|
44
|
-
__running_tasks:
|
45
|
+
__running_tasks: list[AnyTask] = []
|
45
46
|
|
46
47
|
def __init__(
|
47
48
|
self,
|
48
49
|
name: str,
|
49
50
|
group: Optional[Group] = None,
|
50
51
|
description: str = "",
|
51
|
-
inputs:
|
52
|
+
inputs: list[AnyInput] = [],
|
52
53
|
envs: Iterable[Env] = [],
|
53
54
|
env_files: Iterable[EnvFile] = [],
|
54
55
|
icon: Optional[str] = None,
|
@@ -119,7 +120,7 @@ class BaseTask(FinishTracker, AttemptTracker, Renderer, BaseTaskModel, AnyTask):
|
|
119
120
|
operand.add_upstream(self)
|
120
121
|
return operand
|
121
122
|
if isinstance(operand, AnyParallel):
|
122
|
-
other_tasks:
|
123
|
+
other_tasks: list[AnyTask] = operand.get_tasks()
|
123
124
|
for other_task in other_tasks:
|
124
125
|
other_task.add_upstream(self)
|
125
126
|
return operand
|
@@ -286,6 +287,9 @@ class BaseTask(FinishTracker, AttemptTracker, Renderer, BaseTaskModel, AnyTask):
|
|
286
287
|
result = results[-1]
|
287
288
|
self._print_result(result)
|
288
289
|
return result
|
290
|
+
except RuntimeError as e:
|
291
|
+
if str(e) != "Event loop is closed":
|
292
|
+
raise e
|
289
293
|
except Exception as e:
|
290
294
|
self.log_error(f"{e}")
|
291
295
|
if raise_error:
|
@@ -415,7 +419,7 @@ class BaseTask(FinishTracker, AttemptTracker, Renderer, BaseTaskModel, AnyTask):
|
|
415
419
|
# wait all upstream checkers to complete
|
416
420
|
await asyncio.gather(*coroutines)
|
417
421
|
|
418
|
-
async def __trigger_failure(self, tasks:
|
422
|
+
async def __trigger_failure(self, tasks: list[AnyTask]):
|
419
423
|
coroutines = [
|
420
424
|
task.on_failed(is_last_attempt=True, exception=Exception("canceled"))
|
421
425
|
for task in tasks
|
@@ -423,7 +427,7 @@ class BaseTask(FinishTracker, AttemptTracker, Renderer, BaseTaskModel, AnyTask):
|
|
423
427
|
await asyncio.gather(*coroutines)
|
424
428
|
|
425
429
|
async def __trigger_fallbacks(
|
426
|
-
self, tasks:
|
430
|
+
self, tasks: list[AnyTask], kwargs: Mapping[str, Any]
|
427
431
|
):
|
428
432
|
coroutines: Iterable[asyncio.Task] = []
|
429
433
|
for fallback in self.__get_all_fallbacks(tasks):
|
@@ -431,8 +435,8 @@ class BaseTask(FinishTracker, AttemptTracker, Renderer, BaseTaskModel, AnyTask):
|
|
431
435
|
coroutines.append(asyncio.create_task(fallback._run_all(**kwargs)))
|
432
436
|
await asyncio.gather(*coroutines)
|
433
437
|
|
434
|
-
def __get_all_fallbacks(self, tasks:
|
435
|
-
all_fallbacks:
|
438
|
+
def __get_all_fallbacks(self, tasks: list[AnyTask]) -> list[AnyTask]:
|
439
|
+
all_fallbacks: list[AnyTask] = []
|
436
440
|
for task in tasks:
|
437
441
|
task._lock_fallbacks()
|
438
442
|
for fallback in task._get_fallbacks():
|
@@ -2,7 +2,9 @@ import datetime
|
|
2
2
|
import logging
|
3
3
|
import os
|
4
4
|
import sys
|
5
|
+
from collections.abc import Callable, Iterable, Mapping
|
5
6
|
from functools import lru_cache
|
7
|
+
from typing import Any, Optional, Union
|
6
8
|
|
7
9
|
from zrb.config.config import ENV_PREFIX, LOGGING_LEVEL, SHOW_TIME
|
8
10
|
from zrb.helper.accessories.color import colored
|
@@ -10,16 +12,7 @@ from zrb.helper.log import logger
|
|
10
12
|
from zrb.helper.string.conversion import to_variable_name
|
11
13
|
from zrb.helper.string.modification import double_quote
|
12
14
|
from zrb.helper.typecheck import typechecked
|
13
|
-
from zrb.helper.typing import
|
14
|
-
Any,
|
15
|
-
Callable,
|
16
|
-
Iterable,
|
17
|
-
JinjaTemplate,
|
18
|
-
List,
|
19
|
-
Mapping,
|
20
|
-
Optional,
|
21
|
-
Union,
|
22
|
-
)
|
15
|
+
from zrb.helper.typing import JinjaTemplate
|
23
16
|
from zrb.task.any_task import AnyTask
|
24
17
|
from zrb.task.any_task_event_handler import (
|
25
18
|
OnFailed,
|
@@ -48,7 +41,7 @@ class BaseTaskModel(CommonTaskModel, PidModel, TimeTracker):
|
|
48
41
|
name: str,
|
49
42
|
group: Optional[Group] = None,
|
50
43
|
description: str = "",
|
51
|
-
inputs:
|
44
|
+
inputs: list[AnyInput] = [],
|
52
45
|
envs: Iterable[Env] = [],
|
53
46
|
env_files: Iterable[EnvFile] = [],
|
54
47
|
icon: Optional[str] = None,
|
@@ -102,7 +95,7 @@ class BaseTaskModel(CommonTaskModel, PidModel, TimeTracker):
|
|
102
95
|
)
|
103
96
|
PidModel.__init__(self)
|
104
97
|
TimeTracker.__init__(self)
|
105
|
-
self.__args:
|
98
|
+
self.__args: list[Any] = []
|
106
99
|
self.__kwargs: Mapping[str, Any] = {}
|
107
100
|
|
108
101
|
def _set_args(self, args: Iterable[Any]):
|
@@ -201,7 +194,7 @@ class BaseTaskModel(CommonTaskModel, PidModel, TimeTracker):
|
|
201
194
|
def _show_run_command(self):
|
202
195
|
if not self.__has_cli_interface:
|
203
196
|
return
|
204
|
-
params:
|
197
|
+
params: list[str] = [double_quote(arg) for arg in self.__args]
|
205
198
|
for task_input in self._get_combined_inputs():
|
206
199
|
if task_input.is_hidden():
|
207
200
|
continue
|
@@ -1,19 +1,12 @@
|
|
1
1
|
import os
|
2
|
+
from collections.abc import Callable, Iterable, Mapping
|
3
|
+
from typing import Any, Optional, Union
|
2
4
|
|
3
5
|
from zrb.helper.accessories.color import get_random_color
|
4
6
|
from zrb.helper.accessories.icon import get_random_icon
|
5
7
|
from zrb.helper.string.conversion import to_cli_name
|
6
8
|
from zrb.helper.typecheck import typechecked
|
7
|
-
from zrb.helper.typing import
|
8
|
-
Any,
|
9
|
-
Callable,
|
10
|
-
Iterable,
|
11
|
-
JinjaTemplate,
|
12
|
-
List,
|
13
|
-
Mapping,
|
14
|
-
Optional,
|
15
|
-
Union,
|
16
|
-
)
|
9
|
+
from zrb.helper.typing import JinjaTemplate
|
17
10
|
from zrb.helper.util import coalesce_str
|
18
11
|
from zrb.task.any_task import AnyTask
|
19
12
|
from zrb.task.any_task_event_handler import (
|
@@ -39,7 +32,7 @@ class CommonTaskModel:
|
|
39
32
|
name: str,
|
40
33
|
group: Optional[Group] = None,
|
41
34
|
description: str = "",
|
42
|
-
inputs:
|
35
|
+
inputs: list[AnyInput] = [],
|
43
36
|
envs: Iterable[Env] = [],
|
44
37
|
env_files: Iterable[EnvFile] = [],
|
45
38
|
icon: Optional[str] = None,
|
@@ -65,7 +58,7 @@ class CommonTaskModel:
|
|
65
58
|
self._group = group
|
66
59
|
if group is not None:
|
67
60
|
group._add_task(self)
|
68
|
-
checkers_cp:
|
61
|
+
checkers_cp: list[AnyTask] = [checker.copy() for checker in checkers]
|
69
62
|
for checker in checkers_cp:
|
70
63
|
checker.add_env(*envs)
|
71
64
|
checker.add_env_file(*env_files)
|
@@ -104,7 +97,7 @@ class CommonTaskModel:
|
|
104
97
|
self.__has_already_inject_inputs: bool = False
|
105
98
|
self.__has_already_inject_upstreams: bool = False
|
106
99
|
self.__has_already_inject_fallbacks: bool = False
|
107
|
-
self.__all_inputs: Optional[
|
100
|
+
self.__all_inputs: Optional[list[AnyInput]] = None
|
108
101
|
|
109
102
|
def _lock_checkers(self):
|
110
103
|
self.__allow_add_checkers = False
|
@@ -185,7 +178,7 @@ class CommonTaskModel:
|
|
185
178
|
def inject_inputs(self):
|
186
179
|
pass
|
187
180
|
|
188
|
-
def _get_inputs(self) ->
|
181
|
+
def _get_inputs(self) -> list[AnyInput]:
|
189
182
|
if not self.__has_already_inject_inputs:
|
190
183
|
self.inject_inputs()
|
191
184
|
self.__has_already_inject_inputs = True
|
@@ -197,7 +190,7 @@ class CommonTaskModel:
|
|
197
190
|
"""
|
198
191
|
if self.__all_inputs is not None:
|
199
192
|
return self.__all_inputs
|
200
|
-
self.__all_inputs:
|
193
|
+
self.__all_inputs: list[AnyInput] = []
|
201
194
|
existing_input_names: Mapping[str, bool] = {}
|
202
195
|
# Add task inputs
|
203
196
|
inputs = self._get_inputs()
|
@@ -244,7 +237,7 @@ class CommonTaskModel:
|
|
244
237
|
def inject_envs(self):
|
245
238
|
pass
|
246
239
|
|
247
|
-
def _get_envs(self) ->
|
240
|
+
def _get_envs(self) -> list[Env]:
|
248
241
|
if not self.__has_already_inject_envs:
|
249
242
|
self.inject_envs()
|
250
243
|
self.__has_already_inject_envs = True
|
@@ -297,7 +290,7 @@ class CommonTaskModel:
|
|
297
290
|
def inject_upstreams(self):
|
298
291
|
pass
|
299
292
|
|
300
|
-
def _get_upstreams(self) ->
|
293
|
+
def _get_upstreams(self) -> list[AnyTask]:
|
301
294
|
if not self.__has_already_inject_upstreams:
|
302
295
|
self.inject_upstreams()
|
303
296
|
self.__has_already_inject_upstreams = True
|
@@ -316,7 +309,7 @@ class CommonTaskModel:
|
|
316
309
|
def inject_fallbacks(self):
|
317
310
|
pass
|
318
311
|
|
319
|
-
def _get_fallbacks(self) ->
|
312
|
+
def _get_fallbacks(self) -> list[AnyTask]:
|
320
313
|
if not self.__has_already_inject_fallbacks:
|
321
314
|
self.inject_fallbacks()
|
322
315
|
self.__has_already_inject_fallbacks = True
|
@@ -328,7 +321,7 @@ class CommonTaskModel:
|
|
328
321
|
def get_color(self) -> str:
|
329
322
|
return self._color
|
330
323
|
|
331
|
-
def _get_env_files(self) ->
|
324
|
+
def _get_env_files(self) -> list[EnvFile]:
|
332
325
|
if not self.__has_already_inject_env_files:
|
333
326
|
self.inject_env_files()
|
334
327
|
self.__has_already_inject_env_files = True
|
@@ -346,11 +339,11 @@ class CommonTaskModel:
|
|
346
339
|
additional_checkers = self.__complete_new_checkers(checkers)
|
347
340
|
self._checkers = self._checkers + additional_checkers
|
348
341
|
|
349
|
-
def __complete_new_checkers(self, new_checkers:
|
342
|
+
def __complete_new_checkers(self, new_checkers: Iterable[AnyTask]) -> list[AnyTask]:
|
350
343
|
"""
|
351
344
|
For internal use: copy and completing new checkers
|
352
345
|
"""
|
353
|
-
checkers:
|
346
|
+
checkers: list[AnyTask] = [checker.copy() for checker in new_checkers]
|
354
347
|
for checker in checkers:
|
355
348
|
checker.add_input(*self._get_inputs())
|
356
349
|
checker.add_env(*self._get_envs())
|
@@ -360,7 +353,7 @@ class CommonTaskModel:
|
|
360
353
|
def inject_checkers(self):
|
361
354
|
pass
|
362
355
|
|
363
|
-
def _get_checkers(self) ->
|
356
|
+
def _get_checkers(self) -> list[AnyTask]:
|
364
357
|
if not self.__allow_add_checkers:
|
365
358
|
self.inject_checkers()
|
366
359
|
self.__allow_add_checkers = True
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import os
|
2
|
+
from collections.abc import Mapping
|
3
|
+
from typing import Any, Optional, Union
|
2
4
|
|
3
5
|
import jinja2
|
4
6
|
|
@@ -6,7 +8,7 @@ from zrb.helper.render_data import DEFAULT_RENDER_DATA
|
|
6
8
|
from zrb.helper.string.conversion import to_boolean
|
7
9
|
from zrb.helper.string.jinja import is_probably_jinja
|
8
10
|
from zrb.helper.typecheck import typechecked
|
9
|
-
from zrb.helper.typing import
|
11
|
+
from zrb.helper.typing import JinjaTemplate
|
10
12
|
from zrb.task.any_task import AnyTask
|
11
13
|
|
12
14
|
|
zrb/task/checker.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import asyncio
|
2
|
+
from collections.abc import Callable, Iterable
|
3
|
+
from typing import Any, Optional, Union
|
2
4
|
|
3
5
|
from zrb.helper.accessories.color import colored
|
4
6
|
from zrb.helper.log import logger
|
5
7
|
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.typing import Any, Callable, Iterable, Optional, Union
|
7
8
|
from zrb.task.any_task import AnyTask
|
8
9
|
from zrb.task.any_task_event_handler import (
|
9
10
|
OnFailed,
|
zrb/task/cmd_task.py
CHANGED
@@ -7,21 +7,14 @@ import signal
|
|
7
7
|
import subprocess
|
8
8
|
import sys
|
9
9
|
import time
|
10
|
+
from collections.abc import Callable, Iterable
|
11
|
+
from typing import Any, Optional, TypeVar, Union
|
10
12
|
|
11
13
|
from zrb.config.config import DEFAULT_SHELL, LOGGING_LEVEL
|
12
14
|
from zrb.helper.accessories.color import colored
|
13
15
|
from zrb.helper.log import logger
|
14
16
|
from zrb.helper.typecheck import typechecked
|
15
|
-
from zrb.helper.typing import
|
16
|
-
Any,
|
17
|
-
Callable,
|
18
|
-
Iterable,
|
19
|
-
JinjaTemplate,
|
20
|
-
List,
|
21
|
-
Optional,
|
22
|
-
TypeVar,
|
23
|
-
Union,
|
24
|
-
)
|
17
|
+
from zrb.helper.typing import JinjaTemplate
|
25
18
|
from zrb.task.any_task import AnyTask
|
26
19
|
from zrb.task.any_task_event_handler import (
|
27
20
|
OnFailed,
|
@@ -111,7 +104,7 @@ class CmdTask(BaseTask):
|
|
111
104
|
>>> runner.register(hello)
|
112
105
|
"""
|
113
106
|
|
114
|
-
_pids:
|
107
|
+
_pids: list[int] = []
|
115
108
|
_global_state = CmdGlobalState()
|
116
109
|
|
117
110
|
def __init__(
|
zrb/task/decorator.py
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
from collections.abc import Callable, Iterable
|
2
|
+
from typing import Any, Optional, Union
|
3
|
+
|
1
4
|
from zrb.action.runner import Runner
|
2
5
|
from zrb.helper.accessories.color import colored
|
3
6
|
from zrb.helper.log import logger
|
4
7
|
from zrb.helper.typecheck import typechecked
|
5
|
-
from zrb.helper.typing import Any, Callable, Iterable, Optional, Union
|
6
8
|
from zrb.task.any_task import AnyTask
|
7
9
|
from zrb.task.any_task_event_handler import (
|
8
10
|
OnFailed,
|
@@ -1,18 +1,12 @@
|
|
1
1
|
import os
|
2
2
|
import pathlib
|
3
|
+
from collections.abc import Callable, Iterable, Mapping
|
4
|
+
from typing import Any, Optional, Union
|
3
5
|
|
4
6
|
from zrb.helper.accessories.color import colored
|
5
7
|
from zrb.helper.log import logger
|
6
8
|
from zrb.helper.typecheck import typechecked
|
7
|
-
from zrb.helper.typing import
|
8
|
-
Any,
|
9
|
-
Callable,
|
10
|
-
Iterable,
|
11
|
-
JinjaTemplate,
|
12
|
-
Mapping,
|
13
|
-
Optional,
|
14
|
-
Union,
|
15
|
-
)
|
9
|
+
from zrb.helper.typing import JinjaTemplate
|
16
10
|
from zrb.task.any_task import AnyTask
|
17
11
|
from zrb.task.any_task_event_handler import (
|
18
12
|
OnFailed,
|
@@ -123,29 +117,30 @@ class DockerComposeStartTask(DockerComposeTask):
|
|
123
117
|
)
|
124
118
|
|
125
119
|
def get_cmd_script(self, *args: Any, **kwargs: Any) -> str:
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
self._create_cmd_script(
|
130
|
-
self._setup_cmd_path, self._setup_cmd, *args, **kwargs
|
131
|
-
),
|
132
|
-
# compose start
|
133
|
-
self._get_docker_compose_cmd_script(
|
134
|
-
compose_cmd="up",
|
135
|
-
compose_options=self._compose_options,
|
136
|
-
compose_flags=list(self._compose_flags) + ["-d"],
|
137
|
-
compose_args=self._compose_args,
|
138
|
-
*args,
|
139
|
-
),
|
140
|
-
# compose log
|
141
|
-
self._get_docker_compose_cmd_script(
|
142
|
-
compose_cmd="logs",
|
143
|
-
compose_options={},
|
144
|
-
compose_flags=["-f"],
|
145
|
-
compose_args=[],
|
146
|
-
*args,
|
147
|
-
),
|
148
|
-
]
|
120
|
+
# setup
|
121
|
+
setup_cmd = self._create_cmd_script(
|
122
|
+
self._setup_cmd_path, self._setup_cmd, *args, **kwargs
|
149
123
|
)
|
124
|
+
cmd_list = [setup_cmd] if setup_cmd.strip() != "" else []
|
125
|
+
# compose command
|
126
|
+
cmd_list = cmd_list + [
|
127
|
+
# compose start
|
128
|
+
self._get_docker_compose_cmd_script(
|
129
|
+
compose_cmd="up",
|
130
|
+
compose_options=self._compose_options,
|
131
|
+
compose_flags=list(self._compose_flags) + ["-d"],
|
132
|
+
compose_args=self._compose_args,
|
133
|
+
*args,
|
134
|
+
),
|
135
|
+
# compose log
|
136
|
+
self._get_docker_compose_cmd_script(
|
137
|
+
compose_cmd="logs",
|
138
|
+
compose_options={},
|
139
|
+
compose_flags=["-f"],
|
140
|
+
compose_args=[],
|
141
|
+
*args,
|
142
|
+
),
|
143
|
+
]
|
144
|
+
cmd_str = "\n".join(cmd_list)
|
150
145
|
self.log_info(f"Command: {cmd_str}")
|
151
146
|
return cmd_str
|