Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions packages/uipath/src/uipath/_cli/cli_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
from typing import cast, get_args

import click
from pydantic import ValidationError

from uipath._cli._chat._bridge import get_chat_bridge
from uipath._cli._debug._bridge import DebugAttachMode, get_debug_bridge
from uipath._cli._utils._debug import setup_debugging
from uipath._cli._utils._studio_project import StudioClient
from uipath.core.tracing import UiPathTraceManager
from uipath.eval.mocks import UiPathMockRuntime
from uipath.eval.mocks import (
SimulationConfig,
UiPathMockRuntime,
build_mocking_context,
)
from uipath.eval.mocks._mock_runtime import load_simulation_config
from uipath.platform.common import ResourceOverwritesContext, UiPathConfig
from uipath.runtime import (
Expand Down Expand Up @@ -74,6 +79,12 @@
"'console' for local runs."
),
)
@click.option(
"--simulation",
required=False,
default=None,
help="Simulation config as a JSON object (same schema as simulation.json)",
)
@track_command("debug")
def debug(
entrypoint: str | None,
Expand All @@ -85,6 +96,7 @@
debug: bool,
debug_port: int,
attach: str | None,
simulation: str | None,
) -> None:
"""Debug the project."""
input_file = file or input_file
Expand All @@ -96,6 +108,14 @@
cast(DebugAttachMode, attach.lower()) if attach else None
)

simulation_config: SimulationConfig | None = None
if simulation:
try:
simulation_config = SimulationConfig.model_validate_json(simulation)
except (ValidationError, ValueError) as e:

Check warning on line 115 in packages/uipath/src/uipath/_cli/cli_debug.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this redundant Exception class; it derives from another which is already caught.

See more on https://sonarcloud.io/project/issues?id=UiPath_uipath-python&issues=AZ4trT6KzgvZm-J9IJFX&open=AZ4trT6KzgvZm-J9IJFX&pullRequest=1632
console.error(f"Invalid --simulation config: {e}")
return

result = Middlewares.next(
"debug",
entrypoint,
Expand Down Expand Up @@ -188,9 +208,14 @@
if schema.metadata and "settings" in schema.metadata:
agent_model = schema.metadata["settings"].get("model")

mocking_context = load_simulation_config(
agent_model=agent_model
)
if simulation_config:
mocking_context = build_mocking_context(
simulation_config, agent_model
)
else:
mocking_context = load_simulation_config(
agent_model=agent_model
)

mock_runtime = UiPathMockRuntime(
delegate=debug_runtime,
Expand Down
Loading