weni-cli 3.7.1__tar.gz → 3.7.2__tar.gz
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.
- {weni_cli-3.7.1 → weni_cli-3.7.2}/PKG-INFO +1 -1
- {weni_cli-3.7.1 → weni_cli-3.7.2}/pyproject.toml +1 -1
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/cli.py +9 -2
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/clients/cli_client.py +16 -4
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/project_push.py +39 -9
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/formatter/formatter.py +11 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/formatter/tests/test_formatter.py +18 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/README.md +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/__init__.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/auth.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/clients/__init__.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/clients/common.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/clients/response_handlers/__init__.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/clients/response_handlers/handlers.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/clients/tests/__init__.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/clients/tests/test_cli_client.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/clients/tests/test_weni_client.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/clients/weni_client.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/channel_create.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/eval_init.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/eval_run.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/init.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/login.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/logs.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/project_current.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/project_list.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/project_use.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/commands/run.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/formatter/__init__.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/handler.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/packager/__init__.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/packager/loader.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/packager/packager.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/packager/tests/__init__.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/packager/tests/test_loader.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/packager/tests/test_packager.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/spinner/__init__.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/spinner/spinners.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/store.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/utils.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/validators/__init__.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/validators/agent_definition.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/validators/channel_definition.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/validators/source.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/validators/tests/__init__.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/validators/tests/conftest.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/validators/tests/test_active_test_definition.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/validators/tests/test_channel_definition.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/validators/tests/test_definition.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/validators/tests/test_source.py +0 -0
- {weni_cli-3.7.1 → weni_cli-3.7.2}/weni_cli/wsgi.py +0 -0
|
@@ -101,7 +101,9 @@ def current_project():
|
|
|
101
101
|
@project.command("push")
|
|
102
102
|
@click.argument("definition", required=True, type=click.Path(exists=True, dir_okay=False))
|
|
103
103
|
@click.option("--force-update", is_flag=True, help="Force update to the project")
|
|
104
|
-
|
|
104
|
+
@click.option("--use-apm", is_flag=True, help="Enable Elastic APM instrumentation for passive agent tool lambdas")
|
|
105
|
+
@click.option("--remove-apm", is_flag=True, help="Remove Elastic APM instrumentation from passive agent tool lambdas")
|
|
106
|
+
def push_project(definition, force_update, use_apm, remove_apm):
|
|
105
107
|
"""Push an Agent definition to the current project
|
|
106
108
|
|
|
107
109
|
DEFINITION: The path to the YAML agent definition file
|
|
@@ -109,7 +111,12 @@ def push_project(definition, force_update):
|
|
|
109
111
|
from weni_cli.commands.project_push import ProjectPushHandler
|
|
110
112
|
|
|
111
113
|
try:
|
|
112
|
-
ProjectPushHandler().execute(
|
|
114
|
+
ProjectPushHandler().execute(
|
|
115
|
+
definition=definition,
|
|
116
|
+
force_update=force_update,
|
|
117
|
+
use_apm=use_apm,
|
|
118
|
+
remove_apm=remove_apm,
|
|
119
|
+
)
|
|
113
120
|
except Exception as e:
|
|
114
121
|
click.echo(f"Error: {e}")
|
|
115
122
|
|
|
@@ -50,15 +50,22 @@ def get_cli_version() -> str:
|
|
|
50
50
|
return importlib.metadata.version("weni-cli")
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def create_default_payload(
|
|
53
|
+
def create_default_payload(
|
|
54
|
+
project_uuid: str, definition: Dict, agent_type: str, apm_instrumentation: Optional[str] = None
|
|
55
|
+
) -> Dict[str, str]:
|
|
54
56
|
"""Create a default payload for API requests."""
|
|
55
|
-
|
|
57
|
+
payload = {
|
|
56
58
|
"project_uuid": project_uuid,
|
|
57
59
|
"definition": json.dumps(definition, ensure_ascii=False),
|
|
58
60
|
"toolkit_version": get_toolkit_version(),
|
|
59
61
|
"type": agent_type,
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
if apm_instrumentation:
|
|
65
|
+
payload["apm_instrumentation"] = apm_instrumentation
|
|
66
|
+
|
|
67
|
+
return payload
|
|
68
|
+
|
|
62
69
|
|
|
63
70
|
class CLIClient:
|
|
64
71
|
"""Client for interacting with the Weni CLI API."""
|
|
@@ -179,10 +186,15 @@ class CLIClient:
|
|
|
179
186
|
raise RequestError(f"Failed to check project permission: {e.message}")
|
|
180
187
|
|
|
181
188
|
def push_agents(
|
|
182
|
-
self,
|
|
189
|
+
self,
|
|
190
|
+
project_uuid: str,
|
|
191
|
+
agents_definition: Dict,
|
|
192
|
+
resources_folder: Dict[str, BinaryIO],
|
|
193
|
+
agent_type: str,
|
|
194
|
+
apm_instrumentation: Optional[str] = None,
|
|
183
195
|
) -> None:
|
|
184
196
|
"""Push agents to the API."""
|
|
185
|
-
data = create_default_payload(project_uuid, agents_definition, agent_type)
|
|
197
|
+
data = create_default_payload(project_uuid, agents_definition, agent_type, apm_instrumentation)
|
|
186
198
|
|
|
187
199
|
with spinner():
|
|
188
200
|
try:
|
|
@@ -19,12 +19,36 @@ from weni_cli.validators.agent_definition import (
|
|
|
19
19
|
|
|
20
20
|
CONTACT_FIELD_NAME_REGEX = r"^[a-z][a-z0-9_]*$"
|
|
21
21
|
|
|
22
|
+
APM_OBSERVABILITY_WARNING = (
|
|
23
|
+
"Use Elastic APM instrumentation only for observability—for example, while debugging or "
|
|
24
|
+
"investigating an issue. APM adds Lambda layers and environment variables that increase cold "
|
|
25
|
+
"start time and runtime overhead.\n\n"
|
|
26
|
+
"When you no longer need it, disable instrumentation with:\n"
|
|
27
|
+
" weni project push <definition> --remove-apm"
|
|
28
|
+
)
|
|
29
|
+
|
|
22
30
|
|
|
23
31
|
class ProjectPushHandler(Handler):
|
|
24
32
|
def execute(self, **kwargs):
|
|
25
33
|
force_update = self.load_param(kwargs, "force_update", False)
|
|
34
|
+
use_apm = self.load_param(kwargs, "use_apm", False)
|
|
35
|
+
remove_apm = self.load_param(kwargs, "remove_apm", False)
|
|
26
36
|
definition_path = self.load_param(kwargs, "definition", None, True)
|
|
27
37
|
|
|
38
|
+
if use_apm and remove_apm:
|
|
39
|
+
formatter = Formatter()
|
|
40
|
+
formatter.print_error_panel(
|
|
41
|
+
"Cannot use --use-apm and --remove-apm together. Choose one option.",
|
|
42
|
+
title="Invalid APM options",
|
|
43
|
+
)
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
apm_instrumentation = None
|
|
47
|
+
if use_apm:
|
|
48
|
+
apm_instrumentation = "enabled"
|
|
49
|
+
elif remove_apm:
|
|
50
|
+
apm_instrumentation = "disabled"
|
|
51
|
+
|
|
28
52
|
store = Store()
|
|
29
53
|
project_uuid = store.get(STORE_PROJECT_UUID_KEY)
|
|
30
54
|
|
|
@@ -55,11 +79,11 @@ class ProjectPushHandler(Handler):
|
|
|
55
79
|
return
|
|
56
80
|
|
|
57
81
|
if agent_type == "passive":
|
|
58
|
-
self.push_passive_agent(force_update, project_uuid, definition_data)
|
|
82
|
+
self.push_passive_agent(force_update, project_uuid, definition_data, apm_instrumentation)
|
|
59
83
|
elif agent_type == "active":
|
|
60
|
-
self.push_active_agent(force_update, project_uuid, definition_data)
|
|
84
|
+
self.push_active_agent(force_update, project_uuid, definition_data, apm_instrumentation)
|
|
61
85
|
|
|
62
|
-
def push_passive_agent(self, force_update, project_uuid, definition):
|
|
86
|
+
def push_passive_agent(self, force_update, project_uuid, definition, apm_instrumentation=None):
|
|
63
87
|
formatter = Formatter()
|
|
64
88
|
error = validate_agent_definition_schema(definition)
|
|
65
89
|
if error:
|
|
@@ -74,9 +98,9 @@ class ProjectPushHandler(Handler):
|
|
|
74
98
|
return
|
|
75
99
|
|
|
76
100
|
definition = format_definition(definition)
|
|
77
|
-
self.push_definition(force_update, "passive", project_uuid, definition, tools_folders_map)
|
|
101
|
+
self.push_definition(force_update, "passive", project_uuid, definition, tools_folders_map, apm_instrumentation)
|
|
78
102
|
|
|
79
|
-
def push_active_agent(self, force_update, project_uuid, definition):
|
|
103
|
+
def push_active_agent(self, force_update, project_uuid, definition, apm_instrumentation=None):
|
|
80
104
|
formatter = Formatter()
|
|
81
105
|
error = validate_active_agent_definition_schema(definition)
|
|
82
106
|
if error:
|
|
@@ -98,7 +122,7 @@ class ProjectPushHandler(Handler):
|
|
|
98
122
|
rules_folders_map.update(preprocessing_folders_map)
|
|
99
123
|
resources_folders_map = rules_folders_map
|
|
100
124
|
definition = format_definition(definition)
|
|
101
|
-
self.push_definition(force_update, "active", project_uuid, definition, resources_folders_map)
|
|
125
|
+
self.push_definition(force_update, "active", project_uuid, definition, resources_folders_map, None)
|
|
102
126
|
|
|
103
127
|
def load_param(self, params, key, default=None, required=False):
|
|
104
128
|
value = params.get(key, default)
|
|
@@ -115,13 +139,19 @@ class ProjectPushHandler(Handler):
|
|
|
115
139
|
def load_preprocessing_folder(self, definition) -> tuple[Optional[dict], Optional[str]]:
|
|
116
140
|
return _load_preprocessing_folder(definition)
|
|
117
141
|
|
|
118
|
-
def push_definition(
|
|
142
|
+
def push_definition(
|
|
143
|
+
self, force_update, agent_type, project_uuid, definition, resources_folder_map, apm_instrumentation=None
|
|
144
|
+
):
|
|
119
145
|
client = CLIClient()
|
|
146
|
+
formatter = Formatter()
|
|
120
147
|
|
|
121
148
|
try:
|
|
122
|
-
client.push_agents(
|
|
149
|
+
client.push_agents(
|
|
150
|
+
project_uuid, definition, resources_folder_map, agent_type, apm_instrumentation=apm_instrumentation
|
|
151
|
+
)
|
|
123
152
|
except Exception as e:
|
|
124
|
-
formatter = Formatter()
|
|
125
153
|
formatter.print_error_panel(f"Failed to push definition: {e}")
|
|
126
154
|
else:
|
|
127
155
|
click.echo("Definition pushed successfully")
|
|
156
|
+
if apm_instrumentation == "enabled":
|
|
157
|
+
formatter.print_warning_panel(APM_OBSERVABILITY_WARNING, title="APM instrumentation enabled")
|
|
@@ -32,3 +32,14 @@ class Formatter:
|
|
|
32
32
|
expand=False,
|
|
33
33
|
)
|
|
34
34
|
print(success_panel)
|
|
35
|
+
|
|
36
|
+
def print_warning_panel(self, message, title="Warning"):
|
|
37
|
+
warning_panel = Panel(
|
|
38
|
+
self._to_renderable(message),
|
|
39
|
+
title=f"[bold yellow]{title}[/bold yellow]",
|
|
40
|
+
title_align="left",
|
|
41
|
+
style="bold yellow",
|
|
42
|
+
expand=False,
|
|
43
|
+
padding=(1, 1),
|
|
44
|
+
)
|
|
45
|
+
print(warning_panel)
|
|
@@ -53,6 +53,24 @@ def test_print_success_panel(formatter, mocker):
|
|
|
53
53
|
assert panel_arg.expand is False
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
def test_print_warning_panel(formatter, mocker):
|
|
57
|
+
"""Test the warning panel creation and printing."""
|
|
58
|
+
mock_print = mocker.patch("weni_cli.formatter.formatter.print")
|
|
59
|
+
|
|
60
|
+
warning_message = "This is a warning message"
|
|
61
|
+
|
|
62
|
+
formatter.print_warning_panel(warning_message, title="Custom warning")
|
|
63
|
+
|
|
64
|
+
mock_print.assert_called_once()
|
|
65
|
+
|
|
66
|
+
panel_arg = mock_print.call_args[0][0]
|
|
67
|
+
assert isinstance(panel_arg, Panel)
|
|
68
|
+
assert panel_arg.title == "[bold yellow]Custom warning[/bold yellow]"
|
|
69
|
+
assert panel_arg.renderable == warning_message
|
|
70
|
+
assert panel_arg.style == "bold yellow"
|
|
71
|
+
assert panel_arg.expand is False
|
|
72
|
+
|
|
73
|
+
|
|
56
74
|
def test_print_error_panel_with_exception(formatter, mocker):
|
|
57
75
|
"""Test printing an error panel with an exception object."""
|
|
58
76
|
mock_print = mocker.patch("weni_cli.formatter.formatter.print")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|