zrb 0.23.4__py3-none-any.whl → 0.26.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zrb/__init__.py +2 -0
- zrb/action/runner.py +8 -5
- zrb/advertisement.py +1 -2
- zrb/builtin/__init__.py +4 -0
- zrb/builtin/base64/decode.py +1 -1
- zrb/builtin/base64/encode.py +1 -1
- zrb/builtin/devtool/install/_helper.py +2 -1
- zrb/builtin/devtool/install/_input.py +2 -2
- zrb/builtin/docker/prune.py +11 -3
- zrb/builtin/env/get.py +3 -2
- zrb/builtin/eval.py +2 -1
- zrb/builtin/git/get_file_changes.py +2 -1
- zrb/builtin/md5/hash.py +1 -1
- zrb/builtin/md5/sum.py +1 -1
- zrb/builtin/monorepo/__init__.py +7 -0
- zrb/builtin/monorepo/_config.py +11 -0
- zrb/builtin/monorepo/_group.py +3 -0
- zrb/builtin/monorepo/_task.py +99 -0
- zrb/builtin/monorepo/add.py +40 -0
- zrb/builtin/monorepo/pull.py +23 -0
- zrb/builtin/monorepo/push.py +35 -0
- zrb/builtin/project/_helper.py +3 -3
- zrb/builtin/project/_input.py +2 -2
- zrb/builtin/project/add/app/generator/generator.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/snake_zrb_generator_name.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/remove.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/start.py +6 -7
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/stop.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/src/kebab-zrb-app-name/docker-compose.yml +0 -2
- zrb/builtin/project/add/app/python/python.py +1 -1
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/remove.py +1 -1
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/start.py +6 -7
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/stop.py +1 -1
- zrb/builtin/project/add/app/python/template/src/kebab-zrb-app-name/docker-compose.yml +0 -2
- zrb/builtin/project/add/fastapp/app/app.py +3 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_helper.py +2 -53
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_service_config.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/_helper.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/_helper.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/stop.py +2 -0
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/_helper.py +5 -3
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/start.py +4 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/frontend/build-once.sh +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/frontend/build.sh +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/_helper.py +3 -5
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/start.py +3 -3
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/{start_microservices.py → start_services.py} +2 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/.generator-version +1 -0
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/deployment/_common.py +5 -5
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/deployment/app_helper.py +5 -5
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/docker-compose.yml +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/loadtest/locustfile.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/loadtest/template.env +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/error.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/kafka/admin.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/kafka/consumer.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/messagebus.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/mock.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/rabbitmq/admin.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/rabbitmq/consumer.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/model/repo_model.py +3 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/db_repo.py +7 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/repo.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/search_filter.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/messagebus/caller.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/messagebus/server.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/rpc.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/serializer/serializer.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/config.py +59 -62
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/frontend/package-lock.json +4443 -0
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/helper/async_task.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/app/app.py +28 -28
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/app/app_lifespan.py +15 -15
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/app/app_state.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/db_connection.py +14 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/frontend_index.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/log.py +6 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/messagebus.py +33 -33
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/rpc.py +9 -9
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/component/access_token/scheme.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/component/access_token/util.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/group/repo.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/group/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/api.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/model.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/repo.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/rpc.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/access_token_scheme.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/access_token_util.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/model/user_model.py +6 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/refresh_token_util.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/user.py +18 -18
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/register_module.py +8 -8
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/register_permission.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/group.py +3 -5
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/permission.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/request.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/user.py +5 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/entity/activity/event.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/entity/activity/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/register_module.py +8 -8
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/schema/activity.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/template.env +5 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py +8 -8
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_permission_crud.py +8 -8
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py +8 -8
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_login.py +15 -15
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/test_liveness_and_readiness.py +4 -4
- zrb/builtin/project/add/fastapp/crud/_helper/__init__.py +7 -0
- zrb/builtin/project/add/fastapp/crud/_helper/_common.py +8 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_api.py +45 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_permission.py +40 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_rpc.py +45 -0
- zrb/builtin/project/add/fastapp/crud/_task_factory.py +1 -2
- zrb/builtin/project/add/fastapp/crud/crud.py +4 -25
- zrb/builtin/project/add/fastapp/crud/nodejs/codemod/package-lock.json +3 -3
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/repo.py +12 -1
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/schema/snake_zrb_entity_name.py +3 -2
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/test/snake_zrb_module_name/test_snake_zrb_entity_name.py +9 -8
- zrb/builtin/project/add/fastapp/field/_helper/__init__.py +17 -0
- zrb/builtin/project/add/fastapp/field/_helper/_common.py +102 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_delete_page.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_detail_page.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_insert_page.py +62 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_list_page.py +47 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_repo.py +47 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_schema.py +45 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_test.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_update_page.py +50 -0
- zrb/builtin/project/add/fastapp/field/_input.py +14 -2
- zrb/builtin/project/add/fastapp/field/field.py +52 -70
- zrb/builtin/project/add/fastapp/module/_helper/__init__.py +17 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_all_disabled_env.py +22 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_all_enabled_env.py +22 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_deployment_template_env.py +25 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_src_template_env.py +25 -0
- zrb/builtin/project/add/fastapp/module/_helper/create_app_config.py +29 -0
- zrb/builtin/project/add/fastapp/module/_helper/create_microservice_config.py +157 -0
- zrb/builtin/project/add/fastapp/module/_helper/register_migration.py +35 -0
- zrb/builtin/project/add/fastapp/module/_helper/register_module.py +33 -0
- zrb/builtin/project/add/fastapp/module/module.py +9 -38
- zrb/builtin/project/add/fastapp/module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/register_module.py +8 -8
- zrb/builtin/project/add/plugin/plugin.py +3 -3
- zrb/builtin/project/add/project_task/add.py +1 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/build.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/container/remove.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/container/start.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/container/stop.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/deploy.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/destroy.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/get_env.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/image/build.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/image/push.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/publish.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/start.py +2 -1
- zrb/builtin/project/add/task/cmd/add.py +1 -1
- zrb/builtin/project/add/task/docker_compose/add.py +1 -1
- zrb/builtin/project/add/task/docker_compose/template/src/kebab-zrb-task-name/docker-compose.yml +0 -2
- zrb/builtin/project/add/task/python/add.py +1 -1
- zrb/builtin/project/add/task/python/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/project/create/_helper.py +1 -1
- zrb/builtin/project/create/create.py +3 -3
- zrb/builtin/say.py +3 -3
- zrb/builtin/version.py +5 -4
- zrb/config/config.py +24 -14
- zrb/helper/accessories/color.py +2 -1
- zrb/helper/advertisement.py +2 -1
- zrb/helper/asyncio_task.py +23 -0
- zrb/helper/callable.py +4 -1
- zrb/helper/cli.py +20 -6
- zrb/helper/codemod/add_import_module.py +3 -2
- zrb/helper/codemod/add_property_to_class.py +2 -1
- zrb/helper/default_env.py +2 -1
- zrb/helper/docker_compose/fetch_external_env.py +4 -2
- zrb/helper/docker_compose/file.py +3 -1
- zrb/helper/env_map/fetch.py +3 -2
- zrb/helper/file/copy_tree.py +2 -1
- zrb/helper/file/match.py +2 -2
- zrb/helper/git/detect_changes.py +1 -1
- zrb/helper/loader/load_module.py +7 -46
- zrb/helper/loader/load_script.py +57 -0
- zrb/helper/log.py +3 -3
- zrb/helper/map/conversion.py +3 -1
- zrb/helper/string/jinja.py +2 -1
- zrb/helper/string/parse_replacement.py +1 -1
- zrb/helper/typecheck.py +2 -2
- zrb/helper/typing.py +5 -27
- zrb/helper/util.py +13 -1
- zrb/runner.py +2 -2
- zrb/task/any_task.py +9 -17
- zrb/task/any_task_event_handler.py +3 -1
- zrb/task/base_remote_cmd_task.py +3 -10
- zrb/task/base_task/base_task.py +15 -11
- zrb/task/base_task/component/base_task_model.py +15 -22
- zrb/task/base_task/component/common_task_model.py +15 -22
- zrb/task/base_task/component/renderer.py +3 -1
- zrb/task/base_task/component/trackers.py +1 -1
- zrb/task/checker.py +2 -1
- zrb/task/cmd_task.py +10 -22
- zrb/task/decorator.py +3 -1
- zrb/task/docker_compose_start_task.py +146 -0
- zrb/task/docker_compose_task.py +43 -34
- zrb/task/flow_task.py +19 -17
- zrb/task/http_checker.py +3 -9
- zrb/task/looper.py +4 -2
- zrb/task/notifier.py +3 -1
- zrb/task/parallel.py +4 -4
- zrb/task/path_checker.py +6 -12
- zrb/task/path_watcher.py +5 -13
- zrb/task/port_checker.py +3 -9
- zrb/task/recurring_task.py +5 -4
- zrb/task/remote_cmd_task.py +2 -1
- zrb/task/resource_maker.py +6 -13
- zrb/task/rsync_task.py +3 -1
- zrb/task/server.py +13 -12
- zrb/task/time_watcher.py +3 -10
- zrb/task/watcher.py +2 -1
- zrb/task/wiki_task.py +4 -3
- zrb/task_env/env.py +2 -1
- zrb/task_env/env_file.py +7 -6
- zrb/task_group/group.py +8 -7
- zrb/task_input/any_input.py +4 -3
- zrb/task_input/base_input.py +7 -5
- zrb/task_input/bool_input.py +2 -1
- zrb/task_input/choice_input.py +3 -1
- zrb/task_input/float_input.py +2 -1
- zrb/task_input/int_input.py +2 -1
- zrb/task_input/multiline_input.py +5 -3
- zrb/task_input/password_input.py +2 -1
- zrb/task_input/str_input.py +2 -1
- {zrb-0.23.4.dist-info → zrb-0.26.0.dist-info}/METADATA +2 -2
- {zrb-0.23.4.dist-info → zrb-0.26.0.dist-info}/RECORD +242 -214
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/init.py +0 -34
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/init.py +0 -34
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/init.py +0 -36
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/init.py +0 -36
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/init.py +0 -26
- zrb/builtin/project/add/fastapp/crud/_helper.py +0 -118
- zrb/builtin/project/add/fastapp/field/_helper.py +0 -328
- zrb/builtin/project/add/fastapp/module/_helper.py +0 -313
- {zrb-0.23.4.dist-info → zrb-0.26.0.dist-info}/LICENSE +0 -0
- {zrb-0.23.4.dist-info → zrb-0.26.0.dist-info}/WHEEL +0 -0
- {zrb-0.23.4.dist-info → zrb-0.26.0.dist-info}/entry_points.txt +0 -0
zrb/task/docker_compose_task.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
import os
|
2
2
|
import pathlib
|
3
|
+
from collections.abc import Callable, Iterable, Mapping
|
4
|
+
from typing import Any, Optional, TypeVar, Union
|
3
5
|
|
4
|
-
from zrb.config.config import
|
6
|
+
from zrb.config.config import CONTAINER_BACKEND
|
5
7
|
from zrb.helper.accessories.color import colored
|
6
8
|
from zrb.helper.accessories.name import get_random_name
|
7
9
|
from zrb.helper.docker_compose.fetch_external_env import fetch_compose_file_env_map
|
@@ -10,17 +12,7 @@ from zrb.helper.log import logger
|
|
10
12
|
from zrb.helper.string.conversion import to_cli_name
|
11
13
|
from zrb.helper.string.modification import double_quote
|
12
14
|
from zrb.helper.typecheck import typechecked
|
13
|
-
from zrb.helper.typing import
|
14
|
-
Any,
|
15
|
-
Callable,
|
16
|
-
Iterable,
|
17
|
-
JinjaTemplate,
|
18
|
-
List,
|
19
|
-
Mapping,
|
20
|
-
Optional,
|
21
|
-
TypeVar,
|
22
|
-
Union,
|
23
|
-
)
|
15
|
+
from zrb.helper.typing import JinjaTemplate
|
24
16
|
from zrb.helper.util import to_snake_case
|
25
17
|
from zrb.task.any_task import AnyTask
|
26
18
|
from zrb.task.any_task_event_handler import (
|
@@ -66,19 +58,19 @@ def _get_ensure_zrb_network_task(backend: str):
|
|
66
58
|
|
67
59
|
|
68
60
|
TDockerComposeTask = TypeVar("TDockerComposeTask", bound="DockerComposeTask")
|
69
|
-
ensure_zrb_network_task = _get_ensure_zrb_network_task(
|
61
|
+
ensure_zrb_network_task = _get_ensure_zrb_network_task(CONTAINER_BACKEND)
|
70
62
|
|
71
63
|
|
72
64
|
@typechecked
|
73
65
|
class ServiceConfig:
|
74
|
-
def __init__(self, envs:
|
66
|
+
def __init__(self, envs: list[Env] = [], env_files: list[EnvFile] = []):
|
75
67
|
self._envs = envs
|
76
68
|
self._env_files = env_files
|
77
69
|
|
78
|
-
def get_envs(self) ->
|
70
|
+
def get_envs(self) -> list[Env]:
|
79
71
|
return self._envs
|
80
72
|
|
81
|
-
def get_env_files(self) ->
|
73
|
+
def get_env_files(self) -> list[EnvFile]:
|
82
74
|
return self._env_files
|
83
75
|
|
84
76
|
|
@@ -224,7 +216,7 @@ class DockerComposeTask(CmdTask):
|
|
224
216
|
def __generate_compose_runtime_file(self):
|
225
217
|
compose_data = read_compose_file(self._compose_template_file)
|
226
218
|
for service, service_config in self._compose_service_configs.items():
|
227
|
-
envs:
|
219
|
+
envs: list[Env] = []
|
228
220
|
env_files = service_config.get_env_files()
|
229
221
|
for env_file in env_files:
|
230
222
|
envs += env_file.get_envs()
|
@@ -233,7 +225,7 @@ class DockerComposeTask(CmdTask):
|
|
233
225
|
write_compose_file(self._compose_runtime_file, compose_data)
|
234
226
|
|
235
227
|
def __apply_service_env(
|
236
|
-
self, compose_data: Any, service_name: str, envs:
|
228
|
+
self, compose_data: Any, service_name: str, envs: list[Env]
|
237
229
|
) -> Any:
|
238
230
|
# service not found
|
239
231
|
service_map = compose_data["services"]
|
@@ -269,7 +261,7 @@ class DockerComposeTask(CmdTask):
|
|
269
261
|
return compose_data
|
270
262
|
|
271
263
|
def __get_service_new_env_map(
|
272
|
-
self, service_name: str, service_env_map: Mapping[str, str], new_envs:
|
264
|
+
self, service_name: str, service_env_map: Mapping[str, str], new_envs: list[Env]
|
273
265
|
) -> Mapping[str, str]:
|
274
266
|
new_service_envs: Mapping[str, str] = {}
|
275
267
|
for env in new_envs:
|
@@ -280,9 +272,9 @@ class DockerComposeTask(CmdTask):
|
|
280
272
|
return new_service_envs
|
281
273
|
|
282
274
|
def __get_service_new_env_list(
|
283
|
-
self, service_name: str, service_env_list:
|
284
|
-
) ->
|
285
|
-
new_service_envs:
|
275
|
+
self, service_name: str, service_env_list: list[str], new_envs: list[Env]
|
276
|
+
) -> list[str]:
|
277
|
+
new_service_envs: list[str] = []
|
286
278
|
for env in new_envs:
|
287
279
|
should_be_added = 0 == len(
|
288
280
|
[
|
@@ -341,10 +333,34 @@ class DockerComposeTask(CmdTask):
|
|
341
333
|
raise Exception(f"Invalid compose file: {compose_file}")
|
342
334
|
|
343
335
|
def get_cmd_script(self, *args: Any, **kwargs: Any) -> str:
|
344
|
-
|
336
|
+
# setup
|
337
|
+
setup_cmd = self._create_cmd_script(
|
345
338
|
self._setup_cmd_path, self._setup_cmd, *args, **kwargs
|
346
339
|
)
|
347
|
-
|
340
|
+
cmd_list = [setup_cmd] if setup_cmd.strip() != "" else []
|
341
|
+
# compose command
|
342
|
+
cmd_list.append(
|
343
|
+
self._get_docker_compose_cmd_script(
|
344
|
+
compose_cmd=self._compose_cmd,
|
345
|
+
compose_options=self._compose_options,
|
346
|
+
compose_flags=self._compose_flags,
|
347
|
+
compose_args=self._compose_args,
|
348
|
+
*args,
|
349
|
+
)
|
350
|
+
)
|
351
|
+
cmd_str = "\n".join(cmd_list)
|
352
|
+
self.log_info(f"Command: {cmd_str}")
|
353
|
+
return cmd_str
|
354
|
+
|
355
|
+
def _get_docker_compose_cmd_script(
|
356
|
+
self,
|
357
|
+
compose_cmd: str,
|
358
|
+
compose_options: Mapping[JinjaTemplate, JinjaTemplate],
|
359
|
+
compose_flags: Iterable[JinjaTemplate],
|
360
|
+
compose_args: Iterable[JinjaTemplate],
|
361
|
+
*args: Any,
|
362
|
+
) -> str:
|
363
|
+
command_options = dict(compose_options)
|
348
364
|
command_options["--file"] = self._compose_runtime_file
|
349
365
|
options = " ".join(
|
350
366
|
[
|
@@ -356,22 +372,15 @@ class DockerComposeTask(CmdTask):
|
|
356
372
|
flags = " ".join(
|
357
373
|
[
|
358
374
|
self.render_str(flag)
|
359
|
-
for flag in
|
375
|
+
for flag in compose_flags
|
360
376
|
if self.render_str(flag) != ""
|
361
377
|
]
|
362
378
|
)
|
363
379
|
args = " ".join(
|
364
380
|
[
|
365
381
|
double_quote(self.render_str(arg))
|
366
|
-
for arg in
|
382
|
+
for arg in compose_args
|
367
383
|
if self.render_str(arg) != ""
|
368
384
|
]
|
369
385
|
)
|
370
|
-
|
371
|
-
[
|
372
|
-
setup_cmd_str,
|
373
|
-
f"{container_backend} compose {options} {self._compose_cmd} {flags} {args}", # noqa
|
374
|
-
]
|
375
|
-
)
|
376
|
-
self.log_info(f"Command: {cmd_str}")
|
377
|
-
return cmd_str
|
386
|
+
return f"{CONTAINER_BACKEND} compose {options} {compose_cmd} {flags} {args}"
|
zrb/task/flow_task.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
from collections.abc import Callable, Iterable
|
2
|
+
from typing import Optional, TypeVar, Union
|
3
|
+
|
1
4
|
from zrb.helper.accessories.color import colored
|
2
5
|
from zrb.helper.log import logger
|
3
6
|
from zrb.helper.typecheck import typechecked
|
4
|
-
from zrb.helper.typing import Callable, Iterable, List, Optional, TypeVar, Union
|
5
7
|
from zrb.task.any_task import AnyTask
|
6
8
|
from zrb.task.any_task_event_handler import (
|
7
9
|
OnFailed,
|
@@ -48,7 +50,7 @@ class FlowTask(BaseTask):
|
|
48
50
|
checking_interval: Union[float, int] = 0.05,
|
49
51
|
retry: int = 2,
|
50
52
|
retry_interval: Union[float, int] = 1,
|
51
|
-
steps:
|
53
|
+
steps: list[Union[AnyTask, list[AnyTask]]] = [],
|
52
54
|
should_execute: Union[bool, str, Callable[..., bool]] = True,
|
53
55
|
return_upstream_result: bool = False,
|
54
56
|
):
|
@@ -91,12 +93,12 @@ class FlowTask(BaseTask):
|
|
91
93
|
|
92
94
|
def _create_flow_upstreams(
|
93
95
|
self,
|
94
|
-
steps:
|
95
|
-
upstreams:
|
96
|
-
inputs:
|
97
|
-
envs:
|
98
|
-
env_files:
|
99
|
-
) ->
|
96
|
+
steps: list[Union[AnyTask, list[AnyTask]]],
|
97
|
+
upstreams: list[AnyTask],
|
98
|
+
inputs: list[AnyInput],
|
99
|
+
envs: list[Env],
|
100
|
+
env_files: list[EnvFile],
|
101
|
+
) -> list[AnyTask]:
|
100
102
|
flow_upstreams = upstreams
|
101
103
|
for step in steps:
|
102
104
|
tasks = [task.copy() for task in self._step_to_tasks(step)]
|
@@ -110,20 +112,20 @@ class FlowTask(BaseTask):
|
|
110
112
|
flow_upstreams = new_upstreams
|
111
113
|
return flow_upstreams
|
112
114
|
|
113
|
-
def _step_to_tasks(self, step: Union[AnyTask,
|
115
|
+
def _step_to_tasks(self, step: Union[AnyTask, list[AnyTask]]) -> list[AnyTask]:
|
114
116
|
if isinstance(step, AnyTask):
|
115
117
|
return [step]
|
116
118
|
return step
|
117
119
|
|
118
120
|
def _create_embeded_tasks(
|
119
121
|
self,
|
120
|
-
tasks:
|
121
|
-
upstreams:
|
122
|
-
inputs:
|
123
|
-
envs:
|
124
|
-
env_files:
|
125
|
-
) ->
|
126
|
-
embeded_tasks:
|
122
|
+
tasks: list[AnyTask],
|
123
|
+
upstreams: list[AnyTask],
|
124
|
+
inputs: list[AnyInput],
|
125
|
+
envs: list[Env],
|
126
|
+
env_files: list[EnvFile],
|
127
|
+
) -> list[AnyTask]:
|
128
|
+
embeded_tasks: list[AnyTask] = []
|
127
129
|
for embeded_task in tasks:
|
128
130
|
embeded_task_upstreams = self._get_all_upstreams(tasks=[embeded_task])
|
129
131
|
for embeded_task_upstream in embeded_task_upstreams:
|
@@ -134,7 +136,7 @@ class FlowTask(BaseTask):
|
|
134
136
|
embeded_tasks.append(embeded_task)
|
135
137
|
return embeded_tasks
|
136
138
|
|
137
|
-
def _get_all_upstreams(self, tasks:
|
139
|
+
def _get_all_upstreams(self, tasks: list[AnyTask]):
|
138
140
|
all_upstreams = []
|
139
141
|
for task in tasks:
|
140
142
|
upstreams = task._get_upstreams()
|
zrb/task/http_checker.py
CHANGED
@@ -1,17 +1,11 @@
|
|
1
|
+
from collections.abc import Callable, Iterable
|
1
2
|
from http.client import HTTPConnection, HTTPSConnection
|
3
|
+
from typing import Any, Optional, TypeVar, Union
|
2
4
|
|
3
5
|
from zrb.helper.accessories.color import colored
|
4
6
|
from zrb.helper.log import logger
|
5
7
|
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.typing import
|
7
|
-
Any,
|
8
|
-
Callable,
|
9
|
-
Iterable,
|
10
|
-
JinjaTemplate,
|
11
|
-
Optional,
|
12
|
-
TypeVar,
|
13
|
-
Union,
|
14
|
-
)
|
8
|
+
from zrb.helper.typing import JinjaTemplate
|
15
9
|
from zrb.task.any_task import AnyTask
|
16
10
|
from zrb.task.any_task_event_handler import (
|
17
11
|
OnFailed,
|
zrb/task/looper.py
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
+
from collections.abc import Callable
|
2
|
+
from typing import Optional
|
3
|
+
|
1
4
|
from zrb.helper.accessories.color import colored
|
2
5
|
from zrb.helper.callable import run_async
|
3
6
|
from zrb.helper.log import logger
|
4
|
-
from zrb.helper.typing import Callable, List, Mapping, Optional
|
5
7
|
|
6
8
|
logger.debug(colored("Loading zrb.task.looper", attrs=["dark"]))
|
7
9
|
|
8
10
|
|
9
11
|
class Looper:
|
10
12
|
def __init__(self):
|
11
|
-
self._queue: Mapping[str,
|
13
|
+
self._queue: Mapping[str, list[Optional[bool]]] = {}
|
12
14
|
self._should_stop = False
|
13
15
|
|
14
16
|
async def pop(self, identifier: str) -> Optional[bool]:
|
zrb/task/notifier.py
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
import os
|
2
2
|
import subprocess
|
3
|
+
from collections.abc import Callable, Iterable
|
4
|
+
from typing import Any, Optional, Union
|
3
5
|
|
4
6
|
from zrb.helper.accessories.color import colored
|
5
7
|
from zrb.helper.accessories.icon import get_random_icon
|
6
8
|
from zrb.helper.log import logger
|
7
9
|
from zrb.helper.string.modification import double_quote
|
8
10
|
from zrb.helper.typecheck import typechecked
|
9
|
-
from zrb.helper.typing import
|
11
|
+
from zrb.helper.typing import JinjaTemplate
|
10
12
|
from zrb.task.any_task import AnyTask
|
11
13
|
from zrb.task.any_task_event_handler import (
|
12
14
|
OnFailed,
|
zrb/task/parallel.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
|
+
from typing import TypeVar, Union
|
2
3
|
|
3
4
|
from zrb.helper.accessories.color import colored
|
4
5
|
from zrb.helper.log import logger
|
5
6
|
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.typing import List, TypeVar, Union
|
7
7
|
from zrb.task.any_task import AnyTask
|
8
8
|
|
9
9
|
logger.debug(colored("Loading zrb.task.parallel", attrs=["dark"]))
|
@@ -13,7 +13,7 @@ TParallel = TypeVar("TParallel", bound="Parallel")
|
|
13
13
|
|
14
14
|
class AnyParallel(ABC):
|
15
15
|
@abstractmethod
|
16
|
-
def get_tasks(self) ->
|
16
|
+
def get_tasks(self) -> list[AnyTask]:
|
17
17
|
pass
|
18
18
|
|
19
19
|
|
@@ -22,7 +22,7 @@ class Parallel(AnyParallel):
|
|
22
22
|
def __init__(self, *tasks: AnyTask):
|
23
23
|
self.__tasks = list(tasks)
|
24
24
|
|
25
|
-
def get_tasks(self) ->
|
25
|
+
def get_tasks(self) -> list[AnyTask]:
|
26
26
|
return self.__tasks
|
27
27
|
|
28
28
|
def __rshift__(
|
@@ -33,7 +33,7 @@ class Parallel(AnyParallel):
|
|
33
33
|
operand.add_upstream(task)
|
34
34
|
return operand
|
35
35
|
if isinstance(operand, AnyParallel):
|
36
|
-
other_tasks:
|
36
|
+
other_tasks: list[AnyTask] = operand.get_tasks()
|
37
37
|
for task in self.__tasks:
|
38
38
|
for other_task in other_tasks:
|
39
39
|
other_task.add_upstream(task)
|
zrb/task/path_checker.py
CHANGED
@@ -1,17 +1,11 @@
|
|
1
|
+
from collections.abc import Callable, Iterable
|
2
|
+
from typing import Any, Optional, TypeVar, Union
|
3
|
+
|
1
4
|
from zrb.helper.accessories.color import colored
|
2
5
|
from zrb.helper.file.match import get_file_names
|
3
6
|
from zrb.helper.log import logger
|
4
7
|
from zrb.helper.typecheck import typechecked
|
5
|
-
from zrb.helper.typing import
|
6
|
-
Any,
|
7
|
-
Callable,
|
8
|
-
Iterable,
|
9
|
-
JinjaTemplate,
|
10
|
-
List,
|
11
|
-
Optional,
|
12
|
-
TypeVar,
|
13
|
-
Union,
|
14
|
-
)
|
8
|
+
from zrb.helper.typing import JinjaTemplate
|
15
9
|
from zrb.task.any_task import AnyTask
|
16
10
|
from zrb.task.any_task_event_handler import (
|
17
11
|
OnFailed,
|
@@ -88,7 +82,7 @@ class PathChecker(Checker):
|
|
88
82
|
self._path = path
|
89
83
|
self._ignored_path = ignored_path
|
90
84
|
self._rendered_path: str = ""
|
91
|
-
self._rendered_ignored_paths:
|
85
|
+
self._rendered_ignored_paths: list[str] = []
|
92
86
|
|
93
87
|
def copy(self) -> TPathChecker:
|
94
88
|
return super().copy()
|
@@ -120,7 +114,7 @@ class PathChecker(Checker):
|
|
120
114
|
]
|
121
115
|
return await super().run(*args, **kwargs)
|
122
116
|
|
123
|
-
def _get_rendered_ignored_paths(self) ->
|
117
|
+
def _get_rendered_ignored_paths(self) -> list[str]:
|
124
118
|
if isinstance(self._ignored_path, str):
|
125
119
|
return [self.render_str(self._ignored_path)]
|
126
120
|
return [self.render_str(ignored_path) for ignored_path in self._ignored_path]
|
zrb/task/path_watcher.py
CHANGED
@@ -1,20 +1,12 @@
|
|
1
1
|
import os
|
2
|
+
from collections.abc import Callable, Iterable, Mapping
|
3
|
+
from typing import Any, Optional, TypeVar, Union
|
2
4
|
|
3
5
|
from zrb.helper.accessories.color import colored
|
4
6
|
from zrb.helper.file.match import get_file_names
|
5
7
|
from zrb.helper.log import logger
|
6
8
|
from zrb.helper.typecheck import typechecked
|
7
|
-
from zrb.helper.typing import
|
8
|
-
Any,
|
9
|
-
Callable,
|
10
|
-
Iterable,
|
11
|
-
JinjaTemplate,
|
12
|
-
List,
|
13
|
-
Mapping,
|
14
|
-
Optional,
|
15
|
-
TypeVar,
|
16
|
-
Union,
|
17
|
-
)
|
9
|
+
from zrb.helper.typing import JinjaTemplate
|
18
10
|
from zrb.task.any_task import AnyTask
|
19
11
|
from zrb.task.any_task_event_handler import (
|
20
12
|
OnFailed,
|
@@ -108,7 +100,7 @@ class PathWatcher(Watcher):
|
|
108
100
|
self._watch_modified_files = watch_modified_files
|
109
101
|
self._watch_deleted_files = watch_deleted_files
|
110
102
|
self._rendered_path: str = ""
|
111
|
-
self._rendered_ignored_paths:
|
103
|
+
self._rendered_ignored_paths: list[str] = []
|
112
104
|
|
113
105
|
def copy(self) -> TPathWatcher:
|
114
106
|
return super().copy()
|
@@ -143,7 +135,7 @@ class PathWatcher(Watcher):
|
|
143
135
|
self.__init_times[identifier] = self._get_mod_times()
|
144
136
|
return await super().run(*args, **kwargs)
|
145
137
|
|
146
|
-
def _get_rendered_ignored_paths(self) ->
|
138
|
+
def _get_rendered_ignored_paths(self) -> list[str]:
|
147
139
|
if isinstance(self._ignored_path, str):
|
148
140
|
return [self.render_str(self._ignored_path)]
|
149
141
|
return [self.render_str(ignored_path) for ignored_path in self._ignored_path]
|
zrb/task/port_checker.py
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
import socket
|
2
|
+
from collections.abc import Callable, Iterable
|
3
|
+
from typing import Any, Optional, TypeVar, Union
|
2
4
|
|
3
5
|
from zrb.helper.accessories.color import colored
|
4
6
|
from zrb.helper.log import logger
|
5
7
|
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.typing import
|
7
|
-
Any,
|
8
|
-
Callable,
|
9
|
-
Iterable,
|
10
|
-
JinjaTemplate,
|
11
|
-
Optional,
|
12
|
-
TypeVar,
|
13
|
-
Union,
|
14
|
-
)
|
8
|
+
from zrb.helper.typing import JinjaTemplate
|
15
9
|
from zrb.task.any_task import AnyTask
|
16
10
|
from zrb.task.any_task_event_handler import (
|
17
11
|
OnFailed,
|
zrb/task/recurring_task.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import asyncio
|
2
2
|
import copy
|
3
|
+
from collections.abc import Callable, Iterable, Mapping
|
4
|
+
from typing import Any, Optional, Union
|
3
5
|
|
4
6
|
from zrb.helper.accessories.color import colored
|
5
7
|
from zrb.helper.accessories.name import get_random_name
|
6
8
|
from zrb.helper.log import logger
|
7
9
|
from zrb.helper.typecheck import typechecked
|
8
|
-
from zrb.helper.typing import Any, Callable, Iterable, List, Mapping, Optional, Union
|
9
10
|
from zrb.task.any_task import AnyTask
|
10
11
|
from zrb.task.any_task_event_handler import (
|
11
12
|
OnFailed,
|
@@ -29,7 +30,7 @@ class RunConfig:
|
|
29
30
|
def __init__(
|
30
31
|
self,
|
31
32
|
fn: Callable[..., Any],
|
32
|
-
args:
|
33
|
+
args: list[Any],
|
33
34
|
kwargs: Mapping[Any, Any],
|
34
35
|
execution_id: str,
|
35
36
|
):
|
@@ -112,8 +113,8 @@ class RecurringTask(BaseTask):
|
|
112
113
|
should_execute=should_execute,
|
113
114
|
return_upstream_result=return_upstream_result,
|
114
115
|
)
|
115
|
-
self._triggers:
|
116
|
-
self._run_configs:
|
116
|
+
self._triggers: list[AnyTask] = [trigger.copy() for trigger in triggers]
|
117
|
+
self._run_configs: list[RunConfig] = []
|
117
118
|
self._single_execution = single_execution
|
118
119
|
self.print_err("Deprecated, please use Server instead")
|
119
120
|
|
zrb/task/remote_cmd_task.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
import os
|
2
2
|
import pathlib
|
3
|
+
from collections.abc import Callable, Iterable
|
4
|
+
from typing import Any, Optional, Union
|
3
5
|
|
4
6
|
from zrb.helper.accessories.color import colored
|
5
7
|
from zrb.helper.log import logger
|
6
8
|
from zrb.helper.typecheck import typechecked
|
7
|
-
from zrb.helper.typing import Any, Callable, Iterable, Optional, Union
|
8
9
|
from zrb.task.any_task import AnyTask
|
9
10
|
from zrb.task.any_task_event_handler import (
|
10
11
|
OnFailed,
|
zrb/task/resource_maker.py
CHANGED
@@ -1,18 +1,11 @@
|
|
1
|
+
from collections.abc import Callable, Iterable, Mapping
|
2
|
+
from typing import Any, Optional, TypeVar, Union
|
3
|
+
|
1
4
|
from zrb.helper.accessories.color import colored
|
2
5
|
from zrb.helper.file.copy_tree import copy_tree
|
3
6
|
from zrb.helper.log import logger
|
4
7
|
from zrb.helper.typecheck import typechecked
|
5
|
-
from zrb.helper.typing import
|
6
|
-
Any,
|
7
|
-
Callable,
|
8
|
-
Iterable,
|
9
|
-
JinjaTemplate,
|
10
|
-
List,
|
11
|
-
Mapping,
|
12
|
-
Optional,
|
13
|
-
TypeVar,
|
14
|
-
Union,
|
15
|
-
)
|
8
|
+
from zrb.helper.typing import JinjaTemplate
|
16
9
|
from zrb.helper.util import (
|
17
10
|
to_camel_case,
|
18
11
|
to_capitalized_human_readable,
|
@@ -44,7 +37,7 @@ ReplacementMutator = Callable[[AnyTask, Replacement], Replacement]
|
|
44
37
|
TResourceMaker = TypeVar("TResourceMaker", bound="ResourceMaker")
|
45
38
|
|
46
39
|
|
47
|
-
def get_default_resource_skip_parsing() ->
|
40
|
+
def get_default_resource_skip_parsing() -> list[str]:
|
48
41
|
return [
|
49
42
|
"*.mp3",
|
50
43
|
"*.pdf",
|
@@ -63,7 +56,7 @@ def get_default_resource_skip_parsing() -> List[str]:
|
|
63
56
|
]
|
64
57
|
|
65
58
|
|
66
|
-
def get_default_resource_excludes() ->
|
59
|
+
def get_default_resource_excludes() -> list[str]:
|
67
60
|
return [
|
68
61
|
"*/.git",
|
69
62
|
"*/__pycache__",
|
zrb/task/rsync_task.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
import os
|
2
2
|
import pathlib
|
3
|
+
from collections.abc import Callable, Iterable
|
4
|
+
from typing import Any, Optional, Union
|
3
5
|
|
4
6
|
from zrb.helper.accessories.color import colored
|
5
7
|
from zrb.helper.log import logger
|
6
8
|
from zrb.helper.typecheck import typechecked
|
7
|
-
from zrb.helper.typing import
|
9
|
+
from zrb.helper.typing import JinjaTemplate
|
8
10
|
from zrb.task.any_task import AnyTask
|
9
11
|
from zrb.task.any_task_event_handler import (
|
10
12
|
OnFailed,
|
zrb/task/server.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import asyncio
|
2
2
|
import copy
|
3
|
+
from collections.abc import Callable, Iterable, Mapping
|
4
|
+
from typing import Any, Optional, Union
|
3
5
|
|
4
6
|
from zrb.helper.accessories.color import colored
|
5
7
|
from zrb.helper.accessories.name import get_random_name
|
6
8
|
from zrb.helper.log import logger
|
7
9
|
from zrb.helper.typecheck import typechecked
|
8
|
-
from zrb.helper.typing import Any, Callable, Iterable, List, Mapping, Optional, Union
|
9
10
|
from zrb.helper.util import to_kebab_case
|
10
11
|
from zrb.task.any_task import AnyTask
|
11
12
|
from zrb.task.any_task_event_handler import (
|
@@ -31,32 +32,32 @@ logger.debug(colored("Loading zrb.task.server", attrs=["dark"]))
|
|
31
32
|
class Controller:
|
32
33
|
def __init__(
|
33
34
|
self,
|
34
|
-
trigger: Union[AnyTask,
|
35
|
-
action: Union[AnyTask,
|
35
|
+
trigger: Union[AnyTask, list[AnyTask]],
|
36
|
+
action: Union[AnyTask, list[AnyTask]],
|
36
37
|
name: Optional[str] = None,
|
37
38
|
):
|
38
39
|
self._name = get_random_name() if name is None else name
|
39
40
|
self._triggers = self._to_task_list(trigger)
|
40
41
|
self._actions = self._to_task_list(action)
|
41
|
-
self._args:
|
42
|
+
self._args: list[Any] = []
|
42
43
|
self._kwargs: Mapping[str, Any] = {}
|
43
|
-
self._inputs:
|
44
|
-
self._envs:
|
45
|
-
self._env_files:
|
44
|
+
self._inputs: list[AnyInput] = []
|
45
|
+
self._envs: list[Env] = []
|
46
|
+
self._env_files: list[EnvFile] = []
|
46
47
|
|
47
|
-
def set_args(self, args:
|
48
|
+
def set_args(self, args: list[Any]):
|
48
49
|
self._args = args
|
49
50
|
|
50
51
|
def set_kwargs(self, kwargs: Mapping[str, Any]):
|
51
52
|
self._kwargs = kwargs
|
52
53
|
|
53
|
-
def set_inputs(self, inputs:
|
54
|
+
def set_inputs(self, inputs: list[AnyInput]):
|
54
55
|
self._inputs = inputs
|
55
56
|
|
56
|
-
def set_envs(self, envs:
|
57
|
+
def set_envs(self, envs: list[Env]):
|
57
58
|
self._envs = envs
|
58
59
|
|
59
|
-
def set_env_files(self, env_files:
|
60
|
+
def set_env_files(self, env_files: list[EnvFile]):
|
60
61
|
self._env_files = env_files
|
61
62
|
|
62
63
|
def get_original_env_files(self) -> Iterable[EnvFile]:
|
@@ -93,7 +94,7 @@ class Controller:
|
|
93
94
|
|
94
95
|
return fn
|
95
96
|
|
96
|
-
def _to_task_list(self, tasks: Union[AnyTask,
|
97
|
+
def _to_task_list(self, tasks: Union[AnyTask, list[AnyTask]]) -> list[AnyTask]:
|
97
98
|
if isinstance(tasks, AnyTask):
|
98
99
|
return [tasks.copy()]
|
99
100
|
return [task.copy() for task in tasks]
|
zrb/task/time_watcher.py
CHANGED
@@ -1,21 +1,14 @@
|
|
1
1
|
import asyncio
|
2
2
|
import datetime
|
3
|
+
from collections.abc import Callable, Iterable, Mapping
|
4
|
+
from typing import Any, Optional, TypeVar, Union
|
3
5
|
|
4
6
|
import croniter
|
5
7
|
|
6
8
|
from zrb.helper.accessories.color import colored
|
7
9
|
from zrb.helper.log import logger
|
8
10
|
from zrb.helper.typecheck import typechecked
|
9
|
-
from zrb.helper.typing import
|
10
|
-
Any,
|
11
|
-
Callable,
|
12
|
-
Iterable,
|
13
|
-
JinjaTemplate,
|
14
|
-
Mapping,
|
15
|
-
Optional,
|
16
|
-
TypeVar,
|
17
|
-
Union,
|
18
|
-
)
|
11
|
+
from zrb.helper.typing import JinjaTemplate
|
19
12
|
from zrb.task.any_task import AnyTask
|
20
13
|
from zrb.task.any_task_event_handler import (
|
21
14
|
OnFailed,
|
zrb/task/watcher.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import asyncio
|
2
|
+
from collections.abc import Callable, Iterable
|
3
|
+
from typing import Any, Optional, Union
|
2
4
|
|
3
5
|
from zrb.helper.accessories.color import colored
|
4
6
|
from zrb.helper.accessories.name import get_random_name
|
5
7
|
from zrb.helper.callable import run_async
|
6
8
|
from zrb.helper.log import logger
|
7
9
|
from zrb.helper.typecheck import typechecked
|
8
|
-
from zrb.helper.typing import Any, Callable, Iterable, Optional, Union
|
9
10
|
from zrb.task.any_task import AnyTask
|
10
11
|
from zrb.task.any_task_event_handler import (
|
11
12
|
OnFailed,
|
zrb/task/wiki_task.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import os
|
2
|
+
from collections.abc import Callable, Iterable, Mapping
|
3
|
+
from typing import Any, Optional, Union
|
2
4
|
|
3
5
|
from zrb.action.runner import Runner
|
4
6
|
from zrb.helper.accessories.color import colored
|
5
7
|
from zrb.helper.log import logger
|
6
8
|
from zrb.helper.task import show_lines
|
7
9
|
from zrb.helper.typecheck import typechecked
|
8
|
-
from zrb.helper.typing import Any, Callable, Iterable, List, Mapping, Optional, Union
|
9
10
|
from zrb.helper.util import to_human_readable
|
10
11
|
from zrb.task.any_task import AnyTask
|
11
12
|
from zrb.task.any_task_event_handler import (
|
@@ -49,7 +50,7 @@ def create_wiki_tasks(
|
|
49
50
|
):
|
50
51
|
abs_directory = os.path.abspath(directory)
|
51
52
|
directory_structure = _get_directory_structure(abs_directory)
|
52
|
-
tasks:
|
53
|
+
tasks: list[AnyTask] = []
|
53
54
|
for file_name in directory_structure["files"]:
|
54
55
|
if not file_name.endswith(".md"):
|
55
56
|
continue
|
@@ -120,7 +121,7 @@ def _create_function(directory: str, file_name: str) -> Callable[..., Any]:
|
|
120
121
|
return fn
|
121
122
|
|
122
123
|
|
123
|
-
def _get_directory_structure(path) -> Mapping[str,
|
124
|
+
def _get_directory_structure(path) -> Mapping[str, list[str]]:
|
124
125
|
contents = {"files": [], "dirs": []}
|
125
126
|
for item in os.listdir(path):
|
126
127
|
full_path = os.path.join(path, item)
|