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/time_watcher.py
CHANGED
@@ -1,42 +1,55 @@
|
|
1
|
+
import datetime
|
2
|
+
|
3
|
+
import croniter
|
4
|
+
|
5
|
+
from zrb.helper.typecheck import typechecked
|
1
6
|
from zrb.helper.typing import (
|
2
|
-
Any,
|
7
|
+
Any,
|
8
|
+
Callable,
|
9
|
+
Iterable,
|
10
|
+
JinjaTemplate,
|
11
|
+
Optional,
|
12
|
+
TypeVar,
|
13
|
+
Union,
|
3
14
|
)
|
4
|
-
from zrb.helper.typecheck import typechecked
|
5
|
-
from zrb.task.checker import Checker
|
6
15
|
from zrb.task.any_task import AnyTask
|
7
16
|
from zrb.task.any_task_event_handler import (
|
8
|
-
|
17
|
+
OnFailed,
|
18
|
+
OnReady,
|
19
|
+
OnRetry,
|
20
|
+
OnSkipped,
|
21
|
+
OnStarted,
|
22
|
+
OnTriggered,
|
23
|
+
OnWaiting,
|
9
24
|
)
|
25
|
+
from zrb.task.checker import Checker
|
10
26
|
from zrb.task_env.env import Env
|
11
27
|
from zrb.task_env.env_file import EnvFile
|
12
28
|
from zrb.task_group.group import Group
|
13
29
|
from zrb.task_input.any_input import AnyInput
|
14
30
|
|
15
|
-
|
16
|
-
import datetime
|
17
|
-
|
18
|
-
TTimeWatcher = TypeVar('TTimeWatcher', bound='TimeWatcher')
|
31
|
+
TTimeWatcher = TypeVar("TTimeWatcher", bound="TimeWatcher")
|
19
32
|
|
20
33
|
|
21
34
|
@typechecked
|
22
35
|
class TimeWatcher(Checker):
|
23
|
-
|
36
|
+
"""
|
24
37
|
TimeWatcher will wait for any changes specified on path.
|
25
38
|
|
26
39
|
Once the changes detected, TimeWatcher will be completed
|
27
40
|
and <task-name>.scheduled-time xcom will be set.
|
28
|
-
|
41
|
+
"""
|
29
42
|
|
30
43
|
def __init__(
|
31
44
|
self,
|
32
|
-
name: str =
|
45
|
+
name: str = "watch-path",
|
33
46
|
group: Optional[Group] = None,
|
34
47
|
inputs: Iterable[AnyInput] = [],
|
35
48
|
envs: Iterable[Env] = [],
|
36
49
|
env_files: Iterable[EnvFile] = [],
|
37
50
|
icon: Optional[str] = None,
|
38
51
|
color: Optional[str] = None,
|
39
|
-
description: str =
|
52
|
+
description: str = "",
|
40
53
|
upstreams: Iterable[AnyTask] = [],
|
41
54
|
on_triggered: Optional[OnTriggered] = None,
|
42
55
|
on_waiting: Optional[OnWaiting] = None,
|
@@ -45,10 +58,10 @@ class TimeWatcher(Checker):
|
|
45
58
|
on_ready: Optional[OnReady] = None,
|
46
59
|
on_retry: Optional[OnRetry] = None,
|
47
60
|
on_failed: Optional[OnFailed] = None,
|
48
|
-
schedule: JinjaTemplate =
|
61
|
+
schedule: JinjaTemplate = "",
|
49
62
|
checking_interval: Union[int, float] = 1,
|
50
63
|
progress_interval: Union[int, float] = 30,
|
51
|
-
should_execute: Union[bool, JinjaTemplate, Callable[..., bool]] = True
|
64
|
+
should_execute: Union[bool, JinjaTemplate, Callable[..., bool]] = True,
|
52
65
|
):
|
53
66
|
Checker.__init__(
|
54
67
|
self,
|
@@ -74,42 +87,34 @@ class TimeWatcher(Checker):
|
|
74
87
|
)
|
75
88
|
self._schedule = schedule
|
76
89
|
self._scheduled_time: Optional[datetime.datetime] = None
|
77
|
-
self._rendered_schedule: str =
|
90
|
+
self._rendered_schedule: str = ""
|
78
91
|
|
79
92
|
def copy(self) -> TTimeWatcher:
|
80
93
|
return super().copy()
|
81
94
|
|
82
95
|
def to_function(
|
83
96
|
self,
|
84
|
-
env_prefix: str =
|
97
|
+
env_prefix: str = "",
|
85
98
|
raise_error: bool = True,
|
86
99
|
is_async: bool = False,
|
87
|
-
show_done_info: bool = True
|
100
|
+
show_done_info: bool = True,
|
88
101
|
) -> Callable[..., bool]:
|
89
|
-
return super().to_function(
|
90
|
-
env_prefix, raise_error, is_async, show_done_info
|
91
|
-
)
|
102
|
+
return super().to_function(env_prefix, raise_error, is_async, show_done_info)
|
92
103
|
|
93
104
|
async def run(self, *args: Any, **kwargs: Any) -> bool:
|
94
105
|
self._rendered_schedule = self.render_str(self._schedule)
|
95
106
|
margin = datetime.timedelta(seconds=0.001)
|
96
107
|
slightly_before_check_time = datetime.datetime.now() - margin
|
97
|
-
cron = croniter.croniter(
|
98
|
-
self._rendered_schedule, slightly_before_check_time
|
99
|
-
)
|
108
|
+
cron = croniter.croniter(self._rendered_schedule, slightly_before_check_time)
|
100
109
|
self._scheduled_time = cron.get_next(datetime.datetime)
|
101
|
-
self.set_task_xcom(key=
|
110
|
+
self.set_task_xcom(key="scheduled-time", value=self._scheduled_time)
|
102
111
|
return await super().run(*args, **kwargs)
|
103
112
|
|
104
113
|
async def inspect(self, *args: Any, **kwargs: Any) -> bool:
|
105
|
-
label = f
|
114
|
+
label = f"Watching {self._rendered_schedule}"
|
106
115
|
now = datetime.datetime.now()
|
107
116
|
if now > self._scheduled_time:
|
108
|
-
self.print_out_dark(
|
109
|
-
f'{label} (Meet {self._scheduled_time})'
|
110
|
-
)
|
117
|
+
self.print_out_dark(f"{label} (Meet {self._scheduled_time})")
|
111
118
|
return True
|
112
|
-
self.show_progress(
|
113
|
-
f'{label} (Waiting for {self._scheduled_time})'
|
114
|
-
)
|
119
|
+
self.show_progress(f"{label} (Waiting for {self._scheduled_time})")
|
115
120
|
return False
|
zrb/task_env/constant.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
RESERVED_ENV_NAMES = (
|
1
|
+
RESERVED_ENV_NAMES = ("_ZRB_EXECUTION_ID",)
|
zrb/task_env/env.py
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
|
1
|
+
import os
|
2
|
+
|
3
|
+
from zrb.helper.string.modification import double_quote
|
2
4
|
from zrb.helper.typecheck import typechecked
|
5
|
+
from zrb.helper.typing import JinjaTemplate, Optional
|
3
6
|
from zrb.task_env.constant import RESERVED_ENV_NAMES
|
4
|
-
from zrb.helper.string.modification import double_quote
|
5
|
-
import os
|
6
7
|
|
7
8
|
# flake8: noqa E501
|
8
9
|
|
10
|
+
|
9
11
|
@typechecked
|
10
|
-
class Env
|
11
|
-
|
12
|
-
Env Represents an environment configuration for a task, encapsulating details such as environment name, OS-specific
|
12
|
+
class Env:
|
13
|
+
"""
|
14
|
+
Env Represents an environment configuration for a task, encapsulating details such as environment name, OS-specific
|
13
15
|
environment name, default values, and rendering behavior.
|
14
16
|
|
15
17
|
Attributes:
|
@@ -17,7 +19,7 @@ class Env():
|
|
17
19
|
os_name (Optional[str]): The corresponding name in the OS's environment, if different from 'name'. You can set os_name to empty string if you don't want the environment to be linked to OS environment name.
|
18
20
|
default (JinjaTemplate): Default value of the environment variable.
|
19
21
|
should_render (bool): Flag to determine if the environment value should be rendered.
|
20
|
-
|
22
|
+
|
21
23
|
Examples:
|
22
24
|
>>> from zrb import Env, Task
|
23
25
|
>>> task = Task(
|
@@ -26,60 +28,60 @@ class Env():
|
|
26
28
|
>>> Env(name='DATABASE_URL', os_name='SYSTEM_DATABASE_URL', default='postgresql://...')
|
27
29
|
>>> ]
|
28
30
|
>>> )
|
29
|
-
|
31
|
+
"""
|
30
32
|
|
31
33
|
def __init__(
|
32
34
|
self,
|
33
35
|
name: str,
|
34
36
|
os_name: Optional[str] = None,
|
35
|
-
default: JinjaTemplate =
|
37
|
+
default: JinjaTemplate = "",
|
36
38
|
should_render: bool = True,
|
37
39
|
):
|
38
40
|
if name in RESERVED_ENV_NAMES:
|
39
|
-
raise ValueError(f
|
41
|
+
raise ValueError(f"Forbidden input name: {name}")
|
40
42
|
self.__name: str = name
|
41
43
|
self.__os_name: str = os_name if os_name is not None else name
|
42
44
|
self.__default: str = default
|
43
45
|
self.__should_render: bool = should_render
|
44
46
|
|
45
47
|
def get_name(self) -> str:
|
46
|
-
|
48
|
+
"""
|
47
49
|
Retrieves the name of the environment variable.
|
48
50
|
|
49
51
|
Returns:
|
50
52
|
str: The name of the environment variable.
|
51
|
-
|
53
|
+
"""
|
52
54
|
return self.__name
|
53
55
|
|
54
56
|
def get_os_name(self) -> Optional[str]:
|
55
|
-
|
57
|
+
"""
|
56
58
|
Retrieves the OS-specific name of the environment variable.
|
57
59
|
|
58
60
|
Returns:
|
59
61
|
Optional[str]: The OS-specific name of the environment variable.
|
60
|
-
|
62
|
+
"""
|
61
63
|
return self.__os_name
|
62
64
|
|
63
65
|
def get_default(self) -> str:
|
64
|
-
|
66
|
+
"""
|
65
67
|
Retrieves the default value of the environment variable.
|
66
68
|
|
67
69
|
Returns:
|
68
70
|
str: The default value of the environment variable.
|
69
|
-
|
71
|
+
"""
|
70
72
|
return self.__default
|
71
73
|
|
72
74
|
def should_render(self) -> bool:
|
73
|
-
|
75
|
+
"""
|
74
76
|
Determines whether the environment value should be rendered.
|
75
77
|
|
76
78
|
Returns:
|
77
79
|
bool: True if the environment value should be rendered, False otherwise.
|
78
|
-
|
80
|
+
"""
|
79
81
|
return self.__should_render
|
80
82
|
|
81
|
-
def get(self, prefix: str =
|
82
|
-
|
83
|
+
def get(self, prefix: str = "") -> str:
|
84
|
+
"""
|
83
85
|
Retrieves the value of the environment variable, considering an optional prefix.
|
84
86
|
|
85
87
|
Args:
|
@@ -97,21 +99,21 @@ class Env():
|
|
97
99
|
>>> print(env.get('DEV')) # will show 'localhost'
|
98
100
|
>>> print(env.get('PROD')) # will show 'example.com'
|
99
101
|
>>> print(env.get('STAG')) # will show '0.0.0.0'
|
100
|
-
|
101
|
-
if self.__os_name ==
|
102
|
+
"""
|
103
|
+
if self.__os_name == "":
|
102
104
|
return self.__default
|
103
105
|
prefixed_name = self.__get_prefixed_name(self.__os_name, prefix)
|
104
|
-
if prefixed_name in os.environ and os.environ[prefixed_name] !=
|
106
|
+
if prefixed_name in os.environ and os.environ[prefixed_name] != "":
|
105
107
|
return os.environ[prefixed_name]
|
106
|
-
if self.__os_name in os.environ and os.environ[self.__os_name] !=
|
108
|
+
if self.__os_name in os.environ and os.environ[self.__os_name] != "":
|
107
109
|
return os.environ[self.__os_name]
|
108
110
|
return self.__default
|
109
111
|
|
110
112
|
def __get_prefixed_name(self, name: str, prefix: str):
|
111
|
-
|
113
|
+
"""
|
112
114
|
Constructs the prefixed name of the environment variable.
|
113
115
|
|
114
|
-
This method is intended for internal use only.
|
116
|
+
This method is intended for internal use only.
|
115
117
|
|
116
118
|
Args:
|
117
119
|
name (str): The base name of the environment variable.
|
@@ -119,14 +121,14 @@ class Env():
|
|
119
121
|
|
120
122
|
Returns:
|
121
123
|
str: The prefixed name of the environment variable.
|
122
|
-
|
123
|
-
if prefix is None or prefix ==
|
124
|
+
"""
|
125
|
+
if prefix is None or prefix == "":
|
124
126
|
return name
|
125
|
-
return prefix +
|
127
|
+
return prefix + "_" + name
|
126
128
|
|
127
129
|
def __repr__(self) -> str:
|
128
130
|
cls_name = self.__class__.__name__
|
129
131
|
name = double_quote(self.__name)
|
130
|
-
os_name =
|
132
|
+
os_name = "None" if self.__os_name is None else double_quote(self.__os_name)
|
131
133
|
default = double_quote(self.__default)
|
132
|
-
return f
|
134
|
+
return f"<{cls_name} {name} os_name={os_name} default={default}>"
|
zrb/task_env/env_file.py
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
-
from zrb.helper.typing import List, Optional
|
2
|
-
from zrb.helper.typecheck import typechecked
|
3
1
|
from dotenv import dotenv_values
|
4
|
-
|
2
|
+
|
5
3
|
from zrb.helper.string.modification import double_quote
|
4
|
+
from zrb.helper.typecheck import typechecked
|
5
|
+
from zrb.helper.typing import List, Optional
|
6
|
+
from zrb.task_env.constant import RESERVED_ENV_NAMES
|
6
7
|
from zrb.task_env.env import Env
|
7
8
|
|
8
9
|
# flake8: noqa E501
|
9
10
|
|
11
|
+
|
10
12
|
@typechecked
|
11
|
-
class EnvFile
|
12
|
-
|
13
|
-
Represents a handler for an environment file, facilitating the creation and management of environment variables
|
13
|
+
class EnvFile:
|
14
|
+
"""
|
15
|
+
Represents a handler for an environment file, facilitating the creation and management of environment variables
|
14
16
|
(Env objects) based on the contents of the specified environment file.
|
15
17
|
|
16
18
|
Attributes:
|
@@ -28,13 +30,10 @@ class EnvFile():
|
|
28
30
|
>>> EnvFile(path=os.path.join(CURRENT_DIR, '.env'), prefix='SYSTEM')
|
29
31
|
>>> ]
|
30
32
|
>>> )
|
31
|
-
|
33
|
+
"""
|
32
34
|
|
33
35
|
def __init__(
|
34
|
-
self,
|
35
|
-
path: str,
|
36
|
-
prefix: Optional[str] = None,
|
37
|
-
should_render: bool = False
|
36
|
+
self, path: str, prefix: Optional[str] = None, should_render: bool = False
|
38
37
|
):
|
39
38
|
self.__path = path
|
40
39
|
self.__prefix = prefix.upper() if prefix is not None else None
|
@@ -43,8 +42,8 @@ class EnvFile():
|
|
43
42
|
self.__env_list_fetched: bool = False
|
44
43
|
|
45
44
|
def get_envs(self) -> List[Env]:
|
46
|
-
|
47
|
-
Retrieves a list of Env objects based on the environment file. If a prefix is provided, it is
|
45
|
+
"""
|
46
|
+
Retrieves a list of Env objects based on the environment file. If a prefix is provided, it is
|
48
47
|
applied to the environment variable names.
|
49
48
|
|
50
49
|
Returns:
|
@@ -54,7 +53,7 @@ class EnvFile():
|
|
54
53
|
>>> from zrb import Env, EnvFile
|
55
54
|
>>> env_file = EnvFile(path='some_file.env')
|
56
55
|
>>> envs: List[Env] = env_file.get_envs()
|
57
|
-
|
56
|
+
"""
|
58
57
|
if self.__env_list_fetched:
|
59
58
|
return self.__env_list
|
60
59
|
env_list: List[Env] = []
|
@@ -63,14 +62,16 @@ class EnvFile():
|
|
63
62
|
if key in RESERVED_ENV_NAMES:
|
64
63
|
continue
|
65
64
|
os_name: Optional[str] = None
|
66
|
-
if self.__prefix is not None and self.__prefix !=
|
67
|
-
os_name = f
|
68
|
-
env_list.append(
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
65
|
+
if self.__prefix is not None and self.__prefix != "":
|
66
|
+
os_name = f"{self.__prefix}_{key}"
|
67
|
+
env_list.append(
|
68
|
+
Env(
|
69
|
+
name=key,
|
70
|
+
os_name=os_name,
|
71
|
+
default=value,
|
72
|
+
should_render=self.__should_render,
|
73
|
+
)
|
74
|
+
)
|
74
75
|
self.__env_list = env_list
|
75
76
|
self.__env_list_fetched = True
|
76
77
|
return env_list
|
@@ -79,4 +80,4 @@ class EnvFile():
|
|
79
80
|
cls_name = self.__class__.__name__
|
80
81
|
path = double_quote(self.__path)
|
81
82
|
prefix = double_quote(self.__prefix)
|
82
|
-
return f
|
83
|
+
return f"<{cls_name} path={path} prefix={prefix}>"
|
zrb/task_group/group.py
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
from zrb.helper.typing import List, Optional, TypeVar
|
2
|
-
from zrb.helper.typecheck import typechecked
|
3
|
-
from zrb.task.any_task import AnyTask
|
4
1
|
from zrb.helper.string.conversion import to_cli_name
|
5
2
|
from zrb.helper.string.modification import double_quote
|
3
|
+
from zrb.helper.typecheck import typechecked
|
4
|
+
from zrb.helper.typing import List, Optional, TypeVar
|
5
|
+
from zrb.task.any_task import AnyTask
|
6
6
|
|
7
7
|
# flake8: noqa E501
|
8
|
-
TGroup = TypeVar(
|
8
|
+
TGroup = TypeVar("TGroup", bound="Group")
|
9
9
|
|
10
10
|
|
11
11
|
@typechecked
|
12
|
-
class Group
|
13
|
-
|
12
|
+
class Group:
|
13
|
+
"""
|
14
14
|
Represents a group of tasks and subgroups, facilitating organization and hierarchy.
|
15
15
|
|
16
|
-
This class allows the creation of a hierarchical structure by grouping tasks and
|
17
|
-
other task groups together. It provides methods to add tasks, retrieve tasks,
|
16
|
+
This class allows the creation of a hierarchical structure by grouping tasks and
|
17
|
+
other task groups together. It provides methods to add tasks, retrieve tasks,
|
18
18
|
and generate Command-Line Interface (CLI) names based on group names.
|
19
19
|
|
20
20
|
Attributes:
|
@@ -26,13 +26,10 @@ class Group():
|
|
26
26
|
>>> from zrb import Group
|
27
27
|
>>> system_group = Group(name='system')
|
28
28
|
>>> log_group = Group(name='log', parent='system')
|
29
|
-
|
29
|
+
"""
|
30
30
|
|
31
31
|
def __init__(
|
32
|
-
self,
|
33
|
-
name: str,
|
34
|
-
description: str = '',
|
35
|
-
parent: Optional[TGroup] = None
|
32
|
+
self, name: str, description: str = "", parent: Optional[TGroup] = None
|
36
33
|
):
|
37
34
|
self.__name = name
|
38
35
|
self.__description = description
|
@@ -43,25 +40,25 @@ class Group():
|
|
43
40
|
self.__tasks: List[AnyTask] = []
|
44
41
|
|
45
42
|
def get_parent(self) -> Optional[TGroup]:
|
46
|
-
|
43
|
+
"""
|
47
44
|
Retrieves parent of the Group.
|
48
45
|
|
49
46
|
Returns:
|
50
47
|
Optional[Group]: Parent of the group.
|
51
48
|
|
52
49
|
Examples:
|
53
|
-
>>> from zrb import Group
|
50
|
+
>>> from zrb import Group
|
54
51
|
>>> system_group = Group(name='my system')
|
55
52
|
>>> system_log_group = Group(name='log', parent=system_group)
|
56
53
|
>>> print(system_group.get_parent())
|
57
54
|
>>> print(system_log_group.get_parent())
|
58
55
|
None
|
59
56
|
<Group "my-system">
|
60
|
-
|
57
|
+
"""
|
61
58
|
return self._parent
|
62
59
|
|
63
60
|
def get_description(self) -> str:
|
64
|
-
|
61
|
+
"""
|
65
62
|
Retrieves group description.
|
66
63
|
|
67
64
|
Returns:
|
@@ -72,11 +69,11 @@ class Group():
|
|
72
69
|
>>> group = Group(name='group', description='description of the group')
|
73
70
|
>>> print(group.get_description())
|
74
71
|
description of the group
|
75
|
-
|
72
|
+
"""
|
76
73
|
return self.__description
|
77
74
|
|
78
75
|
def get_cli_name(self) -> str:
|
79
|
-
|
76
|
+
"""
|
80
77
|
Retrieves the CLI name of the group, formatted in kebab case.
|
81
78
|
|
82
79
|
The method converts the group name into a CLI-friendly format, suitable for command-line usage.
|
@@ -89,11 +86,11 @@ class Group():
|
|
89
86
|
>>> system_group = Group(name='my system')
|
90
87
|
>>> print(system_group.get_cli_name())
|
91
88
|
my-system
|
92
|
-
|
89
|
+
"""
|
93
90
|
return to_cli_name(self.__name)
|
94
91
|
|
95
92
|
def _get_full_cli_name(self) -> str:
|
96
|
-
|
93
|
+
"""
|
97
94
|
Retrieves the full CLI name of the group, including names of parent groups.
|
98
95
|
|
99
96
|
This method is intended for internal use and constructs a full CLI name that reflects the group's hierarchy.
|
@@ -107,15 +104,15 @@ class Group():
|
|
107
104
|
>>> system_log_group = Group(name='log', parent=system_group)
|
108
105
|
>>> print(system_log_group._get_full_cli_name())
|
109
106
|
my-system log
|
110
|
-
|
107
|
+
"""
|
111
108
|
cli_name = self.get_cli_name()
|
112
109
|
if self._parent is None:
|
113
110
|
return cli_name
|
114
111
|
parent_cli_name = self._parent._get_full_cli_name()
|
115
|
-
return f
|
112
|
+
return f"{parent_cli_name} {cli_name}"
|
116
113
|
|
117
114
|
def _add_task(self, task: AnyTask):
|
118
|
-
|
115
|
+
"""
|
119
116
|
Adds a task to the group.
|
120
117
|
|
121
118
|
This method is intended for internal use. It appends a given task to the group's task list.
|
@@ -132,11 +129,11 @@ class Group():
|
|
132
129
|
>>> group._add_task(second_task)
|
133
130
|
>>> print(group.get_tasks())
|
134
131
|
[<Task "group first-task">, <Task "group second-task">]
|
135
|
-
|
132
|
+
"""
|
136
133
|
self.__tasks.append(task)
|
137
134
|
|
138
135
|
def get_tasks(self) -> List[AnyTask]:
|
139
|
-
|
136
|
+
"""
|
140
137
|
Get direct Tasks under this Task Group.
|
141
138
|
|
142
139
|
Returns:
|
@@ -149,11 +146,11 @@ class Group():
|
|
149
146
|
>>> second_task = Task(name='second-task', group=group)
|
150
147
|
>>> print(group.get_tasks())
|
151
148
|
[<Task "group first-task">, <Task "group second-task">]
|
152
|
-
|
149
|
+
"""
|
153
150
|
return self.__tasks
|
154
151
|
|
155
152
|
def get_children(self) -> List[TGroup]:
|
156
|
-
|
153
|
+
"""
|
157
154
|
Retrieves the list of direct subgroups under this group.
|
158
155
|
|
159
156
|
Returns a list of immediate subgroups nested within this group, helping to understand the group's hierarchical structure.
|
@@ -168,10 +165,10 @@ class Group():
|
|
168
165
|
>>> sub_group_2 = TaskGroup(name='sub-group-2', parent=group)
|
169
166
|
>>> print(group.get_children())
|
170
167
|
[<Group "group sub-group-1">, <Group "group sub-group-2">]
|
171
|
-
|
168
|
+
"""
|
172
169
|
return self.__children
|
173
170
|
|
174
171
|
def __repr__(self) -> str:
|
175
172
|
cls_name = self.__class__.__name__
|
176
173
|
full_cli_name = double_quote(self._get_full_cli_name())
|
177
|
-
return f
|
174
|
+
return f"<{cls_name} {full_cli_name}>"
|
zrb/task_input/any_input.py
CHANGED
@@ -1,72 +1,74 @@
|
|
1
|
-
from zrb.helper.typing import Any, List, Mapping
|
2
1
|
from abc import ABC, abstractmethod
|
3
2
|
|
3
|
+
from zrb.helper.typing import Any, List, Mapping
|
4
|
+
|
4
5
|
# flake8: noqa E501
|
5
6
|
|
7
|
+
|
6
8
|
class AnyInput(ABC):
|
7
|
-
|
9
|
+
"""
|
8
10
|
Abstract base class representing a generalized input specification.
|
9
|
-
This class serves as a template for creating various input types,
|
11
|
+
This class serves as a template for creating various input types,
|
10
12
|
providing a standardized interface for input handling and processing.
|
11
13
|
|
12
|
-
|
14
|
+
"""
|
13
15
|
|
14
16
|
@abstractmethod
|
15
17
|
def get_name(self) -> str:
|
16
|
-
|
18
|
+
"""
|
17
19
|
Retrieves the name of the input.
|
18
20
|
|
19
21
|
Returns:
|
20
22
|
str: The name of the input.
|
21
|
-
|
23
|
+
"""
|
22
24
|
pass
|
23
25
|
|
24
26
|
@abstractmethod
|
25
27
|
def get_default(self) -> Any:
|
26
|
-
|
28
|
+
"""
|
27
29
|
Obtains the default value of the input.
|
28
30
|
|
29
31
|
Returns:
|
30
32
|
Any: The default value of the input. The type can be any, depending on the input specification.
|
31
|
-
|
33
|
+
"""
|
32
34
|
pass
|
33
35
|
|
34
36
|
@abstractmethod
|
35
37
|
def get_param_decl(self) -> List[str]:
|
36
|
-
|
38
|
+
"""
|
37
39
|
Fetches a list of parameter option associated with the input (i.e., `-f` or `--file`).
|
38
40
|
|
39
41
|
Returns:
|
40
42
|
List[str]: A list containing strings of parameter options.
|
41
|
-
|
43
|
+
"""
|
42
44
|
pass
|
43
45
|
|
44
46
|
@abstractmethod
|
45
47
|
def get_options(self) -> Mapping[str, Any]:
|
46
|
-
|
48
|
+
"""
|
47
49
|
Provides a mapping (dictionary) representing the input.
|
48
50
|
|
49
51
|
Returns:
|
50
52
|
Mapping[str, Any]: A dictionary where keys are option names and values are the corresponding details.
|
51
|
-
|
53
|
+
"""
|
52
54
|
pass
|
53
55
|
|
54
56
|
@abstractmethod
|
55
57
|
def should_render(self) -> bool:
|
56
|
-
|
58
|
+
"""
|
57
59
|
Determines whether or not the input should be rendered.
|
58
60
|
|
59
61
|
Returns:
|
60
62
|
bool: True if the input should be rendered, False otherwise.
|
61
|
-
|
63
|
+
"""
|
62
64
|
pass
|
63
65
|
|
64
66
|
@abstractmethod
|
65
67
|
def is_hidden(self) -> bool:
|
66
|
-
|
68
|
+
"""
|
67
69
|
Checks whether the input value is meant to be hidden from view or output.
|
68
70
|
|
69
71
|
Returns:
|
70
72
|
bool: True if the input is hidden, False otherwise.
|
71
|
-
|
73
|
+
"""
|
72
74
|
pass
|