Skip to content

Commit 74f0b3a

Browse files
bmehta001Copilot
andcommitted
Fix telemetry pipeline test regressions
Keep CLI workflow imports patchable so existing CLI tests and command mocks still intercept workflow execution. Update CLI test expectations for recipe telemetry metadata, and make the CI-sensitive workflow telemetry assertion deterministic. Files changed: - olive/cli/base.py - olive/cli/run.py - test/cli/test_cli.py - test/workflows/test_workflow_run.py Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9daf901 commit 74f0b3a

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

olive/cli/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from olive.hardware.accelerator import AcceleratorSpec
2121
from olive.hardware.constants import DEVICE_TO_EXECUTION_PROVIDERS
2222
from olive.resource_path import OLIVE_RESOURCE_ANNOTATIONS
23-
from olive.workflows import run as olive_run
2423

2524

2625
class BaseOliveCLICommand(ABC):
@@ -34,6 +33,8 @@ def __init__(self, parser: ArgumentParser, args: Namespace, unknown_args: Option
3433
parser.error(f"Unknown arguments: {unknown_args}")
3534

3635
def _run_workflow(self):
36+
from olive.workflows import run as olive_run
37+
3738
Path(self.args.output_path).mkdir(parents=True, exist_ok=True)
3839

3940
with tempfile.TemporaryDirectory(prefix="olive-cli-tmp-", dir=self.args.output_path) as tempdir:

olive/cli/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
)
1515
from olive.common.config_utils import load_config_file
1616
from olive.telemetry import action
17-
from olive.workflows import run as olive_run
1817

1918

2019
class WorkflowRunCommand(BaseOliveCLICommand):
@@ -52,6 +51,8 @@ def register_subcommand(parser: ArgumentParser):
5251

5352
@action
5453
def run(self):
54+
from olive.workflows import run as olive_run
55+
5556
# allow the run_config to be a dict already (for api use)
5657
run_config_input = self.args.run_config
5758
run_config = run_config_input

test/cli/test_cli.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,17 @@ def test_workflow_run_command(mock_run, tempdir, list_required_packages, tmp_pat
107107

108108
# assert
109109
mock_run.assert_called_once_with(
110-
{"key": "value"}, package_config=None, tempdir=tempdir, list_required_packages=list_required_packages
110+
{"key": "value"},
111+
package_config=None,
112+
tempdir=tempdir,
113+
list_required_packages=list_required_packages,
114+
recipe_telemetry_metadata={
115+
"recipe_command": "WorkflowRun",
116+
"recipe_source": "config_file",
117+
"recipe_format": "json",
118+
"execution_mode": "list_required_packages" if list_required_packages else "run",
119+
"package_config_provided": False,
120+
},
111121
)
112122

113123

@@ -147,6 +157,13 @@ def test_workflow_run_command_with_overrides(mock_run, tmp_path):
147157
list_required_packages=False,
148158
package_config=None,
149159
tempdir=None,
160+
recipe_telemetry_metadata={
161+
"recipe_command": "WorkflowRun",
162+
"recipe_source": "config_file",
163+
"recipe_format": "json",
164+
"execution_mode": "run",
165+
"package_config_provided": False,
166+
},
150167
)
151168

152169

test/workflows/test_workflow_run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ def test_run_packages():
132132

133133
@patch("olive.workflows.run.run.log_recipe_result")
134134
@patch("olive.workflows.run.run.run_engine")
135-
def test_run_logs_recipe_result_success(mock_run_engine, mock_log_recipe_result):
135+
@patch("olive.workflows.run.run.is_ci_environment", return_value=False)
136+
def test_run_logs_recipe_result_success(_, mock_run_engine, mock_log_recipe_result):
136137
config = {
137138
"input_model": {
138139
"type": "HfModel",

0 commit comments

Comments
 (0)