Skip to content

Commit 7028b65

Browse files
authored
feat(telemetry): Collect information about starters (#1257)
* Not mask starters argument Signed-off-by: Ankita Katiyar <[email protected]> * Add test case for starters Signed-off-by: Ankita Katiyar <[email protected]> * Release notes + lint Signed-off-by: Ankita Katiyar <[email protected]> * Add more test cases Signed-off-by: Ankita Katiyar <[email protected]> * Mask custom starters Signed-off-by: Ankita Katiyar <[email protected]> --------- Signed-off-by: Ankita Katiyar <[email protected]> Signed-off-by: Ankita Katiyar <[email protected]>
1 parent c1a7285 commit 7028b65

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

kedro-telemetry/RELEASE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Upcoming release
22
* Dropped support for Python 3.9 (EOL Oct 2025). Minimum supported version is now 3.10.
3+
* Updated collection of command usage information to include which starter is used when creating a new project.
34
* Update collection of project statistics to include what types of datasets are used in the project. This will not include dataset type name if a custom dataset is used.
45

56
# Release 0.6.5

kedro-telemetry/kedro_telemetry/masking.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
import click
88

99
MASK = "*****"
10+
STARTERS = [
11+
"astro-airflow-iris",
12+
"databricks-iris",
13+
"spaceflights-pandas",
14+
"spaceflights-pyspark",
15+
]
1016

1117

1218
def _recurse_cli(
@@ -103,20 +109,30 @@ def _mask_kedro_cli(cli: click.CommandCollection, command_args: list[str]) -> li
103109
output.append(command_args[arg_index])
104110
current_CLI = current_CLI[command_args[arg_index]]
105111
arg_index += 1
106-
107112
# Mask everything except parameter keywords
113+
prev_arg = None
108114
for arg in command_args[arg_index:]:
109115
if arg.startswith("-"):
110116
if "=" in arg:
111-
arg_left = arg.split("=")[0]
112-
if arg_left in current_CLI:
117+
arg_left, arg_right = arg.split("=", 1)
118+
is_valid_param = arg_left in current_CLI
119+
is_starter = arg_left in ("--starter", "-s")
120+
121+
if is_valid_param:
113122
output.append(arg_left)
114-
output.append(MASK)
115-
elif arg in current_CLI:
116-
output.append(arg)
123+
prev_arg = arg_left
124+
else:
125+
prev_arg = None
126+
127+
output.append(
128+
arg_right if is_starter and arg_right in STARTERS else MASK
129+
)
117130
else:
118-
output.append(MASK)
131+
is_valid_param = arg in current_CLI
132+
output.append(arg if is_valid_param else MASK)
133+
prev_arg = arg if is_valid_param else None
119134
else:
120-
output.append(MASK)
121-
135+
is_starter = prev_arg in ("--starter", "-s")
136+
output.append(arg if is_starter and arg in STARTERS else MASK)
137+
prev_arg = None
122138
return output

kedro-telemetry/kedro_telemetry/plugin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ def before_command_run(
185185
# get KedroCLI and its structure from actual project root
186186
cli = KedroCLI(project_path=project_path if project_path else Path.cwd())
187187
masked_command_args = _mask_kedro_cli(cli, command_args=command_args)
188-
189188
self._user_uuid = _get_or_create_uuid()
190189

191190
event_properties = _get_project_properties(self._user_uuid, project_path)

kedro-telemetry/tests/test_masking.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,18 @@ def test_get_cli_structure_help(self, mocker, fake_metadata):
177177
["run", "--params=hello=4", "--pipeline=my_pipeline"],
178178
["run", "--params", MASK, "--pipeline", MASK],
179179
),
180+
(
181+
["new", "--starter=spaceflights-pandas", "--name=my_project"],
182+
["new", "--starter", "spaceflights-pandas", "--name", MASK],
183+
),
184+
(
185+
["new", "--starter", "my_starter", "--name=my_project"],
186+
["new", "--starter", MASK, "--name", MASK],
187+
),
188+
(
189+
["new", "-s=databricks-iris", "-n=my_project"],
190+
["new", "-s", "databricks-iris", "-n", MASK],
191+
),
180192
],
181193
)
182194
def test_mask_kedro_cli(

0 commit comments

Comments
 (0)