Skip to content

Commit 3493c4a

Browse files
fix lint problems
1 parent e40c02c commit 3493c4a

11 files changed

Lines changed: 90 additions & 101 deletions

File tree

mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ plugins = pydantic.mypy,sqlalchemy.ext.mypy.plugin
1616
exclude = (?x)(
1717
^src/askui/models/ui_tars_ep/ui_tars_api\.py$
1818
| ^src/askui/tools/askui/askui_ui_controller_grpc/.*$
19+
| ^venv/.*$
20+
| ^\.venv/.*$
1921
)
2022
mypy_path = src:tests
2123
explicit_package_bases = true

src/askui/computer_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ComputerAgent(Agent):
5959
agent_os_servers (list[AgentOsServer] | None, optional):
6060
Agent OS servers used by the default `AskUiControllerClient`. Must contain
6161
at least one server, at most one local, and remote addresses must be unique.
62-
Defaults to a single local Agent OS server. Ignored when `tools` is set.
62+
Defaults to a single local Agent OS server.
6363
settings (AgentSettings | None, optional): Provider-based model settings. If `None`, uses the default AskUI model stack.
6464
retry (Retry, optional): The retry instance to use for retrying failed actions. Defaults to `ConfigurableRetry` with exponential backoff. Currently only supported for `locate()` method.
6565
act_tools (list[Tool] | None, optional): Additional tools to make available for the `act()` method.

src/askui/tools/askui/agent_os_server.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,26 @@ def is_service(self) -> bool:
177177
@staticmethod
178178
def _is_askui_core_service_running() -> bool:
179179
"""Return `True` when the `AskuiCoreService` Windows service is RUNNING."""
180-
if sys.platform != "win32":
181-
return False
182-
try:
183-
result = subprocess.run(
184-
["sc", "query", LocalAgentOsServer._ASKUI_CORE_SERVICE_NAME],
185-
capture_output=True,
186-
text=True,
187-
timeout=5,
188-
check=False,
189-
)
190-
except (OSError, subprocess.SubprocessError):
191-
error_msg = (
192-
f"Failed to query {LocalAgentOsServer._ASKUI_CORE_SERVICE_NAME} service"
193-
)
194-
logger.debug(error_msg)
195-
return False
196-
if result.returncode != 0:
197-
return False
198-
return "RUNNING" in result.stdout.upper()
180+
if sys.platform == "win32":
181+
try:
182+
result = subprocess.run(
183+
["sc", "query", LocalAgentOsServer._ASKUI_CORE_SERVICE_NAME],
184+
capture_output=True,
185+
text=True,
186+
timeout=5,
187+
check=False,
188+
)
189+
except (OSError, subprocess.SubprocessError):
190+
error_msg = (
191+
"Failed to query "
192+
f"{LocalAgentOsServer._ASKUI_CORE_SERVICE_NAME} service"
193+
)
194+
logger.debug(error_msg)
195+
return False
196+
if result.returncode != 0:
197+
return False
198+
return "RUNNING" in result.stdout.upper()
199+
return False
199200

200201
def _parse_port(self) -> int:
201202
addr = self._address if "://" in self._address else "//" + self._address

tests/conftest.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pytest_mock import MockerFixture
77

88
from askui.tools.agent_os import AgentOs, Display, DisplaySize
9-
from askui.tools.toolbox import AgentToolbox
109

1110

1211
@pytest.fixture
@@ -97,9 +96,13 @@ def agent_os_mock(mocker: MockerFixture) -> AgentOs:
9796

9897

9998
@pytest.fixture
100-
def agent_toolbox_mock(agent_os_mock: AgentOs) -> AgentToolbox:
101-
"""Fixture providing a mock agent toolbox."""
102-
return AgentToolbox(agent_os=agent_os_mock)
99+
def agent_os_mock_patch(mocker: MockerFixture, agent_os_mock: AgentOs) -> AgentOs:
100+
"""Patches `AskUiControllerClient` so `ComputerAgent` uses `agent_os_mock`."""
101+
mocker.patch(
102+
"askui.computer_agent.AskUiControllerClient",
103+
return_value=agent_os_mock,
104+
)
105+
return agent_os_mock
103106

