hud-python 0.3.2__py3-none-any.whl → 0.3.4__py3-none-any.whl
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.
Potentially problematic release.
This version of hud-python might be problematic. Click here for more details.
- hud/__init__.py +30 -4
- hud/datasets.py +7 -3
- hud/task.py +7 -0
- hud/taskset.py +17 -2
- hud/tools/computer/anthropic.py +6 -3
- hud/tools/computer/hud.py +4 -4
- hud/tools/computer/openai.py +4 -1
- hud/tools/executors/base.py +202 -1
- hud/utils/__init__.py +10 -1
- hud/utils/deprecation.py +115 -0
- hud/utils/tests/test_version.py +1 -1
- hud/version.py +1 -1
- {hud_python-0.3.2.dist-info → hud_python-0.3.4.dist-info}/METADATA +3 -3
- {hud_python-0.3.2.dist-info → hud_python-0.3.4.dist-info}/RECORD +16 -15
- {hud_python-0.3.2.dist-info → hud_python-0.3.4.dist-info}/WHEEL +0 -0
- {hud_python-0.3.2.dist-info → hud_python-0.3.4.dist-info}/licenses/LICENSE +0 -0
hud/__init__.py
CHANGED
|
@@ -4,16 +4,44 @@ HUD SDK for interacting with the HUD evaluation platform.
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
+
import warnings
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
7
10
|
from . import agent, datasets, env, gym, settings, task, taskset, types, utils
|
|
8
11
|
from .adapters import ResponseAction as Response
|
|
9
12
|
from .datasets import run_dataset, to_taskconfigs
|
|
10
13
|
from .job import create_job, load_job, run_job
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
|
|
15
|
+
# Import deprecated items with deferred warning
|
|
16
|
+
from .task import Task as _Task
|
|
17
|
+
from .taskset import load_taskset as _load_taskset
|
|
13
18
|
from .telemetry import flush, job, trace, trace_open # New context-based job
|
|
14
19
|
from .version import __version__
|
|
15
20
|
|
|
16
21
|
|
|
22
|
+
def __getattr__(name: str) -> Any:
|
|
23
|
+
"""Emit deprecation warnings for deprecated imports."""
|
|
24
|
+
if name == "Task":
|
|
25
|
+
warnings.warn(
|
|
26
|
+
"Importing Task from hud is deprecated. "
|
|
27
|
+
"Use hud.datasets.TaskConfig instead. "
|
|
28
|
+
"Task will be removed in v0.4.0.",
|
|
29
|
+
DeprecationWarning,
|
|
30
|
+
stacklevel=2,
|
|
31
|
+
)
|
|
32
|
+
return _Task
|
|
33
|
+
elif name == "load_taskset":
|
|
34
|
+
warnings.warn(
|
|
35
|
+
"Importing load_taskset from hud is deprecated. "
|
|
36
|
+
"Use hud-evals HuggingFace datasets instead. "
|
|
37
|
+
"load_taskset will be removed in v0.4.0.",
|
|
38
|
+
DeprecationWarning,
|
|
39
|
+
stacklevel=2,
|
|
40
|
+
)
|
|
41
|
+
return _load_taskset
|
|
42
|
+
raise AttributeError(f"module 'hud' has no attribute '{name}'")
|
|
43
|
+
|
|
44
|
+
|
|
17
45
|
def init_telemetry() -> None:
|
|
18
46
|
from .telemetry import init_telemetry as _init_telemetry
|
|
19
47
|
|
|
@@ -38,7 +66,6 @@ if settings.settings.fancy_logging:
|
|
|
38
66
|
|
|
39
67
|
__all__ = [
|
|
40
68
|
"Response",
|
|
41
|
-
"Task",
|
|
42
69
|
"__version__",
|
|
43
70
|
"agent",
|
|
44
71
|
"create_job",
|
|
@@ -49,7 +76,6 @@ __all__ = [
|
|
|
49
76
|
"init_telemetry",
|
|
50
77
|
"job",
|
|
51
78
|
"load_job",
|
|
52
|
-
"load_taskset",
|
|
53
79
|
"run_dataset",
|
|
54
80
|
"run_job",
|
|
55
81
|
"settings",
|
hud/datasets.py
CHANGED
|
@@ -33,7 +33,8 @@ class TaskConfig(BaseModel):
|
|
|
33
33
|
"url": "${HUD_MCP_URL:https://mcp.hud.so/v3/mcp}",
|
|
34
34
|
"headers": {
|
|
35
35
|
"Authorization": "Bearer ${HUD_API_KEY}",
|
|
36
|
-
"Run-Id": "${RUN_ID}"
|
|
36
|
+
"Run-Id": "${RUN_ID}",
|
|
37
|
+
"Mcp-Image": "your-mcp-image"
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -73,8 +74,11 @@ class TaskConfig(BaseModel):
|
|
|
73
74
|
def substitute_in_value(obj: Any) -> Any:
|
|
74
75
|
"""Recursively substitute variables in nested structures."""
|
|
75
76
|
if isinstance(obj, str):
|
|
76
|
-
# Use Template's
|
|
77
|
-
|
|
77
|
+
# Use Template's substitute with defaultdict - missing vars become empty strings
|
|
78
|
+
from collections import defaultdict
|
|
79
|
+
|
|
80
|
+
safe_mapping = defaultdict(str, mapping)
|
|
81
|
+
return Template(obj).substitute(safe_mapping)
|
|
78
82
|
elif isinstance(obj, dict):
|
|
79
83
|
return {k: substitute_in_value(v) for k, v in obj.items()}
|
|
80
84
|
elif isinstance(obj, list):
|
hud/task.py
CHANGED
|
@@ -7,11 +7,18 @@ from pydantic import BaseModel, Field
|
|
|
7
7
|
|
|
8
8
|
from hud.types import CustomGym, Gym, MetadataKeys, SensitiveData
|
|
9
9
|
from hud.utils.common import FunctionConfigs
|
|
10
|
+
from hud.utils.deprecation import deprecated
|
|
10
11
|
|
|
11
12
|
if TYPE_CHECKING:
|
|
12
13
|
from hud.agent import Agent
|
|
13
14
|
|
|
14
15
|
|
|
16
|
+
@deprecated(
|
|
17
|
+
reason="Task class is being replaced by TaskConfig for better MCP integration",
|
|
18
|
+
replacement="hud.datasets.TaskConfig",
|
|
19
|
+
version="0.3.0",
|
|
20
|
+
removal_version="0.4.0",
|
|
21
|
+
)
|
|
15
22
|
class Task(BaseModel):
|
|
16
23
|
"""A task that can be executed and evaluated.
|
|
17
24
|
|
hud/taskset.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import logging
|
|
3
4
|
from pathlib import Path
|
|
4
5
|
from typing import TYPE_CHECKING, Any, get_args
|
|
5
|
-
from venv import logger
|
|
6
6
|
|
|
7
7
|
from pydantic import BaseModel
|
|
8
8
|
|
|
@@ -12,6 +12,9 @@ from hud.settings import settings
|
|
|
12
12
|
from hud.task import Task
|
|
13
13
|
from hud.types import CustomGym, ServerGym
|
|
14
14
|
from hud.utils.config import REMOTE_EVALUATE, REMOTE_SETUP
|
|
15
|
+
from hud.utils.deprecation import deprecated
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
15
18
|
|
|
16
19
|
if TYPE_CHECKING:
|
|
17
20
|
from collections.abc import Iterator
|
|
@@ -19,6 +22,12 @@ if TYPE_CHECKING:
|
|
|
19
22
|
from hud.agent import Agent
|
|
20
23
|
|
|
21
24
|
|
|
25
|
+
@deprecated(
|
|
26
|
+
reason="TaskSet class is being replaced by HuggingFace datasets on hud-evals",
|
|
27
|
+
replacement="Use TaskConfig-based collections or hud.datasets module",
|
|
28
|
+
version="0.3.0",
|
|
29
|
+
removal_version="0.4.0",
|
|
30
|
+
)
|
|
22
31
|
class TaskSet(BaseModel):
|
|
23
32
|
"""
|
|
24
33
|
Collection of related tasks for benchmarking.
|
|
@@ -163,6 +172,12 @@ class TaskSet(BaseModel):
|
|
|
163
172
|
task.gym = agent.transfer_gyms.get(task.gym, task.gym)
|
|
164
173
|
|
|
165
174
|
|
|
175
|
+
@deprecated(
|
|
176
|
+
reason="load_taskset is being replaced by new dataset loading mechanisms for MCP-based tasks",
|
|
177
|
+
replacement="Use TaskConfig-based dataset loading from hud.datasets module",
|
|
178
|
+
version="0.3.0",
|
|
179
|
+
removal_version="0.4.0",
|
|
180
|
+
)
|
|
166
181
|
async def load_taskset(
|
|
167
182
|
taskset_id: str,
|
|
168
183
|
api_key: str | None = None,
|
|
@@ -192,7 +207,7 @@ async def load_taskset(
|
|
|
192
207
|
api_key=api_key,
|
|
193
208
|
)
|
|
194
209
|
|
|
195
|
-
logger.info(
|
|
210
|
+
logger.info("Taskset %s loaded successfully", taskset_id)
|
|
196
211
|
|
|
197
212
|
tasks = data["evalset"]
|
|
198
213
|
for task in tasks:
|
hud/tools/computer/anthropic.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
4
|
import logging
|
|
5
|
-
from typing import TYPE_CHECKING, Literal, cast
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Literal, cast
|
|
6
6
|
|
|
7
7
|
from mcp import ErrorData, McpError
|
|
8
8
|
from mcp.types import INTERNAL_ERROR, INVALID_PARAMS, ImageContent, TextContent
|
|
@@ -71,19 +71,21 @@ class AnthropicComputerTool(HudComputerTool):
|
|
|
71
71
|
display_num: int | None = None,
|
|
72
72
|
platform_type: Literal["auto", "xdo", "pyautogui"] = "auto",
|
|
73
73
|
rescale_images: bool = False,
|
|
74
|
+
**kwargs: Any,
|
|
74
75
|
) -> None:
|
|
75
76
|
"""
|
|
76
77
|
Initialize with Anthropic's default dimensions.
|
|
77
78
|
|
|
78
79
|
Args:
|
|
79
|
-
width: Target width for rescaling (default:
|
|
80
|
-
height: Target height for rescaling (default:
|
|
80
|
+
width: Target width for rescaling (default: 1400 for Anthropic)
|
|
81
|
+
height: Target height for rescaling (default: 850 for Anthropic)
|
|
81
82
|
display_num: X display number
|
|
82
83
|
platform_type: Which executor to use:
|
|
83
84
|
- "auto": Automatically detect based on platform
|
|
84
85
|
- "xdo": Use XDOExecutor (Linux/X11 only)
|
|
85
86
|
- "pyautogui": Use PyAutoGUIExecutor (cross-platform)
|
|
86
87
|
rescale_images: If True, rescale screenshots. If False, only rescale action coordinates
|
|
88
|
+
**kwargs: Additional arguments passed to HudComputerTool (e.g., executor)
|
|
87
89
|
"""
|
|
88
90
|
super().__init__(
|
|
89
91
|
width=width,
|
|
@@ -91,6 +93,7 @@ class AnthropicComputerTool(HudComputerTool):
|
|
|
91
93
|
display_num=display_num,
|
|
92
94
|
platform_type=platform_type,
|
|
93
95
|
rescale_images=rescale_images,
|
|
96
|
+
**kwargs,
|
|
94
97
|
)
|
|
95
98
|
|
|
96
99
|
def to_params(self) -> BetaToolComputerUse20250124Param:
|
hud/tools/computer/hud.py
CHANGED
|
@@ -31,7 +31,7 @@ class HudComputerTool:
|
|
|
31
31
|
height: int | None = None,
|
|
32
32
|
display_num: int | None = None,
|
|
33
33
|
platform_type: Literal["auto", "xdo", "pyautogui"] = "auto",
|
|
34
|
-
|
|
34
|
+
custom_executor: BaseExecutor | None = None,
|
|
35
35
|
rescale_images: bool = False,
|
|
36
36
|
) -> None:
|
|
37
37
|
"""
|
|
@@ -45,7 +45,7 @@ class HudComputerTool:
|
|
|
45
45
|
- "auto": Automatically detect based on platform
|
|
46
46
|
- "xdo": Use XDOExecutor (Linux/X11 only)
|
|
47
47
|
- "pyautogui": Use PyAutoGUIExecutor (cross-platform)
|
|
48
|
-
|
|
48
|
+
custom_executor: If None, executor class will be determined based on platform_type.
|
|
49
49
|
rescale_images: If True, rescale screenshots. If False, only rescale action coordinates
|
|
50
50
|
"""
|
|
51
51
|
# Use provided dimensions or defaults
|
|
@@ -72,10 +72,10 @@ class HudComputerTool:
|
|
|
72
72
|
# Check if we need to scale
|
|
73
73
|
self.needs_scaling = self.scale != 1.0
|
|
74
74
|
|
|
75
|
-
if
|
|
75
|
+
if custom_executor is None:
|
|
76
76
|
self._choose_executor(platform_type, display_num)
|
|
77
77
|
else:
|
|
78
|
-
self.executor =
|
|
78
|
+
self.executor = custom_executor
|
|
79
79
|
|
|
80
80
|
def _choose_executor(
|
|
81
81
|
self,
|
hud/tools/computer/openai.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
4
|
import logging
|
|
5
|
-
from typing import Literal, cast
|
|
5
|
+
from typing import Any, Literal, cast
|
|
6
6
|
|
|
7
7
|
from mcp import ErrorData, McpError
|
|
8
8
|
from mcp.types import INTERNAL_ERROR, INVALID_PARAMS, ImageContent, TextContent
|
|
@@ -54,6 +54,7 @@ class OpenAIComputerTool(HudComputerTool):
|
|
|
54
54
|
display_num: int | None = None,
|
|
55
55
|
platform_type: Literal["auto", "xdo", "pyautogui"] = "auto",
|
|
56
56
|
rescale_images: bool = False,
|
|
57
|
+
**kwargs: Any,
|
|
57
58
|
) -> None:
|
|
58
59
|
"""
|
|
59
60
|
Initialize with OpenAI's default dimensions.
|
|
@@ -67,6 +68,7 @@ class OpenAIComputerTool(HudComputerTool):
|
|
|
67
68
|
- "xdo": Use XDOExecutor (Linux/X11 only)
|
|
68
69
|
- "pyautogui": Use PyAutoGUIExecutor (cross-platform)
|
|
69
70
|
rescale_images: If True, rescale screenshots. If False, only rescale action coordinates
|
|
71
|
+
**kwargs: Additional arguments passed to HudComputerTool (e.g., executor)
|
|
70
72
|
"""
|
|
71
73
|
super().__init__(
|
|
72
74
|
width=width,
|
|
@@ -74,6 +76,7 @@ class OpenAIComputerTool(HudComputerTool):
|
|
|
74
76
|
display_num=display_num,
|
|
75
77
|
platform_type=platform_type,
|
|
76
78
|
rescale_images=rescale_images,
|
|
79
|
+
**kwargs,
|
|
77
80
|
)
|
|
78
81
|
|
|
79
82
|
def _map_openai_key_to_cla(self, key: str) -> str:
|
hud/tools/executors/base.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import logging
|
|
5
|
-
from typing import Literal
|
|
5
|
+
from typing import Literal, TypeAlias
|
|
6
6
|
|
|
7
7
|
from hud.tools.base import ToolResult
|
|
8
8
|
|
|
@@ -329,3 +329,204 @@ class BaseExecutor:
|
|
|
329
329
|
async def mouse_move(self, x: int, y: int, take_screenshot: bool = True) -> ToolResult:
|
|
330
330
|
"""Alias for move() to maintain compatibility."""
|
|
331
331
|
return await self.move(x=x, y=y, take_screenshot=take_screenshot)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
CLAKey: TypeAlias = Literal[
|
|
335
|
+
# Control keys
|
|
336
|
+
"backspace",
|
|
337
|
+
"tab",
|
|
338
|
+
"enter",
|
|
339
|
+
"shift",
|
|
340
|
+
"shiftleft",
|
|
341
|
+
"shiftright",
|
|
342
|
+
"ctrl",
|
|
343
|
+
"ctrlleft",
|
|
344
|
+
"ctrlright",
|
|
345
|
+
"alt",
|
|
346
|
+
"altleft",
|
|
347
|
+
"altright",
|
|
348
|
+
"pause",
|
|
349
|
+
"capslock",
|
|
350
|
+
"esc",
|
|
351
|
+
"escape",
|
|
352
|
+
"space",
|
|
353
|
+
"pageup",
|
|
354
|
+
"pagedown",
|
|
355
|
+
"end",
|
|
356
|
+
"home",
|
|
357
|
+
"left",
|
|
358
|
+
"up",
|
|
359
|
+
"right",
|
|
360
|
+
"down",
|
|
361
|
+
"select",
|
|
362
|
+
"print",
|
|
363
|
+
"execute",
|
|
364
|
+
"printscreen",
|
|
365
|
+
"prtsc",
|
|
366
|
+
"insert",
|
|
367
|
+
"delete",
|
|
368
|
+
"help",
|
|
369
|
+
"sleep",
|
|
370
|
+
# Special keys
|
|
371
|
+
"numlock",
|
|
372
|
+
"scrolllock",
|
|
373
|
+
"clear",
|
|
374
|
+
"separator",
|
|
375
|
+
"modechange",
|
|
376
|
+
"apps",
|
|
377
|
+
"browserback",
|
|
378
|
+
"browserfavorites",
|
|
379
|
+
"browserforward",
|
|
380
|
+
"browserhome",
|
|
381
|
+
"browserrefresh",
|
|
382
|
+
"browsersearch",
|
|
383
|
+
"browserstop",
|
|
384
|
+
"launchapp1",
|
|
385
|
+
"launchapp2",
|
|
386
|
+
"launchmail",
|
|
387
|
+
"launchmediaselect",
|
|
388
|
+
"playpause",
|
|
389
|
+
"start",
|
|
390
|
+
"stop",
|
|
391
|
+
"prevtrack",
|
|
392
|
+
"nexttrack",
|
|
393
|
+
"volumemute",
|
|
394
|
+
"volumeup",
|
|
395
|
+
"volumedown",
|
|
396
|
+
"zoom",
|
|
397
|
+
# Modifier keys
|
|
398
|
+
"win",
|
|
399
|
+
"winleft",
|
|
400
|
+
"winright",
|
|
401
|
+
"command",
|
|
402
|
+
"option",
|
|
403
|
+
"optionleft",
|
|
404
|
+
"optionright",
|
|
405
|
+
"fn",
|
|
406
|
+
# Numpad keys
|
|
407
|
+
"num0",
|
|
408
|
+
"num1",
|
|
409
|
+
"num2",
|
|
410
|
+
"num3",
|
|
411
|
+
"num4",
|
|
412
|
+
"num5",
|
|
413
|
+
"num6",
|
|
414
|
+
"num7",
|
|
415
|
+
"num8",
|
|
416
|
+
"num9",
|
|
417
|
+
"multiply",
|
|
418
|
+
"add",
|
|
419
|
+
"subtract",
|
|
420
|
+
"decimal",
|
|
421
|
+
"divide",
|
|
422
|
+
# Function keys
|
|
423
|
+
"f1",
|
|
424
|
+
"f2",
|
|
425
|
+
"f3",
|
|
426
|
+
"f4",
|
|
427
|
+
"f5",
|
|
428
|
+
"f6",
|
|
429
|
+
"f7",
|
|
430
|
+
"f8",
|
|
431
|
+
"f9",
|
|
432
|
+
"f10",
|
|
433
|
+
"f11",
|
|
434
|
+
"f12",
|
|
435
|
+
"f13",
|
|
436
|
+
"f14",
|
|
437
|
+
"f15",
|
|
438
|
+
"f16",
|
|
439
|
+
"f17",
|
|
440
|
+
"f18",
|
|
441
|
+
"f19",
|
|
442
|
+
"f20",
|
|
443
|
+
"f21",
|
|
444
|
+
"f22",
|
|
445
|
+
"f23",
|
|
446
|
+
"f24",
|
|
447
|
+
# Language-specific keys
|
|
448
|
+
"hanguel",
|
|
449
|
+
"hangul",
|
|
450
|
+
"hanja",
|
|
451
|
+
"kana",
|
|
452
|
+
"kanji",
|
|
453
|
+
"junja",
|
|
454
|
+
"convert",
|
|
455
|
+
"nonconvert",
|
|
456
|
+
"yen",
|
|
457
|
+
# Characters
|
|
458
|
+
"\t",
|
|
459
|
+
"\n",
|
|
460
|
+
"\r",
|
|
461
|
+
" ",
|
|
462
|
+
"!",
|
|
463
|
+
'"',
|
|
464
|
+
"#",
|
|
465
|
+
"$",
|
|
466
|
+
"%",
|
|
467
|
+
"&",
|
|
468
|
+
"'",
|
|
469
|
+
"(",
|
|
470
|
+
")",
|
|
471
|
+
"*",
|
|
472
|
+
"+",
|
|
473
|
+
",",
|
|
474
|
+
"-",
|
|
475
|
+
".",
|
|
476
|
+
"/",
|
|
477
|
+
"0",
|
|
478
|
+
"1",
|
|
479
|
+
"2",
|
|
480
|
+
"3",
|
|
481
|
+
"4",
|
|
482
|
+
"5",
|
|
483
|
+
"6",
|
|
484
|
+
"7",
|
|
485
|
+
"8",
|
|
486
|
+
"9",
|
|
487
|
+
":",
|
|
488
|
+
";",
|
|
489
|
+
"<",
|
|
490
|
+
"=",
|
|
491
|
+
">",
|
|
492
|
+
"?",
|
|
493
|
+
"@",
|
|
494
|
+
"[",
|
|
495
|
+
"\\",
|
|
496
|
+
"]",
|
|
497
|
+
"^",
|
|
498
|
+
"_",
|
|
499
|
+
"`",
|
|
500
|
+
"a",
|
|
501
|
+
"b",
|
|
502
|
+
"c",
|
|
503
|
+
"d",
|
|
504
|
+
"e",
|
|
505
|
+
"f",
|
|
506
|
+
"g",
|
|
507
|
+
"h",
|
|
508
|
+
"i",
|
|
509
|
+
"j",
|
|
510
|
+
"k",
|
|
511
|
+
"l",
|
|
512
|
+
"m",
|
|
513
|
+
"n",
|
|
514
|
+
"o",
|
|
515
|
+
"p",
|
|
516
|
+
"q",
|
|
517
|
+
"r",
|
|
518
|
+
"s",
|
|
519
|
+
"t",
|
|
520
|
+
"u",
|
|
521
|
+
"v",
|
|
522
|
+
"w",
|
|
523
|
+
"x",
|
|
524
|
+
"y",
|
|
525
|
+
"z",
|
|
526
|
+
"{",
|
|
527
|
+
"|",
|
|
528
|
+
"}",
|
|
529
|
+
"~",
|
|
530
|
+
]
|
|
531
|
+
|
|
532
|
+
CLAButton: TypeAlias = Literal["left", "right", "middle", "back", "forward"]
|
hud/utils/__init__.py
CHANGED
|
@@ -2,6 +2,15 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from .common import ExecuteResult
|
|
4
4
|
from .config import FunctionConfig, FunctionConfigs, expand_config
|
|
5
|
+
from .deprecation import deprecated, emit_deprecation_warning
|
|
5
6
|
from .telemetry import stream
|
|
6
7
|
|
|
7
|
-
__all__ = [
|
|
8
|
+
__all__ = [
|
|
9
|
+
"ExecuteResult",
|
|
10
|
+
"FunctionConfig",
|
|
11
|
+
"FunctionConfigs",
|
|
12
|
+
"deprecated",
|
|
13
|
+
"emit_deprecation_warning",
|
|
14
|
+
"expand_config",
|
|
15
|
+
"stream",
|
|
16
|
+
]
|
hud/utils/deprecation.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Deprecation utilities for HUD SDK."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import functools
|
|
6
|
+
import logging
|
|
7
|
+
import warnings
|
|
8
|
+
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from collections.abc import Callable
|
|
14
|
+
T = TypeVar("T")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def deprecated(
|
|
18
|
+
reason: str,
|
|
19
|
+
*,
|
|
20
|
+
version: str | None = None,
|
|
21
|
+
replacement: str | None = None,
|
|
22
|
+
removal_version: str | None = None,
|
|
23
|
+
) -> Callable[[T], T]:
|
|
24
|
+
"""
|
|
25
|
+
Decorator to mark functions, methods, or classes as deprecated.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
reason: Explanation of why this is deprecated
|
|
29
|
+
version: Version when this was deprecated (e.g., "1.0.0")
|
|
30
|
+
replacement: What to use instead
|
|
31
|
+
removal_version: Version when this will be removed
|
|
32
|
+
|
|
33
|
+
Example:
|
|
34
|
+
@deprecated(
|
|
35
|
+
reason="Use TaskConfig instead",
|
|
36
|
+
replacement="hud.datasets.TaskConfig",
|
|
37
|
+
version="0.3.0",
|
|
38
|
+
removal_version="0.4.0"
|
|
39
|
+
)
|
|
40
|
+
class OldClass:
|
|
41
|
+
pass
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
def decorator(obj: T) -> T:
|
|
45
|
+
message_parts = [f"{obj.__module__}.{obj.__qualname__} is deprecated"]
|
|
46
|
+
|
|
47
|
+
if version:
|
|
48
|
+
message_parts.append(f"(deprecated since v{version})")
|
|
49
|
+
|
|
50
|
+
message_parts.append(f": {reason}")
|
|
51
|
+
|
|
52
|
+
if replacement:
|
|
53
|
+
message_parts.append(f". Use {replacement} instead")
|
|
54
|
+
|
|
55
|
+
if removal_version:
|
|
56
|
+
message_parts.append(f". Will be removed in v{removal_version}")
|
|
57
|
+
|
|
58
|
+
deprecation_message = " ".join(message_parts) + "."
|
|
59
|
+
|
|
60
|
+
if isinstance(obj, type):
|
|
61
|
+
# Handle class deprecation
|
|
62
|
+
original_init = obj.__init__
|
|
63
|
+
|
|
64
|
+
@functools.wraps(original_init)
|
|
65
|
+
def new_init(self: Any, *args: Any, **kwargs: Any) -> None:
|
|
66
|
+
warnings.warn(deprecation_message, DeprecationWarning, stacklevel=2)
|
|
67
|
+
logger.warning(deprecation_message)
|
|
68
|
+
original_init(self, *args, **kwargs)
|
|
69
|
+
|
|
70
|
+
obj.__init__ = new_init
|
|
71
|
+
|
|
72
|
+
# Update docstring
|
|
73
|
+
if obj.__doc__:
|
|
74
|
+
obj.__doc__ = f"**DEPRECATED**: {deprecation_message}\n\n{obj.__doc__}"
|
|
75
|
+
else:
|
|
76
|
+
obj.__doc__ = f"**DEPRECATED**: {deprecation_message}"
|
|
77
|
+
|
|
78
|
+
else:
|
|
79
|
+
# Handle function/method deprecation
|
|
80
|
+
func = cast("Callable[..., Any]", obj)
|
|
81
|
+
|
|
82
|
+
@functools.wraps(func)
|
|
83
|
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
84
|
+
warnings.warn(deprecation_message, DeprecationWarning, stacklevel=2)
|
|
85
|
+
logger.warning(deprecation_message)
|
|
86
|
+
return func(*args, **kwargs)
|
|
87
|
+
|
|
88
|
+
# Update docstring
|
|
89
|
+
if wrapper.__doc__:
|
|
90
|
+
wrapper.__doc__ = f"**DEPRECATED**: {deprecation_message}\n\n{wrapper.__doc__}"
|
|
91
|
+
else:
|
|
92
|
+
wrapper.__doc__ = f"**DEPRECATED**: {deprecation_message}"
|
|
93
|
+
|
|
94
|
+
return cast("T", wrapper)
|
|
95
|
+
|
|
96
|
+
return obj
|
|
97
|
+
|
|
98
|
+
return decorator
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def emit_deprecation_warning(
|
|
102
|
+
message: str,
|
|
103
|
+
category: type[Warning] = DeprecationWarning,
|
|
104
|
+
stacklevel: int = 2,
|
|
105
|
+
) -> None:
|
|
106
|
+
"""
|
|
107
|
+
Emit a deprecation warning with both warnings and logging.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
message: The deprecation message
|
|
111
|
+
category: Warning category (default: DeprecationWarning)
|
|
112
|
+
stacklevel: Stack level for warning (default: 2)
|
|
113
|
+
"""
|
|
114
|
+
warnings.warn(message, category, stacklevel=stacklevel)
|
|
115
|
+
logger.warning(message)
|
hud/utils/tests/test_version.py
CHANGED
hud/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hud-python
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: SDK for the HUD platform.
|
|
5
5
|
Project-URL: Homepage, https://github.com/hud-evals/hud-python
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/hud-evals/hud-python/issues
|
|
@@ -36,14 +36,14 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
36
36
|
Classifier: Programming Language :: Python :: 3.13
|
|
37
37
|
Requires-Python: <3.14,>=3.11
|
|
38
38
|
Requires-Dist: anthropic
|
|
39
|
-
Requires-Dist: datasets>=
|
|
39
|
+
Requires-Dist: datasets>=2.14.0
|
|
40
40
|
Requires-Dist: dotenv>=0.9.9
|
|
41
41
|
Requires-Dist: httpx<1,>=0.23.0
|
|
42
42
|
Requires-Dist: langchain
|
|
43
43
|
Requires-Dist: langchain-anthropic
|
|
44
44
|
Requires-Dist: langchain-openai
|
|
45
45
|
Requires-Dist: mcp-use>=1.3.7
|
|
46
|
-
Requires-Dist: mcp
|
|
46
|
+
Requires-Dist: mcp>=1.12.2
|
|
47
47
|
Requires-Dist: openai
|
|
48
48
|
Requires-Dist: pathspec>=0.12.1
|
|
49
49
|
Requires-Dist: pydantic-settings<3,>=2
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
hud/__init__.py,sha256=
|
|
2
|
-
hud/datasets.py,sha256=
|
|
1
|
+
hud/__init__.py,sha256=ro9AhwS9EwqnXjRbcZREmZnl6kEJIpWuKbDdmqXBWvo,2443
|
|
2
|
+
hud/datasets.py,sha256=HGMARvOUjNITbvNZTCr7eQ_PRcl4a1B_mtgjLhmQzDI,6369
|
|
3
3
|
hud/exceptions.py,sha256=Xna_pdEK_ESwkcffsRmT5GXq4xSHLV5cu7Qu3MjstSE,5516
|
|
4
4
|
hud/gym.py,sha256=-hp5HdPBWf6-j0CgSoX_f2CTLssf1Wo5UhfyrnPbvkc,4774
|
|
5
5
|
hud/job.py,sha256=0vWbr3E5bYstVRzXS_6l-57JGUFcrZpmFrNkOSQ8Aa0,26969
|
|
6
6
|
hud/settings.py,sha256=KPzeF9OUecApYH8YYMW-8vIRhFP_6htzzZvC4RCUARc,2183
|
|
7
|
-
hud/task.py,sha256=
|
|
8
|
-
hud/taskset.py,sha256=
|
|
7
|
+
hud/task.py,sha256=Ck26zeJzQmYmVzMwbcqIMkXoN_QRFr24B7CFDnhpOzc,5688
|
|
8
|
+
hud/taskset.py,sha256=8xNckJ_4_VPlBudD2l5jOfKMemVRJodf3uQzYJq8wDQ,7116
|
|
9
9
|
hud/trajectory.py,sha256=LBVkFz6U_rmyooCZHN81tdOx0Z7DuAgzf0KQLejc4Fo,3937
|
|
10
10
|
hud/types.py,sha256=h7fUowbdyGF4Fg8TUnvCFoa2fflRRPi6xx7YgpBwFis,3109
|
|
11
|
-
hud/version.py,sha256
|
|
11
|
+
hud/version.py,sha256=-iW4qkpS2PSBpSMSw7v6Wyv033KfYN7ckWvqvjly03M,104
|
|
12
12
|
hud/adapters/__init__.py,sha256=zz24KdC_e9TJPgWo6y57_8SzevEE5ak4Cm6tXzMxwRk,266
|
|
13
13
|
hud/adapters/claude/__init__.py,sha256=i7QEF-29FLb9qxp1eYtXs-adIk_tG54tL-9g6d3xodk,100
|
|
14
14
|
hud/adapters/claude/adapter.py,sha256=vCpotJ5gzQs4PP2iCXVavIcyG8c_4m1P6fuXStwUxSo,6675
|
|
@@ -74,11 +74,11 @@ hud/tools/edit.py,sha256=9vJ2XSnWOPViujQbZZuDjLahvzxoPHyAeXxgKfpUDHo,11796
|
|
|
74
74
|
hud/tools/playwright_tool.py,sha256=IQT1hk5U4H8BI988iZq0B2oS_fbgkaX01Z-ZXL4r71o,13724
|
|
75
75
|
hud/tools/utils.py,sha256=bfVyYMcBOJvr1QdptCjVb6jaHVGIL5WUxmY59kzMekQ,1447
|
|
76
76
|
hud/tools/computer/__init__.py,sha256=ehKY7u0_4cZ9h7YQlOQjbKPWfd5LhQq8ZQn2w2-l2mY,302
|
|
77
|
-
hud/tools/computer/anthropic.py,sha256=
|
|
78
|
-
hud/tools/computer/hud.py,sha256=
|
|
79
|
-
hud/tools/computer/openai.py,sha256=
|
|
77
|
+
hud/tools/computer/anthropic.py,sha256=uTK2bd5Hjjrus8Gj8Ac8cmT7nOuuAdh5Xcne9plNHvI,16240
|
|
78
|
+
hud/tools/computer/hud.py,sha256=mm3jHpWYGj39WI2VYkKPfhKtag74VbIdS-yUGAHBaXU,13859
|
|
79
|
+
hud/tools/computer/openai.py,sha256=bXZ1rVNZOj9xujeXVwKB4wUGZkC9T9_VFvEMqbLSSJg,10674
|
|
80
80
|
hud/tools/executors/__init__.py,sha256=jHxfus9SLhkL6YGtebR5RyKYyVAix3yu5EkUp2Q27Kg,732
|
|
81
|
-
hud/tools/executors/base.py,sha256=
|
|
81
|
+
hud/tools/executors/base.py,sha256=ZVdriSlO6XmhT8-123rYgd7K1DbeGaNRDiO4-oGYM_c,14180
|
|
82
82
|
hud/tools/executors/pyautogui.py,sha256=Kc2OcFw-sEuRBRFtO1ZrWeHs1p-p5FtEpESkzpRhOHk,22098
|
|
83
83
|
hud/tools/executors/xdo.py,sha256=C6ecIVPUba7c6vKpgIcNxKcc698hwelQjj4YYUxT2_4,17751
|
|
84
84
|
hud/tools/executors/tests/__init__.py,sha256=opFpGSH6cEqIZgt9izXd3Yt85pC7xkxiYmOZQTHf4AY,32
|
|
@@ -98,10 +98,11 @@ hud/tools/tests/test_init.py,sha256=PD_SS6X6SPhEjStJqYxdJRtsa7RbL6cTokAGIn5bWhA,
|
|
|
98
98
|
hud/tools/tests/test_playwright_tool.py,sha256=1qED_NF2QXUZmBRbWSmcKImMLUQ3m5CbA_9tLUiaxTQ,6696
|
|
99
99
|
hud/tools/tests/test_tools.py,sha256=KgSPgdqldpifbHeQHBFdYJVf3boWbvK6LRRRORPfTOg,4595
|
|
100
100
|
hud/tools/tests/test_utils.py,sha256=oYxEnLpSA5sEeYFGUTj74QRNv0AHP3AjmYYHXgIW0BY,5496
|
|
101
|
-
hud/utils/__init__.py,sha256=
|
|
101
|
+
hud/utils/__init__.py,sha256=WR1-DGxgZyIGdEsrKJqrJYXrN0Tq64cUs06NiiXK8EU,395
|
|
102
102
|
hud/utils/agent.py,sha256=CpNgjKWMaNqo-EATH_vfJHIN53rEkZngm2LXfUFlldQ,1225
|
|
103
103
|
hud/utils/common.py,sha256=_3HNmSOsHWyexP6iXTuU2wMx3Fafeg5hZU3VXBmv0Ag,7780
|
|
104
104
|
hud/utils/config.py,sha256=L_sSYtEaOap-Gnb2iLPJPQc2rteyt6mjOdJUrktmFwM,4020
|
|
105
|
+
hud/utils/deprecation.py,sha256=6XmX0C_0OvW55L2KgSWdSD8Lzy2OGtV9KPPJqOFDUXE,3430
|
|
105
106
|
hud/utils/misc.py,sha256=CfOv_ftLty1iEo3Rxyz4AD4nmaBkhCJVO_W-FlcyDgI,1481
|
|
106
107
|
hud/utils/progress.py,sha256=suikwFM8sdSfkV10nAOEaInDhG4XKgOSvFePg4jSj1A,5927
|
|
107
108
|
hud/utils/telemetry.py,sha256=hrVIx2rUjSGyy9IVxTZ_3Jii83PiHjyFRd5ls2whimM,1863
|
|
@@ -111,9 +112,9 @@ hud/utils/tests/test_config.py,sha256=dPlXYWuMrxX-NOYbf0vdJ27TJpfacKG8eiKOSGOcfD
|
|
|
111
112
|
hud/utils/tests/test_init.py,sha256=UxlNTwjlSE2q3M0R86EmMYmmXmbRvzZaC-S2av26QXI,529
|
|
112
113
|
hud/utils/tests/test_progress.py,sha256=QunwDgi_heQXhDgmC25zgjr-sFUu5FdJ_1aYigMKeIc,6351
|
|
113
114
|
hud/utils/tests/test_telemetry.py,sha256=t0An1RTBaE0dZVEpF4uwuq5k1R-PXFR5k4u71h60tx8,1224
|
|
114
|
-
hud/utils/tests/test_version.py,sha256=
|
|
115
|
+
hud/utils/tests/test_version.py,sha256=0oPeF4n4mCfNWykLo9xBQlJ9rh0VkzVQTIOfo1HdKFk,159
|
|
115
116
|
hud/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
116
|
-
hud_python-0.3.
|
|
117
|
-
hud_python-0.3.
|
|
118
|
-
hud_python-0.3.
|
|
119
|
-
hud_python-0.3.
|
|
117
|
+
hud_python-0.3.4.dist-info/METADATA,sha256=JHgz8WDAOg9bq7UJKRYxDiiaTKY6KX6Z992xsdL_Dkg,10250
|
|
118
|
+
hud_python-0.3.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
119
|
+
hud_python-0.3.4.dist-info/licenses/LICENSE,sha256=yIzBheVUf86FC1bztAcr7RYWWNxyd3B-UJQ3uddg1HA,1078
|
|
120
|
+
hud_python-0.3.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|