zrb 0.6.0__py3-none-any.whl → 0.6.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 +24 -20
- zrb/__main__.py +5 -5
- zrb/action/runner.py +22 -30
- zrb/advertisement.py +10 -9
- zrb/builtin/__init__.py +18 -16
- zrb/builtin/base64.py +13 -18
- zrb/builtin/devtool/__init__.py +14 -3
- zrb/builtin/devtool/devtool_install.py +207 -221
- zrb/builtin/env.py +9 -12
- zrb/builtin/eval.py +9 -9
- zrb/builtin/explain.py +73 -74
- zrb/builtin/generator/__init__.py +7 -11
- zrb/builtin/generator/app_generator/add.py +86 -87
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/add.py +78 -77
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_checker.py +6 -6
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_common.py +14 -15
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/container.py +32 -32
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/deployment.py +29 -30
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/image.py +1 -3
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +5 -4
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/__main__.py +24 -32
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/add.py +89 -87
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_common.py +14 -15
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/container.py +42 -54
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/deployment.py +34 -32
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/image.py +19 -22
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +18 -18
- zrb/builtin/generator/app_generator/template/http-port/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_checker.py +10 -10
- zrb/builtin/generator/app_generator/template/http-port-build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +19 -19
- zrb/builtin/generator/app_generator/template/use-helm/_automate/generate_snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/__main__.py +12 -14
- zrb/builtin/generator/cmd_task/add.py +23 -25
- zrb/builtin/generator/cmd_task/template/_automate/snake_zrb_task_name.py +3 -5
- zrb/builtin/generator/common/helper.py +15 -20
- zrb/builtin/generator/common/task_factory.py +29 -26
- zrb/builtin/generator/common/task_input.py +97 -91
- zrb/builtin/generator/docker_compose_task/add.py +38 -39
- zrb/builtin/generator/docker_compose_task/template/_automate/snake_zrb_task_name.py +13 -19
- zrb/builtin/generator/docker_compose_task/template/src/kebab-zrb-task-name/image/main.py +18 -14
- zrb/builtin/generator/fastapp/add.py +94 -90
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_checker.py +28 -27
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_config.py +68 -39
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_env.py +24 -22
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_env_file.py +12 -12
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_get_start_microservices.py +43 -41
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_helper.py +23 -24
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_input.py +21 -20
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-load-test.sh +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-start.sh +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-test.sh +2 -2
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/container.py +46 -39
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/deployment.py +28 -20
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/frontend.py +21 -27
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/image.py +23 -18
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/load_test.py +35 -36
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/local.py +68 -58
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/test.py +24 -38
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/__main__.py +23 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/_common.py +72 -75
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/app_helper.py +70 -75
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_postgresql_helper.py +18 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_rabbitmq_helper.py +11 -19
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_redpanda_helper.py +18 -15
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_signoz_helper.py +17 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/docker-compose.yml +12 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/loadtest/locustfile.py +10 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/Dockerfile +1 -0
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/app.py +35 -30
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/app_lifespan.py +21 -17
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/app_state.py +3 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/db_connection.py +18 -20
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/frontend_index.py +5 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/log.py +7 -15
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/messagebus.py +38 -34
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/rpc.py +19 -18
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/config.py +68 -103
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/error.py +11 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/__init__.py +2 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/kafka/admin.py +38 -35
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/kafka/consumer.py +38 -45
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/kafka/publisher.py +26 -29
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/messagebus.py +8 -14
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/mock.py +12 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/rabbitmq/admin.py +37 -44
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/rabbitmq/consumer.py +42 -67
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/rabbitmq/publisher.py +32 -55
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/model/repo_model.py +11 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/__init__.py +2 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/db_entity_mixin.py +3 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/db_repo.py +76 -83
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/repo.py +5 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/search_filter.py +1 -0
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/__init__.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/messagebus/caller.py +17 -19
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/messagebus/server.py +14 -18
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/rpc.py +15 -28
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/schema/__init__.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/schema/base_schema.py +6 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/serializer/__init__.py +1 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/serializer/serializer.py +3 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/helper/async_task.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/helper/conversion.py +10 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/helper/migration.py +6 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/migrate.py +3 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/api.py +7 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/__init__.py +4 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/access_token_scheme.py +9 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/access_token_util.py +6 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/authorizer.py +4 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/bearer_token_scheme.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/model/user_model.py +8 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/password_hasher.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/refresh_token_util.py +7 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/repo/group_repo.py +3 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/repo/permission_repo.py +3 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/repo/user_repo.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/user.py +12 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/__init__.py +7 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/access_token/scheme.py +7 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/access_token/util.py +20 -30
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/authorizer/authorizer.py +1 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/authorizer/rpc_authorizer.py +5 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/password_hasher/bcrypt_password_hasher.py +3 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/password_hasher/password_hasher.py +0 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/refresh_token/util.py +15 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/api.py +42 -49
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/model.py +3 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/repo.py +18 -16
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/rpc.py +26 -41
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/api.py +46 -51
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/model.py +5 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/repo.py +11 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/rpc.py +28 -45
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/table.py +10 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/api.py +60 -72
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/model.py +32 -61
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/repo.py +33 -36
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/rpc.py +42 -61
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/event.py +2 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/migrate.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/register_module.py +11 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/register_permission.py +19 -26
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/rpc.py +5 -13
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/group.py +6 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/permission.py +3 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/request.py +1 -0
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/token.py +2 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/user.py +4 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/api.py +4 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/component/model/activity_model.py +3 -9
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/component/repo/activity_repo.py +3 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/core/historical_repo_model.py +13 -13
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/api.py +22 -23
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/event.py +5 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/model.py +2 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/repo.py +8 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/rpc.py +28 -45
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/table.py +3 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/event.py +4 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/migrate.py +2 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/register_module.py +10 -11
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/rpc.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/schema/activity.py +3 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/requirements.txt +12 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py +76 -106
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_permission_crud.py +73 -103
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py +92 -122
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_user_login.py +107 -134
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/conftest.py +2 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/test_liveness_and_readiness.py +8 -15
- zrb/builtin/generator/fastapp_crud/add.py +74 -79
- zrb/builtin/generator/fastapp_crud/helper.py +51 -48
- zrb/builtin/generator/fastapp_crud/task_factory.py +17 -14
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/component/model/snake_zrb_entity_name_model.py +2 -2
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/component/repo/snake_zrb_entity_name_repo.py +3 -2
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/api.py +58 -40
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/model.py +7 -3
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/repo.py +9 -4
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/rpc.py +32 -39
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/schema/snake_zrb_entity_name.py +3 -1
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/test/snake_zrb_module_name/test_snake_zrb_entity_name.py +68 -98
- zrb/builtin/generator/fastapp_field/add.py +143 -85
- zrb/builtin/generator/fastapp_field/helper.py +184 -125
- zrb/builtin/generator/fastapp_module/add.py +90 -67
- zrb/builtin/generator/fastapp_module/helper.py +141 -155
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/api.py +3 -2
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/table.py +3 -3
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/event.py +3 -5
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/migrate.py +2 -4
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/register_module.py +10 -11
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/rpc.py +3 -5
- zrb/builtin/generator/pip_package/add.py +39 -40
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/local.py +30 -30
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/__init__.py +1 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/__main__.py +1 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/util.py +2 -2
- zrb/builtin/generator/plugin/create.py +39 -36
- zrb/builtin/generator/plugin/template/src/snake_zrb_package_name/__init__.py +1 -1
- zrb/builtin/generator/plugin/template/src/snake_zrb_package_name/__main__.py +1 -0
- zrb/builtin/generator/plugin/template/src/snake_zrb_package_name/task/example_task.py +6 -4
- zrb/builtin/generator/plugin/template/zrb_init.py +27 -27
- zrb/builtin/generator/project/create.py +38 -46
- zrb/builtin/generator/project/template/.flake8 +3 -0
- zrb/builtin/generator/project/template/project.sh +19 -10
- zrb/builtin/generator/project_task/task_factory.py +60 -61
- zrb/builtin/generator/project_task/template/_automate/_project/__init__.py +2 -2
- zrb/builtin/generator/project_task/template/_automate/_project/build_project_images.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/deploy_project.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/destroy_project.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/push_project_images.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/remove_project_containers.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/start_project.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/start_project_containers.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/stop_project_containers.py +4 -4
- zrb/builtin/generator/python_task/add.py +25 -33
- zrb/builtin/generator/python_task/template/_automate/snake_zrb_task_name.py +8 -7
- zrb/builtin/generator/simple_python_app/add.py +81 -75
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/_common.py +14 -15
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/container.py +46 -61
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/deployment.py +34 -32
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/image.py +19 -22
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/local.py +23 -25
- zrb/builtin/generator/simple_python_app/template/src/kebab-zrb-app-name/deployment/__main__.py +24 -32
- zrb/builtin/generator/simple_python_app/template/src/kebab-zrb-app-name/src/main.py +18 -14
- zrb/builtin/git.py +46 -46
- zrb/builtin/group.py +13 -34
- zrb/builtin/helper/reccuring_action.py +26 -29
- zrb/builtin/md5.py +17 -30
- zrb/builtin/process.py +19 -19
- zrb/builtin/project.py +13 -15
- zrb/builtin/say.py +69 -88
- zrb/builtin/schedule.py +15 -19
- zrb/builtin/ubuntu.py +44 -35
- zrb/builtin/update.py +5 -5
- zrb/builtin/version.py +3 -7
- zrb/builtin/watch_changes.py +24 -25
- zrb/config/config.py +19 -18
- zrb/helper/accessories/color.py +18 -6
- zrb/helper/accessories/icon.py +24 -3
- zrb/helper/accessories/name.py +120 -28
- zrb/helper/advertisement.py +9 -13
- zrb/helper/callable.py +2 -4
- zrb/helper/cli.py +27 -31
- zrb/helper/codemod/add_argument_to_function.py +3 -4
- zrb/helper/codemod/add_argument_to_function_call.py +4 -7
- zrb/helper/codemod/add_assert_resource.py +7 -7
- zrb/helper/codemod/add_function_call.py +3 -5
- zrb/helper/codemod/add_import_module.py +15 -26
- zrb/helper/codemod/add_key_value_to_dict.py +7 -10
- zrb/helper/codemod/add_property_to_class.py +10 -8
- zrb/helper/codemod/add_upstream_to_task.py +21 -33
- zrb/helper/codemod/append_code_to_function.py +6 -13
- zrb/helper/codemod/format_code.py +2 -1
- zrb/helper/default_env.py +25 -25
- zrb/helper/docker_compose/fetch_external_env.py +18 -18
- zrb/helper/docker_compose/file.py +5 -4
- zrb/helper/docstring.py +44 -47
- zrb/helper/env_map/fetch.py +7 -12
- zrb/helper/file/copy_tree.py +12 -17
- zrb/helper/file/match.py +6 -7
- zrb/helper/file/text.py +8 -6
- zrb/helper/git/detect_changes.py +9 -8
- zrb/helper/loader/load_module.py +14 -13
- zrb/helper/log.py +4 -3
- zrb/helper/map/conversion.py +4 -5
- zrb/helper/python_task.py +2 -4
- zrb/helper/render_data.py +25 -18
- zrb/helper/string/constant.py +2 -2
- zrb/helper/string/conversion.py +17 -16
- zrb/helper/string/jinja.py +2 -2
- zrb/helper/typecheck.py +6 -4
- zrb/helper/typing.py +10 -2
- zrb/helper/util.py +44 -40
- zrb/task/any_task.py +251 -251
- zrb/task/base_remote_cmd_task.py +76 -59
- zrb/task/base_task/base_task.py +95 -108
- zrb/task/base_task/component/base_task_model.py +73 -71
- zrb/task/base_task/component/common_task_model.py +42 -29
- zrb/task/base_task/component/pid_model.py +3 -5
- zrb/task/base_task/component/renderer.py +26 -36
- zrb/task/base_task/component/trackers.py +6 -9
- zrb/task/checker.py +14 -9
- zrb/task/cmd_task.py +102 -100
- zrb/task/decorator.py +19 -13
- zrb/task/docker_compose_task.py +127 -98
- zrb/task/flow_task.py +16 -19
- zrb/task/http_checker.py +40 -36
- zrb/task/notifier.py +50 -38
- zrb/task/parallel.py +3 -3
- zrb/task/path_checker.py +34 -27
- zrb/task/path_watcher.py +49 -40
- zrb/task/port_checker.py +33 -26
- zrb/task/recurring_task.py +36 -42
- zrb/task/remote_cmd_task.py +31 -28
- zrb/task/resource_maker.py +66 -52
- zrb/task/rsync_task.py +24 -21
- zrb/task/task.py +4 -3
- zrb/task/time_watcher.py +36 -31
- zrb/task_env/constant.py +1 -1
- zrb/task_env/env.py +33 -31
- zrb/task_env/env_file.py +24 -23
- zrb/task_group/group.py +27 -30
- zrb/task_input/any_input.py +18 -16
- zrb/task_input/base_input.py +26 -26
- zrb/task_input/bool_input.py +6 -6
- zrb/task_input/choice_input.py +11 -9
- zrb/task_input/constant.py +1 -1
- zrb/task_input/float_input.py +6 -5
- zrb/task_input/int_input.py +8 -8
- zrb/task_input/password_input.py +9 -9
- zrb/task_input/str_input.py +8 -8
- zrb/task_input/task_input.py +4 -2
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/METADATA +3 -1
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/RECORD +316 -315
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/LICENSE +0 -0
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/WHEEL +0 -0
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/entry_points.txt +0 -0
zrb/task/recurring_task.py
CHANGED
@@ -1,29 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
from zrb.helper.typecheck import typechecked
|
1
|
+
import asyncio
|
2
|
+
import copy
|
3
|
+
|
5
4
|
from zrb.helper.accessories.name import get_random_name
|
6
|
-
from zrb.
|
5
|
+
from zrb.helper.typecheck import typechecked
|
6
|
+
from zrb.helper.typing import Any, Callable, Iterable, List, Mapping, Optional, Union
|
7
7
|
from zrb.task.any_task import AnyTask
|
8
8
|
from zrb.task.any_task_event_handler import (
|
9
|
-
|
9
|
+
OnFailed,
|
10
|
+
OnReady,
|
11
|
+
OnRetry,
|
12
|
+
OnSkipped,
|
13
|
+
OnStarted,
|
14
|
+
OnTriggered,
|
15
|
+
OnWaiting,
|
10
16
|
)
|
17
|
+
from zrb.task.base_task.base_task import BaseTask
|
11
18
|
from zrb.task_env.env import Env
|
12
19
|
from zrb.task_env.env_file import EnvFile
|
13
20
|
from zrb.task_group.group import Group
|
14
21
|
from zrb.task_input.any_input import AnyInput
|
15
22
|
|
16
|
-
import asyncio
|
17
|
-
import copy
|
18
|
-
|
19
23
|
|
20
|
-
class RunConfig
|
24
|
+
class RunConfig:
|
21
25
|
def __init__(
|
22
26
|
self,
|
23
27
|
fn: Callable[..., Any],
|
24
28
|
args: List[Any],
|
25
29
|
kwargs: Mapping[Any, Any],
|
26
|
-
execution_id: str
|
30
|
+
execution_id: str,
|
27
31
|
):
|
28
32
|
self.fn = fn
|
29
33
|
self.args = args
|
@@ -36,14 +40,14 @@ class RunConfig():
|
|
36
40
|
|
37
41
|
@typechecked
|
38
42
|
class RecurringTask(BaseTask):
|
39
|
-
|
43
|
+
"""
|
40
44
|
A class representing a recurring task that is triggered based on
|
41
45
|
specified conditions.
|
42
46
|
|
43
47
|
Examples:
|
44
48
|
|
45
49
|
>>> from zrb import RecurringTask
|
46
|
-
|
50
|
+
"""
|
47
51
|
|
48
52
|
def __init__(
|
49
53
|
self,
|
@@ -57,7 +61,7 @@ class RecurringTask(BaseTask):
|
|
57
61
|
env_files: Iterable[EnvFile] = [],
|
58
62
|
icon: Optional[str] = None,
|
59
63
|
color: Optional[str] = None,
|
60
|
-
description: str =
|
64
|
+
description: str = "",
|
61
65
|
upstreams: Iterable[AnyTask] = [],
|
62
66
|
on_triggered: Optional[OnTriggered] = None,
|
63
67
|
on_waiting: Optional[OnWaiting] = None,
|
@@ -71,7 +75,7 @@ class RecurringTask(BaseTask):
|
|
71
75
|
retry: int = 0,
|
72
76
|
retry_interval: float = 1,
|
73
77
|
should_execute: Union[bool, str, Callable[..., bool]] = True,
|
74
|
-
return_upstream_result: bool = False
|
78
|
+
return_upstream_result: bool = False,
|
75
79
|
):
|
76
80
|
self._task: AnyTask = task.copy()
|
77
81
|
inputs = list(inputs) + self._task._get_combined_inputs()
|
@@ -102,9 +106,7 @@ class RecurringTask(BaseTask):
|
|
102
106
|
should_execute=should_execute,
|
103
107
|
return_upstream_result=return_upstream_result,
|
104
108
|
)
|
105
|
-
self._triggers: List[AnyTask] = [
|
106
|
-
trigger.copy() for trigger in triggers
|
107
|
-
]
|
109
|
+
self._triggers: List[AnyTask] = [trigger.copy() for trigger in triggers]
|
108
110
|
self._run_configs: List[RunConfig] = []
|
109
111
|
self._single_execution = single_execution
|
110
112
|
|
@@ -116,29 +118,24 @@ class RecurringTask(BaseTask):
|
|
116
118
|
for trigger in self._triggers:
|
117
119
|
trigger.add_input(*self._get_inputs())
|
118
120
|
trigger.add_env(*self._get_envs())
|
119
|
-
trigger_coroutines.append(
|
120
|
-
|
121
|
-
kwargs=new_kwargs, env_prefix=env_prefix
|
121
|
+
trigger_coroutines.append(
|
122
|
+
asyncio.create_task(
|
123
|
+
trigger._set_keyval(kwargs=new_kwargs, env_prefix=env_prefix)
|
122
124
|
)
|
123
|
-
)
|
125
|
+
)
|
124
126
|
await asyncio.gather(*trigger_coroutines)
|
125
127
|
|
126
128
|
async def run(self, *args: Any, **kwargs: Any):
|
127
129
|
await asyncio.gather(
|
128
130
|
asyncio.create_task(self.__check_trigger(*args, **kwargs)),
|
129
|
-
asyncio.create_task(self.__run_from_queue())
|
131
|
+
asyncio.create_task(self.__run_from_queue()),
|
130
132
|
)
|
131
133
|
|
132
134
|
async def __check_trigger(self, *args: Any, **kwargs: Any):
|
133
|
-
task_kwargs = {
|
134
|
-
key: kwargs[key]
|
135
|
-
for key in kwargs if key not in ['_task']
|
136
|
-
}
|
135
|
+
task_kwargs = {key: kwargs[key] for key in kwargs if key not in ["_task"]}
|
137
136
|
is_first_time = True
|
138
137
|
while True:
|
139
|
-
execution_id = get_random_name(
|
140
|
-
add_random_digit=True, digit_count=5
|
141
|
-
)
|
138
|
+
execution_id = get_random_name(add_random_digit=True, digit_count=5)
|
142
139
|
# Create trigger functions
|
143
140
|
trigger_functions = []
|
144
141
|
for trigger in self._triggers:
|
@@ -147,10 +144,10 @@ class RecurringTask(BaseTask):
|
|
147
144
|
trigger_function = trigger_copy.to_function(
|
148
145
|
is_async=True, raise_error=False, show_done_info=False
|
149
146
|
)
|
150
|
-
trigger_functions.append(
|
151
|
-
trigger_function(*args, **task_kwargs)
|
152
|
-
)
|
153
|
-
self.print_out_dark(
|
147
|
+
trigger_functions.append(
|
148
|
+
asyncio.create_task(trigger_function(*args, **task_kwargs))
|
149
|
+
)
|
150
|
+
self.print_out_dark("Waiting for next trigger")
|
154
151
|
# Mark task as done since trigger has been defined.
|
155
152
|
if is_first_time:
|
156
153
|
await self._mark_done()
|
@@ -171,13 +168,10 @@ class RecurringTask(BaseTask):
|
|
171
168
|
fn = task_copy.to_function(
|
172
169
|
is_async=True, raise_error=False, show_done_info=False
|
173
170
|
)
|
174
|
-
self.print_out_dark(f
|
171
|
+
self.print_out_dark(f"Add execution to the queue: {execution_id}")
|
175
172
|
self._run_configs.append(
|
176
173
|
RunConfig(
|
177
|
-
fn=fn,
|
178
|
-
args=args,
|
179
|
-
kwargs=task_kwargs,
|
180
|
-
execution_id=execution_id
|
174
|
+
fn=fn, args=args, kwargs=task_kwargs, execution_id=execution_id
|
181
175
|
)
|
182
176
|
)
|
183
177
|
|
@@ -190,12 +184,12 @@ class RecurringTask(BaseTask):
|
|
190
184
|
# Drain the queue, leave only the latest task
|
191
185
|
while len(self._run_configs) > 1:
|
192
186
|
run_config = self._run_configs.pop(0)
|
193
|
-
self.print_out_dark(f
|
187
|
+
self.print_out_dark(f"Skipping {run_config.execution_id}")
|
194
188
|
self.clear_xcom(execution_id=run_config.execution_id)
|
195
189
|
# Run task
|
196
190
|
run_config = self._run_configs.pop(0)
|
197
|
-
self.print_out_dark(f
|
198
|
-
self.print_out_dark(f
|
191
|
+
self.print_out_dark(f"Executing {run_config.execution_id}")
|
192
|
+
self.print_out_dark(f"{len(self._run_configs)} tasks left")
|
199
193
|
await run_config.run()
|
200
194
|
self.clear_xcom(execution_id=run_config.execution_id)
|
201
195
|
self._play_bell()
|
zrb/task/remote_cmd_task.py
CHANGED
@@ -1,32 +1,37 @@
|
|
1
|
-
|
1
|
+
import os
|
2
|
+
import pathlib
|
3
|
+
|
2
4
|
from zrb.helper.typecheck import typechecked
|
5
|
+
from zrb.helper.typing import Any, Callable, Iterable, Optional, Union
|
3
6
|
from zrb.task.any_task import AnyTask
|
4
7
|
from zrb.task.any_task_event_handler import (
|
5
|
-
|
8
|
+
OnFailed,
|
9
|
+
OnReady,
|
10
|
+
OnRetry,
|
11
|
+
OnSkipped,
|
12
|
+
OnStarted,
|
13
|
+
OnTriggered,
|
14
|
+
OnWaiting,
|
6
15
|
)
|
16
|
+
from zrb.task.base_remote_cmd_task import BaseRemoteCmdTask, RemoteConfig
|
17
|
+
from zrb.task.cmd_task import CmdTask, CmdVal
|
7
18
|
from zrb.task_env.env import Env
|
8
19
|
from zrb.task_env.env_file import EnvFile
|
9
20
|
from zrb.task_group.group import Group
|
10
21
|
from zrb.task_input.any_input import AnyInput
|
11
|
-
from zrb.task.cmd_task import CmdVal, CmdTask
|
12
|
-
from zrb.task.base_remote_cmd_task import RemoteConfig, BaseRemoteCmdTask
|
13
|
-
|
14
|
-
import os
|
15
|
-
import pathlib
|
16
|
-
|
17
22
|
|
18
23
|
CURRENT_DIR = os.path.dirname(__file__)
|
19
|
-
SHELL_SCRIPT_DIR = os.path.join(CURRENT_DIR,
|
20
|
-
with open(os.path.join(SHELL_SCRIPT_DIR,
|
24
|
+
SHELL_SCRIPT_DIR = os.path.join(CURRENT_DIR, "..", "shell-scripts")
|
25
|
+
with open(os.path.join(SHELL_SCRIPT_DIR, "ssh-util.sh")) as file:
|
21
26
|
SSH_UTIL_SCRIPT = file.read()
|
22
27
|
|
23
28
|
ensure_ssh_is_installed = CmdTask(
|
24
|
-
name=
|
29
|
+
name="ensure-ssh-is-installed",
|
25
30
|
cmd_path=[
|
26
|
-
os.path.join(SHELL_SCRIPT_DIR,
|
27
|
-
os.path.join(SHELL_SCRIPT_DIR,
|
31
|
+
os.path.join(SHELL_SCRIPT_DIR, "_common-util.sh"),
|
32
|
+
os.path.join(SHELL_SCRIPT_DIR, "ensure-ssh-is-installed.sh"),
|
28
33
|
],
|
29
|
-
preexec_fn=None
|
34
|
+
preexec_fn=None,
|
30
35
|
)
|
31
36
|
|
32
37
|
|
@@ -42,10 +47,10 @@ class RemoteCmdTask(BaseRemoteCmdTask):
|
|
42
47
|
env_files: Iterable[EnvFile] = [],
|
43
48
|
icon: Optional[str] = None,
|
44
49
|
color: Optional[str] = None,
|
45
|
-
description: str =
|
50
|
+
description: str = "",
|
46
51
|
executable: Optional[str] = None,
|
47
|
-
cmd: CmdVal =
|
48
|
-
cmd_path: CmdVal =
|
52
|
+
cmd: CmdVal = "",
|
53
|
+
cmd_path: CmdVal = "",
|
49
54
|
cwd: Optional[Union[str, pathlib.Path]] = None,
|
50
55
|
upstreams: Iterable[AnyTask] = [],
|
51
56
|
on_triggered: Optional[OnTriggered] = None,
|
@@ -62,17 +67,15 @@ class RemoteCmdTask(BaseRemoteCmdTask):
|
|
62
67
|
max_output_line: int = 1000,
|
63
68
|
max_error_line: int = 1000,
|
64
69
|
preexec_fn: Optional[Callable[[], Any]] = os.setsid,
|
65
|
-
should_execute: Union[bool, str, Callable[..., bool]] = True
|
70
|
+
should_execute: Union[bool, str, Callable[..., bool]] = True,
|
66
71
|
):
|
67
|
-
pre_cmd =
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
'auth_ssh "$_SCRIPT"'
|
75
|
-
])
|
72
|
+
pre_cmd = "\n".join(
|
73
|
+
[
|
74
|
+
SSH_UTIL_SCRIPT,
|
75
|
+
"_SCRIPT=\"$(cat <<'ENDSCRIPT'",
|
76
|
+
]
|
77
|
+
)
|
78
|
+
post_cmd = "\n".join(["ENDSCRIPT", ')"', 'auth_ssh "$_SCRIPT"'])
|
76
79
|
BaseRemoteCmdTask.__init__(
|
77
80
|
self,
|
78
81
|
name=name,
|
@@ -105,5 +108,5 @@ class RemoteCmdTask(BaseRemoteCmdTask):
|
|
105
108
|
max_output_line=max_output_line,
|
106
109
|
max_error_line=max_error_line,
|
107
110
|
preexec_fn=preexec_fn,
|
108
|
-
should_execute=should_execute
|
111
|
+
should_execute=should_execute,
|
109
112
|
)
|
zrb/task/resource_maker.py
CHANGED
@@ -1,33 +1,46 @@
|
|
1
|
+
from zrb.helper.file.copy_tree import copy_tree
|
2
|
+
from zrb.helper.typecheck import typechecked
|
1
3
|
from zrb.helper.typing import (
|
2
|
-
Any,
|
4
|
+
Any,
|
5
|
+
Callable,
|
6
|
+
Iterable,
|
7
|
+
JinjaTemplate,
|
8
|
+
Mapping,
|
9
|
+
Optional,
|
10
|
+
TypeVar,
|
11
|
+
Union,
|
12
|
+
)
|
13
|
+
from zrb.helper.util import (
|
14
|
+
to_camel_case,
|
15
|
+
to_capitalized_human_readable,
|
16
|
+
to_human_readable,
|
17
|
+
to_kebab_case,
|
18
|
+
to_pascal_case,
|
19
|
+
to_snake_case,
|
3
20
|
)
|
4
|
-
from zrb.helper.typecheck import typechecked
|
5
|
-
from zrb.task.base_task.base_task import BaseTask
|
6
21
|
from zrb.task.any_task import AnyTask
|
7
22
|
from zrb.task.any_task_event_handler import (
|
8
|
-
|
23
|
+
OnFailed,
|
24
|
+
OnReady,
|
25
|
+
OnRetry,
|
26
|
+
OnSkipped,
|
27
|
+
OnStarted,
|
28
|
+
OnTriggered,
|
29
|
+
OnWaiting,
|
9
30
|
)
|
31
|
+
from zrb.task.base_task.base_task import BaseTask
|
10
32
|
from zrb.task_env.env import Env
|
11
33
|
from zrb.task_env.env_file import EnvFile
|
12
34
|
from zrb.task_group.group import Group
|
13
35
|
from zrb.task_input.any_input import AnyInput
|
14
|
-
from zrb.helper.file.copy_tree import copy_tree
|
15
|
-
from zrb.helper.util import (
|
16
|
-
to_camel_case, to_pascal_case, to_kebab_case, to_snake_case,
|
17
|
-
to_human_readable, to_capitalized_human_readable
|
18
|
-
)
|
19
36
|
|
20
37
|
Replacement = Mapping[str, JinjaTemplate]
|
21
|
-
ReplacementMutator = Callable[
|
22
|
-
|
23
|
-
Replacement
|
24
|
-
]
|
25
|
-
TResourceMaker = TypeVar('TResourceMaker', bound='ResourceMaker')
|
38
|
+
ReplacementMutator = Callable[[AnyTask, Replacement], Replacement]
|
39
|
+
TResourceMaker = TypeVar("TResourceMaker", bound="ResourceMaker")
|
26
40
|
|
27
41
|
|
28
42
|
@typechecked
|
29
43
|
class ResourceMaker(BaseTask):
|
30
|
-
|
31
44
|
def __init__(
|
32
45
|
self,
|
33
46
|
name: str,
|
@@ -42,7 +55,7 @@ class ResourceMaker(BaseTask):
|
|
42
55
|
env_files: Iterable[EnvFile] = [],
|
43
56
|
icon: Optional[str] = None,
|
44
57
|
color: Optional[str] = None,
|
45
|
-
description: str =
|
58
|
+
description: str = "",
|
46
59
|
upstreams: Iterable[AnyTask] = [],
|
47
60
|
on_triggered: Optional[OnTriggered] = None,
|
48
61
|
on_waiting: Optional[OnWaiting] = None,
|
@@ -52,7 +65,7 @@ class ResourceMaker(BaseTask):
|
|
52
65
|
on_retry: Optional[OnRetry] = None,
|
53
66
|
on_failed: Optional[OnFailed] = None,
|
54
67
|
should_execute: Union[bool, JinjaTemplate, Callable[..., bool]] = True,
|
55
|
-
skip_parsing: Optional[Iterable[str]] = None
|
68
|
+
skip_parsing: Optional[Iterable[str]] = None,
|
56
69
|
):
|
57
70
|
BaseTask.__init__(
|
58
71
|
self,
|
@@ -76,7 +89,7 @@ class ResourceMaker(BaseTask):
|
|
76
89
|
checking_interval=0.1,
|
77
90
|
retry=0,
|
78
91
|
retry_interval=0,
|
79
|
-
should_execute=should_execute
|
92
|
+
should_execute=should_execute,
|
80
93
|
)
|
81
94
|
self._template_path = template_path
|
82
95
|
self._destination_path = destination_path
|
@@ -93,59 +106,60 @@ class ResourceMaker(BaseTask):
|
|
93
106
|
self._skip_parsing: Iterable[str] = skip_parsing
|
94
107
|
return
|
95
108
|
self._skip_parsing: Iterable[str] = [
|
96
|
-
|
97
|
-
|
109
|
+
"*.mp3",
|
110
|
+
"*.pdf",
|
111
|
+
"*.exe",
|
112
|
+
"*.dll",
|
113
|
+
"*.bin",
|
114
|
+
"*.iso",
|
115
|
+
"*.png",
|
116
|
+
"*.jpg",
|
117
|
+
"*.gif",
|
118
|
+
"*.ico",
|
98
119
|
]
|
99
120
|
|
100
121
|
def to_function(
|
101
122
|
self,
|
102
|
-
env_prefix: str =
|
123
|
+
env_prefix: str = "",
|
103
124
|
raise_error: bool = True,
|
104
125
|
is_async: bool = False,
|
105
|
-
show_done_info: bool = True
|
126
|
+
show_done_info: bool = True,
|
106
127
|
) -> Callable[..., bool]:
|
107
|
-
return super().to_function(
|
108
|
-
env_prefix, raise_error, is_async, show_done_info
|
109
|
-
)
|
128
|
+
return super().to_function(env_prefix, raise_error, is_async, show_done_info)
|
110
129
|
|
111
130
|
async def run(self, *args: Any, **kwargs: Any) -> bool:
|
112
131
|
# render parameters
|
113
132
|
template_path = self.render_str(self._template_path)
|
114
133
|
destination_path = self.render_str(self._destination_path)
|
115
134
|
# render excludes
|
116
|
-
self.log_debug(f
|
135
|
+
self.log_debug(f"Render excludes: {self._excludes}")
|
117
136
|
excludes = [self.render_str(exclude) for exclude in self._excludes]
|
118
|
-
self.log_debug(f
|
137
|
+
self.log_debug(f"Rendered excludes: {excludes}")
|
119
138
|
# render replacements
|
120
|
-
self.log_debug(f
|
139
|
+
self.log_debug(f"Render replacements: {self._replacements}")
|
121
140
|
rendered_replacements: Mapping[str, str] = {
|
122
|
-
old: self.render_str(new)
|
123
|
-
for old, new in self._replacements.items()
|
141
|
+
old: self.render_str(new) for old, new in self._replacements.items()
|
124
142
|
}
|
125
|
-
self.log_debug(f
|
143
|
+
self.log_debug(f"Rendered replacements: {rendered_replacements}")
|
126
144
|
if self._replacement_mutator is not None:
|
127
|
-
self.log_debug(
|
145
|
+
self.log_debug("Apply replacement mutator")
|
128
146
|
rendered_replacements = self._replacement_mutator(
|
129
147
|
self, rendered_replacements
|
130
148
|
)
|
131
|
-
self.log_debug(
|
132
|
-
|
133
|
-
)
|
134
|
-
|
135
|
-
|
136
|
-
)
|
137
|
-
self.
|
138
|
-
self.print_out_dark(f
|
139
|
-
self.print_out_dark(f'Destination: {destination_path}')
|
140
|
-
self.print_out_dark(f'Replacements: {rendered_replacements}')
|
141
|
-
self.print_out_dark(f'Excludes: {excludes}')
|
142
|
-
self.print_out_dark(f'Skip parsing: {self._skip_parsing}')
|
149
|
+
self.log_debug(f"Apply default replacement mutator: {rendered_replacements}")
|
150
|
+
rendered_replacements = self._default_mutate_replacements(rendered_replacements)
|
151
|
+
self.log_debug(f"Final replacement: {rendered_replacements}")
|
152
|
+
self.print_out_dark(f"Template: {template_path}")
|
153
|
+
self.print_out_dark(f"Destination: {destination_path}")
|
154
|
+
self.print_out_dark(f"Replacements: {rendered_replacements}")
|
155
|
+
self.print_out_dark(f"Excludes: {excludes}")
|
156
|
+
self.print_out_dark(f"Skip parsing: {self._skip_parsing}")
|
143
157
|
await copy_tree(
|
144
158
|
src=template_path,
|
145
159
|
dst=destination_path,
|
146
160
|
replacements=rendered_replacements,
|
147
161
|
excludes=excludes,
|
148
|
-
skip_parsing=self._skip_parsing
|
162
|
+
skip_parsing=self._skip_parsing,
|
149
163
|
)
|
150
164
|
return True
|
151
165
|
|
@@ -153,18 +167,18 @@ class ResourceMaker(BaseTask):
|
|
153
167
|
self, rendered_replacements: Mapping[str, str]
|
154
168
|
) -> Mapping[str, str]:
|
155
169
|
transformations: Mapping[str, Callable[[str], str]] = {
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
170
|
+
"Pascal": to_pascal_case,
|
171
|
+
"kebab": to_kebab_case,
|
172
|
+
"camel": to_camel_case,
|
173
|
+
"snake": to_snake_case,
|
174
|
+
"human readable": to_human_readable,
|
175
|
+
"Human readable": to_capitalized_human_readable,
|
162
176
|
}
|
163
177
|
keys = list(rendered_replacements.keys())
|
164
178
|
for key in keys:
|
165
179
|
value = rendered_replacements[key]
|
166
180
|
for prefix, transform in transformations.items():
|
167
|
-
prefixed_key = transform(prefix +
|
181
|
+
prefixed_key = transform(prefix + " " + key)
|
168
182
|
if prefixed_key in rendered_replacements:
|
169
183
|
continue
|
170
184
|
transformed_value = transform(value)
|
zrb/task/rsync_task.py
CHANGED
@@ -1,35 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
import os
|
2
|
+
import pathlib
|
3
|
+
|
4
4
|
from zrb.helper.typecheck import typechecked
|
5
|
+
from zrb.helper.typing import Any, Callable, Iterable, JinjaTemplate, Optional, Union
|
5
6
|
from zrb.task.any_task import AnyTask
|
6
7
|
from zrb.task.any_task_event_handler import (
|
7
|
-
|
8
|
+
OnFailed,
|
9
|
+
OnReady,
|
10
|
+
OnRetry,
|
11
|
+
OnSkipped,
|
12
|
+
OnStarted,
|
13
|
+
OnTriggered,
|
14
|
+
OnWaiting,
|
8
15
|
)
|
16
|
+
from zrb.task.base_remote_cmd_task import BaseRemoteCmdTask, RemoteConfig
|
17
|
+
from zrb.task.cmd_task import CmdTask
|
9
18
|
from zrb.task_env.env import Env
|
10
19
|
from zrb.task_env.env_file import EnvFile
|
11
20
|
from zrb.task_group.group import Group
|
12
21
|
from zrb.task_input.any_input import AnyInput
|
13
|
-
from zrb.task.cmd_task import CmdTask
|
14
|
-
from zrb.task.base_remote_cmd_task import RemoteConfig, BaseRemoteCmdTask
|
15
|
-
|
16
|
-
import os
|
17
|
-
import pathlib
|
18
|
-
|
19
22
|
|
20
23
|
CURRENT_DIR = os.path.dirname(__file__)
|
21
|
-
SHELL_SCRIPT_DIR = os.path.join(CURRENT_DIR,
|
22
|
-
with open(os.path.join(SHELL_SCRIPT_DIR,
|
24
|
+
SHELL_SCRIPT_DIR = os.path.join(CURRENT_DIR, "..", "shell-scripts")
|
25
|
+
with open(os.path.join(SHELL_SCRIPT_DIR, "rsync-util.sh")) as file:
|
23
26
|
RSYNC_UTIL_SCRIPT = file.read()
|
24
27
|
|
25
28
|
ensure_rsync_is_installed = CmdTask(
|
26
|
-
name=
|
29
|
+
name="ensure-ssh-is-installed",
|
27
30
|
cmd_path=[
|
28
|
-
os.path.join(SHELL_SCRIPT_DIR,
|
29
|
-
os.path.join(SHELL_SCRIPT_DIR,
|
30
|
-
os.path.join(SHELL_SCRIPT_DIR,
|
31
|
+
os.path.join(SHELL_SCRIPT_DIR, "_common-util.sh"),
|
32
|
+
os.path.join(SHELL_SCRIPT_DIR, "ensure-ssh-is-installed.sh"),
|
33
|
+
os.path.join(SHELL_SCRIPT_DIR, "ensure-rsync-is-installed.sh"),
|
31
34
|
],
|
32
|
-
preexec_fn=None
|
35
|
+
preexec_fn=None,
|
33
36
|
)
|
34
37
|
|
35
38
|
|
@@ -49,7 +52,7 @@ class RsyncTask(BaseRemoteCmdTask):
|
|
49
52
|
env_files: Iterable[EnvFile] = [],
|
50
53
|
icon: Optional[str] = None,
|
51
54
|
color: Optional[str] = None,
|
52
|
-
description: str =
|
55
|
+
description: str = "",
|
53
56
|
executable: Optional[str] = None,
|
54
57
|
cwd: Optional[Union[str, pathlib.Path]] = None,
|
55
58
|
upstreams: Iterable[AnyTask] = [],
|
@@ -67,7 +70,7 @@ class RsyncTask(BaseRemoteCmdTask):
|
|
67
70
|
max_output_line: int = 1000,
|
68
71
|
max_error_line: int = 1000,
|
69
72
|
preexec_fn: Optional[Callable[[], Any]] = os.setsid,
|
70
|
-
should_execute: Union[bool, str, Callable[..., bool]] = True
|
73
|
+
should_execute: Union[bool, str, Callable[..., bool]] = True,
|
71
74
|
):
|
72
75
|
parsed_src = self._get_parsed_path(is_remote_src, src)
|
73
76
|
parsed_dst = self._get_parsed_path(is_remote_dst, dst)
|
@@ -102,10 +105,10 @@ class RsyncTask(BaseRemoteCmdTask):
|
|
102
105
|
max_output_line=max_output_line,
|
103
106
|
max_error_line=max_error_line,
|
104
107
|
preexec_fn=preexec_fn,
|
105
|
-
should_execute=should_execute
|
108
|
+
should_execute=should_execute,
|
106
109
|
)
|
107
110
|
|
108
111
|
def _get_parsed_path(self, is_remote: bool, path: str) -> str:
|
109
112
|
if not is_remote:
|
110
113
|
return path
|
111
|
-
return
|
114
|
+
return "${_CONFIG_USER}@${_CONFIG_HOST}:" + path
|
zrb/task/task.py
CHANGED