104107

105108
@pytest.fixture(autouse=True)

tests/e2e/agent/conftest.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from askui.models.shared.settings import LocateSettings
2828
from askui.models.types.geometry import PointList
2929
from askui.reporting import Reporter, SimpleHtmlReporter
30-
from askui.tools.toolbox import AgentToolbox
30+
from askui.tools.agent_os import AgentOs
3131
from askui.utils.image_utils import ImageSource
3232

3333

@@ -98,75 +98,70 @@ def combo_locate_model(path_fixtures: pathlib.Path) -> LocateModel:
9898
@pytest.fixture
9999
def agent_with_pta_model(
100100
pta_locate_model: LocateModel,
101-
agent_toolbox_mock: AgentToolbox,
101+
agent_os_mock_patch: AgentOs, # noqa: ARG001
102102
simple_html_reporter: Reporter,
103103
) -> Generator[ComputerAgent, None, None]:
104104
with ComputerAgent(
105105
settings=AgentSettings(
106106
detection_provider=_LocateModelDetectionProvider(pta_locate_model)
107107
),
108108
reporters=[simple_html_reporter],
109-
tools=agent_toolbox_mock,
110109
) as agent:
111110
yield agent
112111

113112

114113
@pytest.fixture
115114
def agent_with_ocr_model(
116115
ocr_locate_model: LocateModel,
117-
agent_toolbox_mock: AgentToolbox,
116+
agent_os_mock_patch: AgentOs, # noqa: ARG001
118117
simple_html_reporter: Reporter,
119118
) -> Generator[ComputerAgent, None, None]:
120119
with ComputerAgent(
121120
settings=AgentSettings(
122121
detection_provider=_LocateModelDetectionProvider(ocr_locate_model)
123122
),
124123
reporters=[simple_html_reporter],
125-
tools=agent_toolbox_mock,
126124
) as agent:
127125
yield agent
128126

129127

130128
@pytest.fixture
131129
def agent_with_ai_element_model(
132130
ai_element_locate_model: LocateModel,
133-
agent_toolbox_mock: AgentToolbox,
131+
agent_os_mock_patch: AgentOs, # noqa: ARG001
134132
simple_html_reporter: Reporter,
135133
) -> Generator[ComputerAgent, None, None]:
136134
with ComputerAgent(
137135
settings=AgentSettings(
138136
detection_provider=_LocateModelDetectionProvider(ai_element_locate_model)
139137
),
140138
reporters=[simple_html_reporter],
141-
tools=agent_toolbox_mock,
142139
) as agent:
143140
yield agent
144141

145142

146143
@pytest.fixture
147144
def agent_with_combo_model(
148145
combo_locate_model: LocateModel,
149-
agent_toolbox_mock: AgentToolbox,
146+
agent_os_mock_patch: AgentOs, # noqa: ARG001
150147
simple_html_reporter: Reporter,
151148
) -> Generator[ComputerAgent, None, None]:
152149
with ComputerAgent(
153150
settings=AgentSettings(
154151
detection_provider=_LocateModelDetectionProvider(combo_locate_model)
155152
),
156153
reporters=[simple_html_reporter],
157-
tools=agent_toolbox_mock,
158154
) as agent:
159155
yield agent
160156

161157

162158
@pytest.fixture
163159
def vision_agent(
164-
agent_toolbox_mock: AgentToolbox,
160+
agent_os_mock_patch: AgentOs, # noqa: ARG001
165161
simple_html_reporter: Reporter,
166162
) -> Generator[ComputerAgent, None, None]:
167163
"""Fixture providing a ComputerAgent instance."""
168164
with ComputerAgent(
169165
reporters=[simple_html_reporter],
170-
tools=agent_toolbox_mock,
171166
) as agent:
172167
yield agent

0 commit comments

Comments
 (0)