qwak-sdk 0.5.102__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.
- qwak_sdk/__init__.py +9 -0
- qwak_sdk/cli.py +79 -0
- qwak_sdk/commands/__init__.py +0 -0
- qwak_sdk/commands/_logic/__init__.py +0 -0
- qwak_sdk/commands/_logic/tools.py +6 -0
- qwak_sdk/commands/admin/__init__.py +0 -0
- qwak_sdk/commands/admin/admin_commands_group.py +17 -0
- qwak_sdk/commands/admin/apikeys/__init__.py +0 -0
- qwak_sdk/commands/admin/apikeys/api_keys_commands_group.py +17 -0
- qwak_sdk/commands/admin/apikeys/generate/__init__.py +0 -0
- qwak_sdk/commands/admin/apikeys/generate/_logic.py +21 -0
- qwak_sdk/commands/admin/apikeys/generate/ui.py +45 -0
- qwak_sdk/commands/admin/apikeys/revoke/__init__.py +0 -0
- qwak_sdk/commands/admin/apikeys/revoke/_logic.py +22 -0
- qwak_sdk/commands/admin/apikeys/revoke/ui.py +31 -0
- qwak_sdk/commands/alerts/__init__.py +0 -0
- qwak_sdk/commands/alerts/alerts_commnad_group.py +18 -0
- qwak_sdk/commands/alerts/delete/__init__.py +0 -0
- qwak_sdk/commands/alerts/delete/_logic.py +5 -0
- qwak_sdk/commands/alerts/delete/ui.py +10 -0
- qwak_sdk/commands/alerts/list/__init__.py +0 -0
- qwak_sdk/commands/alerts/list/_logic.py +23 -0
- qwak_sdk/commands/alerts/list/ui.py +17 -0
- qwak_sdk/commands/alerts/register/__init__.py +0 -0
- qwak_sdk/commands/alerts/register/_logic.py +72 -0
- qwak_sdk/commands/alerts/register/ui.py +30 -0
- qwak_sdk/commands/audience/__init__.py +0 -0
- qwak_sdk/commands/audience/_logic/__init__.py +0 -0
- qwak_sdk/commands/audience/_logic/config/__init__.py +0 -0
- qwak_sdk/commands/audience/_logic/config/config_base.py +15 -0
- qwak_sdk/commands/audience/_logic/config/parser.py +30 -0
- qwak_sdk/commands/audience/_logic/config/v1/__init__.py +0 -0
- qwak_sdk/commands/audience/_logic/config/v1/audience_config.py +26 -0
- qwak_sdk/commands/audience/_logic/config/v1/conditions_config.py +59 -0
- qwak_sdk/commands/audience/_logic/config/v1/config_v1.py +23 -0
- qwak_sdk/commands/audience/_logic/config/v1/route_config.py +15 -0
- qwak_sdk/commands/audience/_logic/config/v1/spec.py +9 -0
- qwak_sdk/commands/audience/audience_api_dump.py +86 -0
- qwak_sdk/commands/audience/audience_commands_group.py +30 -0
- qwak_sdk/commands/audience/create/__init__.py +0 -0
- qwak_sdk/commands/audience/create/logic.py +41 -0
- qwak_sdk/commands/audience/create/ui.py +21 -0
- qwak_sdk/commands/audience/delete/__init__.py +0 -0
- qwak_sdk/commands/audience/delete/logic.py +13 -0
- qwak_sdk/commands/audience/delete/ui.py +17 -0
- qwak_sdk/commands/audience/get/__init__.py +0 -0
- qwak_sdk/commands/audience/get/logic.py +14 -0
- qwak_sdk/commands/audience/get/ui.py +25 -0
- qwak_sdk/commands/audience/list/__init__.py +0 -0
- qwak_sdk/commands/audience/list/logic.py +16 -0
- qwak_sdk/commands/audience/list/ui.py +26 -0
- qwak_sdk/commands/audience/update/__init__.py +0 -0
- qwak_sdk/commands/audience/update/logic.py +37 -0
- qwak_sdk/commands/audience/update/ui.py +26 -0
- qwak_sdk/commands/auto_scalling/__init__.py +0 -0
- qwak_sdk/commands/auto_scalling/_logic/__init__.py +0 -0
- qwak_sdk/commands/auto_scalling/_logic/config/__init__.py +3 -0
- qwak_sdk/commands/auto_scalling/_logic/config/config.py +152 -0
- qwak_sdk/commands/auto_scalling/_logic/config/parser.py +21 -0
- qwak_sdk/commands/auto_scalling/attach/__init__.py +0 -0
- qwak_sdk/commands/auto_scalling/attach/_logic.py +43 -0
- qwak_sdk/commands/auto_scalling/attach/ui.py +21 -0
- qwak_sdk/commands/auto_scalling/autoscaling_commands_group.py +15 -0
- qwak_sdk/commands/automations/__init__.py +0 -0
- qwak_sdk/commands/automations/automations_commands_group.py +30 -0
- qwak_sdk/commands/automations/delete/__init__.py +0 -0
- qwak_sdk/commands/automations/delete/_logic.py +6 -0
- qwak_sdk/commands/automations/delete/ui.py +23 -0
- qwak_sdk/commands/automations/executions/__init__.py +0 -0
- qwak_sdk/commands/automations/executions/executions_commands_group.py +14 -0
- qwak_sdk/commands/automations/executions/list/__init__.py +0 -0
- qwak_sdk/commands/automations/executions/list/_logic.py +8 -0
- qwak_sdk/commands/automations/executions/list/ui.py +25 -0
- qwak_sdk/commands/automations/list/__init__.py +0 -0
- qwak_sdk/commands/automations/list/_logic.py +36 -0
- qwak_sdk/commands/automations/list/ui.py +21 -0
- qwak_sdk/commands/automations/register/__init__.py +0 -0
- qwak_sdk/commands/automations/register/_logic.py +43 -0
- qwak_sdk/commands/automations/register/ui.py +44 -0
- qwak_sdk/commands/feature_store/__init__.py +0 -0
- qwak_sdk/commands/feature_store/backfill/__init__.py +0 -0
- qwak_sdk/commands/feature_store/backfill/_logic.py +140 -0
- qwak_sdk/commands/feature_store/backfill/streaming/__init__.py +0 -0
- qwak_sdk/commands/feature_store/backfill/streaming/_logic.py +50 -0
- qwak_sdk/commands/feature_store/backfill/streaming/ui.py +67 -0
- qwak_sdk/commands/feature_store/backfill/ui.py +146 -0
- qwak_sdk/commands/feature_store/delete/__init__.py +0 -0
- qwak_sdk/commands/feature_store/delete/_logic.py +104 -0
- qwak_sdk/commands/feature_store/delete/ui.py +40 -0
- qwak_sdk/commands/feature_store/execution/__init__.py +0 -0
- qwak_sdk/commands/feature_store/execution/ui.py +19 -0
- qwak_sdk/commands/feature_store/feature_store_command_group.py +29 -0
- qwak_sdk/commands/feature_store/list/__init__.py +0 -0
- qwak_sdk/commands/feature_store/list/ui.py +140 -0
- qwak_sdk/commands/feature_store/pause/__init__.py +0 -0
- qwak_sdk/commands/feature_store/pause/ui.py +18 -0
- qwak_sdk/commands/feature_store/register/__init__.py +0 -0
- qwak_sdk/commands/feature_store/register/_logic.py +367 -0
- qwak_sdk/commands/feature_store/register/ui.py +111 -0
- qwak_sdk/commands/feature_store/resume/__init__.py +0 -0
- qwak_sdk/commands/feature_store/resume/ui.py +18 -0
- qwak_sdk/commands/feature_store/trigger/__init__.py +0 -0
- qwak_sdk/commands/feature_store/trigger/ui.py +39 -0
- qwak_sdk/commands/models/__init__.py +0 -0
- qwak_sdk/commands/models/build/__init__.py +0 -0
- qwak_sdk/commands/models/build/_logic/__init__.py +0 -0
- qwak_sdk/commands/models/build/_logic/build_steps.py +42 -0
- qwak_sdk/commands/models/build/_logic/client_logs/__init__.py +0 -0
- qwak_sdk/commands/models/build/_logic/client_logs/cli_phase_run_handler.py +123 -0
- qwak_sdk/commands/models/build/_logic/client_logs/cli_trigger_build_logger.py +19 -0
- qwak_sdk/commands/models/build/_logic/client_logs/logger.py +88 -0
- qwak_sdk/commands/models/build/_logic/client_logs/messages.py +36 -0
- qwak_sdk/commands/models/build/_logic/client_logs/spinner.py +14 -0
- qwak_sdk/commands/models/build/_logic/client_logs/trigger_build_logger.py +54 -0
- qwak_sdk/commands/models/build/_logic/client_logs/utils.py +12 -0
- qwak_sdk/commands/models/build/_logic/phase/__init__.py +0 -0
- qwak_sdk/commands/models/build/_logic/phase/a_fetch_model_code/__init__.py +20 -0
- qwak_sdk/commands/models/build/_logic/phase/a_fetch_model_code/get_sdk_version_step.py +14 -0
- qwak_sdk/commands/models/build/_logic/phase/b_remote_register_qwak_build/__init__.py +16 -0
- qwak_sdk/commands/models/build/_logic/phase/c_deploy/__init__.py +6 -0
- qwak_sdk/commands/models/build/_logic/phase/c_deploy/build_polling_status.py +55 -0
- qwak_sdk/commands/models/build/_logic/phase/c_deploy/deploy_build.py +61 -0
- qwak_sdk/commands/models/build/_logic/util/__init__.py +0 -0
- qwak_sdk/commands/models/build/_logic/util/protobuf_factory.py +45 -0
- qwak_sdk/commands/models/build/_logic/util/step_decorator.py +60 -0
- qwak_sdk/commands/models/build/_logic/util/text.py +9 -0
- qwak_sdk/commands/models/build/_logic/wait_until_finished.py +27 -0
- qwak_sdk/commands/models/build/ui.py +337 -0
- qwak_sdk/commands/models/builds/__init__.py +0 -0
- qwak_sdk/commands/models/builds/builds_commands_group.py +16 -0
- qwak_sdk/commands/models/builds/cancel/__init__.py +0 -0
- qwak_sdk/commands/models/builds/cancel/_logic.py +5 -0
- qwak_sdk/commands/models/builds/cancel/ui.py +15 -0
- qwak_sdk/commands/models/builds/logs/__init__.py +0 -0
- qwak_sdk/commands/models/builds/logs/ui.py +35 -0
- qwak_sdk/commands/models/builds/status/__init__.py +0 -0
- qwak_sdk/commands/models/builds/status/_logic.py +6 -0
- qwak_sdk/commands/models/builds/status/ui.py +39 -0
- qwak_sdk/commands/models/create/__init__.py +0 -0
- qwak_sdk/commands/models/create/_logic.py +36 -0
- qwak_sdk/commands/models/create/ui.py +43 -0
- qwak_sdk/commands/models/delete/__init__.py +0 -0
- qwak_sdk/commands/models/delete/_logic.py +5 -0
- qwak_sdk/commands/models/delete/ui.py +25 -0
- qwak_sdk/commands/models/deployments/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/deploy/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/deploy/_logic/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/deploy/_logic/advance_deployment_options_handler.py +31 -0
- qwak_sdk/commands/models/deployments/deploy/_logic/base_deploy_executor.py +68 -0
- qwak_sdk/commands/models/deployments/deploy/_logic/deploy_config.py +261 -0
- qwak_sdk/commands/models/deployments/deploy/_logic/deployment.py +405 -0
- qwak_sdk/commands/models/deployments/deploy/_logic/deployment_message_helpers.py +114 -0
- qwak_sdk/commands/models/deployments/deploy/_logic/deployment_response_handler.py +156 -0
- qwak_sdk/commands/models/deployments/deploy/_logic/deployment_size_mapper.py +96 -0
- qwak_sdk/commands/models/deployments/deploy/_logic/get_latest_successful_build.py +28 -0
- qwak_sdk/commands/models/deployments/deploy/_logic/local_deployment.py +193 -0
- qwak_sdk/commands/models/deployments/deploy/batch/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/deploy/batch/_logic/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/deploy/batch/_logic/advanced_deployment_mapper.py +15 -0
- qwak_sdk/commands/models/deployments/deploy/batch/_logic/deploy_executor.py +24 -0
- qwak_sdk/commands/models/deployments/deploy/batch/ui.py +126 -0
- qwak_sdk/commands/models/deployments/deploy/deploy_commands_group.py +19 -0
- qwak_sdk/commands/models/deployments/deploy/realtime/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/deploy/realtime/_logic/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/deploy/realtime/_logic/advanced_deployment_mapper.py +21 -0
- qwak_sdk/commands/models/deployments/deploy/realtime/_logic/deploy_executor.py +24 -0
- qwak_sdk/commands/models/deployments/deploy/realtime/_logic/serving_strategy_mapper.py +75 -0
- qwak_sdk/commands/models/deployments/deploy/realtime/ui.py +209 -0
- qwak_sdk/commands/models/deployments/deploy/streaming/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/deploy/streaming/_logic/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/deploy/streaming/_logic/deploy_executor.py +24 -0
- qwak_sdk/commands/models/deployments/deploy/streaming/_logic/serving_strategy_mapper.py +38 -0
- qwak_sdk/commands/models/deployments/deploy/streaming/ui.py +213 -0
- qwak_sdk/commands/models/deployments/undeploy/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/undeploy/_logic/__init__.py +0 -0
- qwak_sdk/commands/models/deployments/undeploy/_logic/request_undeploy.py +249 -0
- qwak_sdk/commands/models/deployments/undeploy/ui.py +72 -0
- qwak_sdk/commands/models/describe/__init__.py +0 -0
- qwak_sdk/commands/models/describe/_logic.py +169 -0
- qwak_sdk/commands/models/describe/ui.py +35 -0
- qwak_sdk/commands/models/executions/__init__.py +0 -0
- qwak_sdk/commands/models/executions/cancel/__init__.py +0 -0
- qwak_sdk/commands/models/executions/cancel/_logic.py +9 -0
- qwak_sdk/commands/models/executions/cancel/ui.py +27 -0
- qwak_sdk/commands/models/executions/execution_commands_group.py +24 -0
- qwak_sdk/commands/models/executions/report/__init__.py +0 -0
- qwak_sdk/commands/models/executions/report/_logic.py +14 -0
- qwak_sdk/commands/models/executions/report/ui.py +43 -0
- qwak_sdk/commands/models/executions/start/__init__.py +0 -0
- qwak_sdk/commands/models/executions/start/_logic.py +81 -0
- qwak_sdk/commands/models/executions/start/ui.py +208 -0
- qwak_sdk/commands/models/executions/status/__init__.py +0 -0
- qwak_sdk/commands/models/executions/status/_logic.py +13 -0
- qwak_sdk/commands/models/executions/status/ui.py +27 -0
- qwak_sdk/commands/models/init/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/initialize_model_structure.py +40 -0
- qwak_sdk/commands/models/init/_logic/template/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/churn/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/churn/cookiecutter.json +3 -0
- qwak_sdk/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/main/__init__.py +5 -0
- qwak_sdk/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/main/conda.yml +10 -0
- qwak_sdk/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/main/data.csv +1001 -0
- qwak_sdk/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/main/model.py +95 -0
- qwak_sdk/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/tests/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/tests/it/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/tests/it/test_churn.py +32 -0
- qwak_sdk/commands/models/init/_logic/template/credit_risk/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/credit_risk/cookiecutter.json +3 -0
- qwak_sdk/commands/models/init/_logic/template/credit_risk/{{cookiecutter.model_directory}}/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/credit_risk/{{cookiecutter.model_directory}}/main/__init__.py +5 -0
- qwak_sdk/commands/models/init/_logic/template/credit_risk/{{cookiecutter.model_directory}}/main/conda.yml +11 -0
- qwak_sdk/commands/models/init/_logic/template/credit_risk/{{cookiecutter.model_directory}}/main/data.csv +1001 -0
- qwak_sdk/commands/models/init/_logic/template/credit_risk/{{cookiecutter.model_directory}}/main/model.py +108 -0
- qwak_sdk/commands/models/init/_logic/template/general/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/general/cookiecutter.json +6 -0
- qwak_sdk/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/{{cookiecutter.main_directory}}/__init__.py +5 -0
- qwak_sdk/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/{{cookiecutter.main_directory}}/conda.yml +8 -0
- qwak_sdk/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/{{cookiecutter.main_directory}}/model.py +66 -0
- qwak_sdk/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/{{cookiecutter.test_directory}}/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/{{cookiecutter.test_directory}}/test_qwak_model.py +5 -0
- qwak_sdk/commands/models/init/_logic/template/titanic/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/titanic/cookiecutter.json +3 -0
- qwak_sdk/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/main/__init__.py +5 -0
- qwak_sdk/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/main/conda.yml +11 -0
- qwak_sdk/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/main/model.py +98 -0
- qwak_sdk/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/tests/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/tests/it/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/tests/it/test_titanic.py +24 -0
- qwak_sdk/commands/models/init/_logic/template/titanic_poetry/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/titanic_poetry/cookiecutter.json +3 -0
- qwak_sdk/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/main/__init__.py +5 -0
- qwak_sdk/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/main/model.py +98 -0
- qwak_sdk/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/main/pyproject.toml +20 -0
- qwak_sdk/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/tests/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/tests/it/__init__.py +0 -0
- qwak_sdk/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/tests/it/test_titanic.py +25 -0
- qwak_sdk/commands/models/init/ui.py +61 -0
- qwak_sdk/commands/models/list/__init__.py +0 -0
- qwak_sdk/commands/models/list/_logic.py +5 -0
- qwak_sdk/commands/models/list/ui.py +40 -0
- qwak_sdk/commands/models/list_models/__init__.py +0 -0
- qwak_sdk/commands/models/list_models/_logic.py +5 -0
- qwak_sdk/commands/models/list_models/ui.py +60 -0
- qwak_sdk/commands/models/metadata/__init__.py +0 -0
- qwak_sdk/commands/models/metadata/_logic.py +5 -0
- qwak_sdk/commands/models/metadata/ui.py +60 -0
- qwak_sdk/commands/models/models_command_group.py +44 -0
- qwak_sdk/commands/models/runtime/__init__.py +0 -0
- qwak_sdk/commands/models/runtime/logs/__init__.py +0 -0
- qwak_sdk/commands/models/runtime/logs/ui.py +63 -0
- qwak_sdk/commands/models/runtime/runtime_commands_group.py +17 -0
- qwak_sdk/commands/models/runtime/update/__init__.py +0 -0
- qwak_sdk/commands/models/runtime/update/_logic.py +9 -0
- qwak_sdk/commands/models/runtime/update/ui.py +15 -0
- qwak_sdk/commands/projects/__init__.py +0 -0
- qwak_sdk/commands/projects/create/__init__.py +0 -0
- qwak_sdk/commands/projects/create/_logic.py +9 -0
- qwak_sdk/commands/projects/create/ui.py +68 -0
- qwak_sdk/commands/projects/delete/__init__.py +0 -0
- qwak_sdk/commands/projects/delete/_logic.py +6 -0
- qwak_sdk/commands/projects/delete/ui.py +24 -0
- qwak_sdk/commands/projects/list/__init__.py +0 -0
- qwak_sdk/commands/projects/list/_logic.py +6 -0
- qwak_sdk/commands/projects/list/ui.py +45 -0
- qwak_sdk/commands/projects/projects_command_group.py +19 -0
- qwak_sdk/commands/secrets/__init__.py +0 -0
- qwak_sdk/commands/secrets/delete/__init__.py +0 -0
- qwak_sdk/commands/secrets/delete/_logic.py +5 -0
- qwak_sdk/commands/secrets/delete/ui.py +21 -0
- qwak_sdk/commands/secrets/get/__init__.py +0 -0
- qwak_sdk/commands/secrets/get/_logic.py +5 -0
- qwak_sdk/commands/secrets/get/ui.py +17 -0
- qwak_sdk/commands/secrets/secrets_commands_group.py +19 -0
- qwak_sdk/commands/secrets/set/__init__.py +0 -0
- qwak_sdk/commands/secrets/set/_logic.py +5 -0
- qwak_sdk/commands/secrets/set/ui.py +16 -0
- qwak_sdk/commands/ui_tools.py +18 -0
- qwak_sdk/commands/workspaces/__init__.py +0 -0
- qwak_sdk/commands/workspaces/_logic/__init__.py +0 -0
- qwak_sdk/commands/workspaces/_logic/tools.py +44 -0
- qwak_sdk/commands/workspaces/_logic/workspace_validations.py +41 -0
- qwak_sdk/commands/workspaces/config/__init__.py +0 -0
- qwak_sdk/commands/workspaces/config/workspace_config.py +35 -0
- qwak_sdk/commands/workspaces/create/__init__.py +0 -0
- qwak_sdk/commands/workspaces/create/_logic.py +54 -0
- qwak_sdk/commands/workspaces/create/ui.py +48 -0
- qwak_sdk/commands/workspaces/delete/__init__.py +0 -0
- qwak_sdk/commands/workspaces/delete/_logic.py +30 -0
- qwak_sdk/commands/workspaces/delete/ui.py +23 -0
- qwak_sdk/commands/workspaces/start/__init__.py +0 -0
- qwak_sdk/commands/workspaces/start/_logic.py +30 -0
- qwak_sdk/commands/workspaces/start/ui.py +23 -0
- qwak_sdk/commands/workspaces/stop/__init__.py +0 -0
- qwak_sdk/commands/workspaces/stop/_logic.py +30 -0
- qwak_sdk/commands/workspaces/stop/ui.py +23 -0
- qwak_sdk/commands/workspaces/update/__init__.py +0 -0
- qwak_sdk/commands/workspaces/update/_logic.py +82 -0
- qwak_sdk/commands/workspaces/update/ui.py +57 -0
- qwak_sdk/commands/workspaces/workspaces_commands_group.py +23 -0
- qwak_sdk/exceptions/__init__.py +11 -0
- qwak_sdk/exceptions/qwak_command_exception.py +2 -0
- qwak_sdk/exceptions/qwak_deploy_new_build_failed.py +5 -0
- qwak_sdk/exceptions/qwak_resource_not_found.py +2 -0
- qwak_sdk/inner/__init__.py +0 -0
- qwak_sdk/inner/file_registry.py +98 -0
- qwak_sdk/inner/tools/__init__.py +0 -0
- qwak_sdk/inner/tools/cli_tools.py +220 -0
- qwak_sdk/inner/tools/config_handler.py +27 -0
- qwak_sdk/inner/tools/dataclasses_utils.py +21 -0
- qwak_sdk/inner/tools/logger/__init__.py +3 -0
- qwak_sdk/inner/tools/logger/logger.py +269 -0
- qwak_sdk/inner/tools/logger/logging.yml +79 -0
- qwak_sdk/inner/tools/tracking.py +47 -0
- qwak_sdk/main.py +9 -0
- qwak_sdk/tools/__init__.py +0 -0
- qwak_sdk/tools/colors.py +13 -0
- qwak_sdk/tools/files.py +63 -0
- qwak_sdk/tools/log_handling.py +159 -0
- qwak_sdk/tools/utils.py +42 -0
- qwak_sdk-0.5.102.dist-info/METADATA +51 -0
- qwak_sdk-0.5.102.dist-info/RECORD +328 -0
- qwak_sdk-0.5.102.dist-info/WHEEL +4 -0
- qwak_sdk-0.5.102.dist-info/entry_points.txt +3 -0
qwak_sdk/__init__.py
ADDED
qwak_sdk/cli.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
from packaging import version
|
|
5
|
+
from qwak.inner.di_configuration import UserAccountConfiguration
|
|
6
|
+
from qwak.inner.di_configuration.account import UserAccount
|
|
7
|
+
|
|
8
|
+
from qwak_sdk import __version__ as sdk_version
|
|
9
|
+
from qwak_sdk.commands.admin.admin_commands_group import admin_commands_group
|
|
10
|
+
from qwak_sdk.commands.alerts.alerts_commnad_group import alerts_commands_group
|
|
11
|
+
from qwak_sdk.commands.audience.audience_commands_group import audience_commands_group
|
|
12
|
+
from qwak_sdk.commands.automations.automations_commands_group import (
|
|
13
|
+
automations_commands_group,
|
|
14
|
+
)
|
|
15
|
+
from qwak_sdk.commands.feature_store.feature_store_command_group import (
|
|
16
|
+
feature_store_commands_group,
|
|
17
|
+
)
|
|
18
|
+
from qwak_sdk.commands.models.models_command_group import models_command_group
|
|
19
|
+
from qwak_sdk.commands.projects.projects_command_group import projects_command_group
|
|
20
|
+
from qwak_sdk.commands.secrets.secrets_commands_group import secrets_commands_group
|
|
21
|
+
from qwak_sdk.commands.workspaces.workspaces_commands_group import (
|
|
22
|
+
workspaces_commands_group,
|
|
23
|
+
)
|
|
24
|
+
from qwak_sdk.inner.tools.cli_tools import profile_setter_wrapper
|
|
25
|
+
from qwak_sdk.inner.tools.logger import setup_qwak_logger
|
|
26
|
+
|
|
27
|
+
version_option_kwargs = {}
|
|
28
|
+
if version.parse(click.__version__) >= version.parse("8.0.0"):
|
|
29
|
+
version_option_kwargs["package_name"] = "qwak-sdk"
|
|
30
|
+
version_option_kwargs["version"] = sdk_version
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def create_qwak_cli():
|
|
34
|
+
setup_qwak_logger()
|
|
35
|
+
|
|
36
|
+
@click.group()
|
|
37
|
+
@click.version_option(**version_option_kwargs)
|
|
38
|
+
def qwak_cli():
|
|
39
|
+
# This class is intentionally empty
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
@qwak_cli.command("configure", short_help="Configure the Qwak environment")
|
|
43
|
+
@click.option(
|
|
44
|
+
"--api-key",
|
|
45
|
+
metavar="QWAK_API_KEY",
|
|
46
|
+
required=False,
|
|
47
|
+
help="Qwak assigned API key",
|
|
48
|
+
)
|
|
49
|
+
@click.option(
|
|
50
|
+
"--environment",
|
|
51
|
+
metavar="ENVIRONMENT",
|
|
52
|
+
default="default",
|
|
53
|
+
required=False,
|
|
54
|
+
is_eager=True,
|
|
55
|
+
help="Qwak environment's name",
|
|
56
|
+
)
|
|
57
|
+
@profile_setter_wrapper
|
|
58
|
+
def set_configuration(
|
|
59
|
+
api_key: Optional[str],
|
|
60
|
+
environment: str,
|
|
61
|
+
**_,
|
|
62
|
+
):
|
|
63
|
+
if api_key is None:
|
|
64
|
+
api_key = click.prompt("Please enter your API key", type=str)
|
|
65
|
+
|
|
66
|
+
account_config = UserAccountConfiguration()
|
|
67
|
+
account_config.configure_user(UserAccount(api_key=api_key))
|
|
68
|
+
print(f"User successfully configured for the '{environment}' environment")
|
|
69
|
+
|
|
70
|
+
qwak_cli.add_command(projects_command_group)
|
|
71
|
+
qwak_cli.add_command(models_command_group)
|
|
72
|
+
qwak_cli.add_command(secrets_commands_group)
|
|
73
|
+
qwak_cli.add_command(automations_commands_group)
|
|
74
|
+
qwak_cli.add_command(admin_commands_group)
|
|
75
|
+
qwak_cli.add_command(feature_store_commands_group)
|
|
76
|
+
qwak_cli.add_command(audience_commands_group)
|
|
77
|
+
qwak_cli.add_command(alerts_commands_group)
|
|
78
|
+
qwak_cli.add_command(workspaces_commands_group)
|
|
79
|
+
return qwak_cli
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from qwak_sdk.commands.admin.apikeys.api_keys_commands_group import (
|
|
4
|
+
api_keys_commands_group,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@click.group(
|
|
9
|
+
name="admin",
|
|
10
|
+
help="Commands for admin operations",
|
|
11
|
+
)
|
|
12
|
+
def admin_commands_group():
|
|
13
|
+
# Click commands group injection
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
admin_commands_group.add_command(api_keys_commands_group)
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from qwak.tools.logger.logger import get_qwak_logger
|
|
3
|
+
|
|
4
|
+
from qwak_sdk.commands.admin.apikeys.generate.ui import generate_apikey
|
|
5
|
+
from qwak_sdk.commands.admin.apikeys.revoke.ui import revoke_apikey
|
|
6
|
+
|
|
7
|
+
logger = get_qwak_logger()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@click.group(name="api-keys", help="api keys")
|
|
11
|
+
def api_keys_commands_group():
|
|
12
|
+
# Click commands group injection
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
api_keys_commands_group.add_command(generate_apikey)
|
|
17
|
+
api_keys_commands_group.add_command(revoke_apikey)
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from qwak.clients.administration import SelfServiceUserClient
|
|
2
|
+
from qwak.clients.administration.eco_system.client import EcosystemClient
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def execute_generate_apikey(
|
|
6
|
+
environment_name: str, user_id: str, force: bool = False
|
|
7
|
+
) -> str:
|
|
8
|
+
ecosystem_client = EcosystemClient()
|
|
9
|
+
environment_name_to_environment_details_map = (
|
|
10
|
+
ecosystem_client.get_environments_names_to_details([environment_name])
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
user_service = SelfServiceUserClient()
|
|
14
|
+
|
|
15
|
+
return user_service.generate_apikey(
|
|
16
|
+
user_id=user_id,
|
|
17
|
+
environment_id=environment_name_to_environment_details_map.get(
|
|
18
|
+
environment_name
|
|
19
|
+
).id,
|
|
20
|
+
force=force,
|
|
21
|
+
).api_key
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from qwak.clients.administration.self_service.client import APIKEY_ALREADY_EXISTS
|
|
3
|
+
from qwak.tools.logger.logger import get_qwak_logger
|
|
4
|
+
|
|
5
|
+
from qwak_sdk.commands.admin.apikeys.generate._logic import execute_generate_apikey
|
|
6
|
+
from qwak_sdk.inner.tools.cli_tools import QwakCommand
|
|
7
|
+
|
|
8
|
+
logger = get_qwak_logger()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@click.command("generate", help="api keys", cls=QwakCommand)
|
|
12
|
+
@click.option(
|
|
13
|
+
"--environment-name",
|
|
14
|
+
help="Environment name to generate api key for",
|
|
15
|
+
required=True,
|
|
16
|
+
)
|
|
17
|
+
@click.option(
|
|
18
|
+
"--user-id",
|
|
19
|
+
help="User id to generate api key for",
|
|
20
|
+
required=True,
|
|
21
|
+
)
|
|
22
|
+
@click.option(
|
|
23
|
+
"--force",
|
|
24
|
+
help="If override existing one. (default false)",
|
|
25
|
+
default=False,
|
|
26
|
+
is_flag=True,
|
|
27
|
+
)
|
|
28
|
+
def generate_apikey(user_id, environment_name, force, **kwargs):
|
|
29
|
+
logger.info(
|
|
30
|
+
f"Generating api key for user {user_id} on environment {environment_name}..."
|
|
31
|
+
)
|
|
32
|
+
try:
|
|
33
|
+
api_key = execute_generate_apikey(
|
|
34
|
+
user_id=user_id, environment_name=environment_name, force=force
|
|
35
|
+
)
|
|
36
|
+
logger.info("generated api key:")
|
|
37
|
+
logger.info(api_key)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
if e.message == APIKEY_ALREADY_EXISTS:
|
|
40
|
+
logger.error(
|
|
41
|
+
"Failed to generate api key - "
|
|
42
|
+
"the api key already exists please add --force if you want to override it."
|
|
43
|
+
)
|
|
44
|
+
else:
|
|
45
|
+
logger.error(e)
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from _qwak_proto.qwak.self_service.user.v1.user_service_pb2 import RevokeApiKeyResponse
|
|
2
|
+
from qwak.clients.administration import SelfServiceUserClient
|
|
3
|
+
from qwak.clients.administration.eco_system.client import EcosystemClient
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def execute_revoke_apikey(environment_name: str, user_id: str) -> bool:
|
|
7
|
+
ecosystem_client = EcosystemClient()
|
|
8
|
+
environment_name_to_environment_details_map = (
|
|
9
|
+
ecosystem_client.get_environments_names_to_details([environment_name])
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
user_service = SelfServiceUserClient()
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
user_service.revoke_apikey(
|
|
16
|
+
user_id=user_id,
|
|
17
|
+
environment_id=environment_name_to_environment_details_map.get(
|
|
18
|
+
environment_name
|
|
19
|
+
).id,
|
|
20
|
+
).status
|
|
21
|
+
== RevokeApiKeyResponse.Status.REVOKED
|
|
22
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from qwak.tools.logger.logger import get_qwak_logger
|
|
3
|
+
|
|
4
|
+
from qwak_sdk.commands.admin.apikeys.revoke._logic import execute_revoke_apikey
|
|
5
|
+
from qwak_sdk.inner.tools.cli_tools import QwakCommand
|
|
6
|
+
|
|
7
|
+
logger = get_qwak_logger()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@click.command("revoke", help="api keys", cls=QwakCommand)
|
|
11
|
+
@click.option(
|
|
12
|
+
"--environment-name",
|
|
13
|
+
help="Environment name to generate api key for",
|
|
14
|
+
required=True,
|
|
15
|
+
)
|
|
16
|
+
@click.option(
|
|
17
|
+
"--user-id",
|
|
18
|
+
help="User id to generate api key for",
|
|
19
|
+
required=True,
|
|
20
|
+
)
|
|
21
|
+
def revoke_apikey(user_id, environment_name, **kwargs):
|
|
22
|
+
logger.info(
|
|
23
|
+
f"Revoking api key for user {user_id} on environment {environment_name}..."
|
|
24
|
+
)
|
|
25
|
+
try:
|
|
26
|
+
if execute_revoke_apikey(user_id=user_id, environment_name=environment_name):
|
|
27
|
+
logger.info("Successfully revoked api key")
|
|
28
|
+
else:
|
|
29
|
+
logger.info("Failed to revoke api key")
|
|
30
|
+
except Exception as e:
|
|
31
|
+
logger.error(e.message)
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from qwak_sdk.commands.alerts.delete.ui import delete_channel
|
|
4
|
+
from qwak_sdk.commands.alerts.list.ui import list_channels
|
|
5
|
+
from qwak_sdk.commands.alerts.register.ui import register_channel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@click.group(
|
|
9
|
+
name="alerts",
|
|
10
|
+
help="Commands for interacting with the Qwak alerts System",
|
|
11
|
+
)
|
|
12
|
+
def alerts_commands_group():
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
alerts_commands_group.add_command(register_channel)
|
|
17
|
+
alerts_commands_group.add_command(list_channels)
|
|
18
|
+
alerts_commands_group.add_command(delete_channel)
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from qwak_sdk.commands.alerts.delete._logic import execute_delete_channel
|
|
4
|
+
from qwak_sdk.inner.tools.cli_tools import QwakCommand
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@click.command("delete", cls=QwakCommand, help="Delete a Channel by name")
|
|
8
|
+
@click.argument("name")
|
|
9
|
+
def delete_channel(name, **kwargs):
|
|
10
|
+
execute_delete_channel(name)
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from typing import List, Tuple
|
|
2
|
+
|
|
3
|
+
from qwak.clients.alerts_registry import AlertingRegistryClient
|
|
4
|
+
from qwak.clients.alerts_registry.channel import Channel
|
|
5
|
+
from tabulate import tabulate
|
|
6
|
+
|
|
7
|
+
from qwak_sdk.commands._logic.tools import list_of_messages_to_json_str
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def execute_list_channels():
|
|
11
|
+
alerts_client = AlertingRegistryClient()
|
|
12
|
+
channels: List[Tuple[str, Channel]] = alerts_client.list_alerting_channel()
|
|
13
|
+
columns = ["id", "Name", "Type", "repr"]
|
|
14
|
+
data = []
|
|
15
|
+
for c_id, c in channels:
|
|
16
|
+
data.append([c_id, c.name, type(c.channel_conf).__name__, c.__dict__])
|
|
17
|
+
return tabulate(data, headers=columns)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def execute_json_format_list_channels():
|
|
21
|
+
alerts_client = AlertingRegistryClient()
|
|
22
|
+
channels = alerts_client.list_alerting_channel_from_client().description
|
|
23
|
+
return list_of_messages_to_json_str(channels)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from qwak_sdk.commands.alerts.list._logic import (
|
|
4
|
+
execute_json_format_list_channels,
|
|
5
|
+
execute_list_channels,
|
|
6
|
+
)
|
|
7
|
+
from qwak_sdk.inner.tools.cli_tools import QwakCommand
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@click.command("list", cls=QwakCommand, help="List all alerts system channels.")
|
|
11
|
+
@click.option("--json-format", is_flag=True, type=bool)
|
|
12
|
+
def list_channels(json_format, **kwargs):
|
|
13
|
+
if json_format:
|
|
14
|
+
print(execute_json_format_list_channels())
|
|
15
|
+
|
|
16
|
+
else:
|
|
17
|
+
print(execute_list_channels())
|
|
File without changes
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
from qwak.clients.alerts_registry import AlertingRegistryClient
|
|
6
|
+
from qwak.clients.alerts_registry.channel import Channel
|
|
7
|
+
|
|
8
|
+
from qwak_sdk.inner.file_registry import extract_class_objects, list_qwak_python_files
|
|
9
|
+
from qwak_sdk.inner.tools.cli_tools import ask_yesno
|
|
10
|
+
from qwak_sdk.tools.utils import qwak_spinner
|
|
11
|
+
|
|
12
|
+
QWAK_alerts_DELIMITER = "----------------------------------------"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _register_channels(qwak_python_files, alerts_client, force):
|
|
16
|
+
"""
|
|
17
|
+
Register Channels
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
qwak_python_files: a list of python files containing qwak package imports
|
|
21
|
+
alerts_client: AlertingRegistryClient alerts service client
|
|
22
|
+
force: boolean determining if to force register all encountered Channel objects
|
|
23
|
+
"""
|
|
24
|
+
with qwak_spinner(
|
|
25
|
+
begin_text="Looking for channels to register", print_callback=print
|
|
26
|
+
):
|
|
27
|
+
qwak_channels: List[Channel] = extract_class_objects(qwak_python_files, Channel)
|
|
28
|
+
|
|
29
|
+
print(f"👀 Found {len(qwak_channels)} Channels")
|
|
30
|
+
for channel, source_file_path in qwak_channels:
|
|
31
|
+
channel_id, existing_channel = alerts_client.get_alerting_channel(channel.name)
|
|
32
|
+
if existing_channel:
|
|
33
|
+
if ask_yesno(
|
|
34
|
+
f"Update existing Channel '{channel.name}' from source file '{source_file_path}'?",
|
|
35
|
+
force,
|
|
36
|
+
):
|
|
37
|
+
alerts_client.update_alerting_channel(
|
|
38
|
+
channel_id=channel_id, channel=channel
|
|
39
|
+
)
|
|
40
|
+
else:
|
|
41
|
+
if ask_yesno(
|
|
42
|
+
f"Create new Channel '{channel.name}' from source file '{source_file_path}'?",
|
|
43
|
+
force,
|
|
44
|
+
):
|
|
45
|
+
alerts_client.create_alerting_channel(channel)
|
|
46
|
+
print(QWAK_alerts_DELIMITER)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def execute_register_channel(path: Path, force: bool):
|
|
50
|
+
if not path:
|
|
51
|
+
path = Path.cwd()
|
|
52
|
+
else:
|
|
53
|
+
path = Path(path)
|
|
54
|
+
|
|
55
|
+
if path.is_file():
|
|
56
|
+
qwak_python_files = [(str(path), os.path.abspath(path))]
|
|
57
|
+
elif Path.is_dir(path):
|
|
58
|
+
with qwak_spinner(
|
|
59
|
+
begin_text="Recursively looking for python files in input dir",
|
|
60
|
+
print_callback=print,
|
|
61
|
+
) as sp:
|
|
62
|
+
qwak_python_files = list_qwak_python_files(path, sp)
|
|
63
|
+
print(qwak_python_files)
|
|
64
|
+
print(sp)
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
alerts_client = AlertingRegistryClient()
|
|
68
|
+
_register_channels(
|
|
69
|
+
qwak_python_files=qwak_python_files,
|
|
70
|
+
alerts_client=alerts_client,
|
|
71
|
+
force=force,
|
|
72
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from qwak_sdk.commands.alerts.register._logic import execute_register_channel
|
|
6
|
+
from qwak_sdk.inner.tools.cli_tools import QwakCommand
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@click.command(
|
|
10
|
+
"register",
|
|
11
|
+
cls=QwakCommand,
|
|
12
|
+
help="Register all alerts system objects under the given path.",
|
|
13
|
+
)
|
|
14
|
+
@click.option(
|
|
15
|
+
"--path",
|
|
16
|
+
"-p",
|
|
17
|
+
type=click.Path(exists=True),
|
|
18
|
+
metavar="PATH",
|
|
19
|
+
help="Directory / module where qwak alerts system objects are stored",
|
|
20
|
+
)
|
|
21
|
+
@click.option(
|
|
22
|
+
"--force",
|
|
23
|
+
"-f",
|
|
24
|
+
default=False,
|
|
25
|
+
is_flag=True,
|
|
26
|
+
metavar="FLAG",
|
|
27
|
+
help="Force register all found qwak alerts system objects",
|
|
28
|
+
)
|
|
29
|
+
def register_channel(path: Path, force: bool, **kwargs):
|
|
30
|
+
execute_register_channel(path, force)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from dataclasses import dataclass, field
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from _qwak_proto.qwak.audience.v1.audience_pb2 import Audience
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class ConfigBase(ABC):
|
|
10
|
+
spec: Any
|
|
11
|
+
api_version: str = field(default="v1")
|
|
12
|
+
|
|
13
|
+
@abstractmethod
|
|
14
|
+
def to_audiences_api(self) -> Audience:
|
|
15
|
+
pass
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Optional, Union
|
|
3
|
+
|
|
4
|
+
import yaml
|
|
5
|
+
|
|
6
|
+
from qwak_sdk.commands.audience._logic.config.config_base import ConfigBase
|
|
7
|
+
from qwak_sdk.commands.audience._logic.config.v1.config_v1 import ConfigV1
|
|
8
|
+
from qwak_sdk.inner.tools.dataclasses_utils import create_dataclass_instance
|
|
9
|
+
|
|
10
|
+
VERSION_CONFIG_MAPPING = {"v1": ConfigV1}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def parse_audience_from_yaml(
|
|
14
|
+
file_path: Optional[Union[Path, str]] = None
|
|
15
|
+
) -> ConfigBase:
|
|
16
|
+
if file_path:
|
|
17
|
+
file_path_obj = Path(file_path)
|
|
18
|
+
if file_path_obj.exists():
|
|
19
|
+
audience_dict = yaml.safe_load(file_path_obj.open("r"))
|
|
20
|
+
audience_config: ConfigBase = VERSION_CONFIG_MAPPING.get(
|
|
21
|
+
audience_dict.get("api_version")
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
return create_dataclass_instance(audience_config, audience_dict)
|
|
25
|
+
else:
|
|
26
|
+
raise FileNotFoundError(
|
|
27
|
+
f"Audience file {file_path_obj} definition isn't found"
|
|
28
|
+
)
|
|
29
|
+
else:
|
|
30
|
+
return ConfigV1()
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from _qwak_proto.qwak.audience.v1.audience_pb2 import AudienceRoutesEntry
|
|
5
|
+
|
|
6
|
+
from qwak_sdk.commands.audience._logic.config.v1.conditions_config import (
|
|
7
|
+
ConditionsConfig,
|
|
8
|
+
)
|
|
9
|
+
from qwak_sdk.commands.audience._logic.config.v1.route_config import RouteConfig
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class AudienceConfig:
|
|
14
|
+
name: str = field(default="")
|
|
15
|
+
id: str = field(default="")
|
|
16
|
+
description: str = field(default="")
|
|
17
|
+
routes: List[RouteConfig] = field(default_factory=list)
|
|
18
|
+
conditions: ConditionsConfig = field(default_factory=ConditionsConfig)
|
|
19
|
+
|
|
20
|
+
def to_audience_route_entry(self, index: int = 0) -> AudienceRoutesEntry:
|
|
21
|
+
return AudienceRoutesEntry(
|
|
22
|
+
audience_id=self.id,
|
|
23
|
+
audience_name=self.name,
|
|
24
|
+
order=index + 1,
|
|
25
|
+
routes=[route.to_route_api() for route in self.routes],
|
|
26
|
+
)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from _qwak_proto.qwak.audience.v1.audience_pb2 import (
|
|
5
|
+
BinaryCondition,
|
|
6
|
+
BinaryOperatorType,
|
|
7
|
+
Condition,
|
|
8
|
+
UnaryCondition,
|
|
9
|
+
UnaryOperatorType,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class UnaryConditionConfig:
|
|
15
|
+
key: str
|
|
16
|
+
operator: str
|
|
17
|
+
operand: str
|
|
18
|
+
|
|
19
|
+
def to_condition_api(self) -> Condition:
|
|
20
|
+
return Condition(
|
|
21
|
+
key=self.key,
|
|
22
|
+
unary_condition=UnaryCondition(
|
|
23
|
+
operator=UnaryOperatorType.DESCRIPTOR.values_by_name[
|
|
24
|
+
self.operator
|
|
25
|
+
].number,
|
|
26
|
+
operand=self.operand,
|
|
27
|
+
),
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class BinaryConditionConfig:
|
|
33
|
+
key: str
|
|
34
|
+
operator: str
|
|
35
|
+
first_operand: str
|
|
36
|
+
second_operand: str
|
|
37
|
+
|
|
38
|
+
def to_condition_api(self) -> Condition:
|
|
39
|
+
return Condition(
|
|
40
|
+
key=self.key,
|
|
41
|
+
binary_condition=BinaryCondition(
|
|
42
|
+
operator=BinaryOperatorType.DESCRIPTOR.values_by_name[
|
|
43
|
+
self.operator
|
|
44
|
+
].number,
|
|
45
|
+
first_operand=str(self.first_operand),
|
|
46
|
+
second_operand=str(self.second_operand),
|
|
47
|
+
),
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass
|
|
52
|
+
class ConditionsConfig:
|
|
53
|
+
unary: List[UnaryConditionConfig] = field(default_factory=list)
|
|
54
|
+
binary: List[BinaryConditionConfig] = field(default_factory=list)
|
|
55
|
+
|
|
56
|
+
def to_conditions_api(self) -> List[Condition]:
|
|
57
|
+
conditions = [condition.to_condition_api() for condition in self.unary]
|
|
58
|
+
conditions.extend([condition.to_condition_api() for condition in self.binary])
|
|
59
|
+
return conditions
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from _qwak_proto.qwak.audience.v1.audience_pb2 import Audience
|
|
5
|
+
|
|
6
|
+
from qwak_sdk.commands.audience._logic.config.config_base import ConfigBase
|
|
7
|
+
from qwak_sdk.commands.audience._logic.config.v1.spec import Spec
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class ConfigV1(ConfigBase):
|
|
12
|
+
spec: Spec = field(default_factory=Spec)
|
|
13
|
+
|
|
14
|
+
def to_audiences_api(self) -> List[Audience]:
|
|
15
|
+
return [
|
|
16
|
+
Audience(
|
|
17
|
+
name=audience_config.name,
|
|
18
|
+
description=audience_config.description,
|
|
19
|
+
routes=[route.to_route_api() for route in audience_config.routes],
|
|
20
|
+
conditions=audience_config.conditions.to_conditions_api(),
|
|
21
|
+
)
|
|
22
|
+
for audience_config in self.spec.audiences
|
|
23
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from _qwak_proto.qwak.audience.v1.audience_pb2 import Route
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class RouteConfig:
|
|
8
|
+
variation_name: str
|
|
9
|
+
weight: int
|
|
10
|
+
shadow: bool
|
|
11
|
+
|
|
12
|
+
def to_route_api(self):
|
|
13
|
+
return Route(
|
|
14
|
+
variation_name=self.variation_name, weight=self.weight, shadow=self.shadow
|
|
15
|
+
)
|