-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delegate trajectory export to exporters
- Loading branch information
Showing
9 changed files
with
28 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,9 @@ | ||
from lavague.action import Action | ||
from typing import ClassVar, Dict, Type, Optional, TypeVar | ||
|
||
T = TypeVar("T", bound="NavigationAction") | ||
from typing import Optional | ||
|
||
|
||
class NavigationAction(Action): | ||
"""Navigation action performed by the agent.""" | ||
|
||
subtypes: ClassVar[Dict[str, Type["NavigationAction"]]] = {} | ||
|
||
xpath: str | ||
value: Optional[str] = None | ||
|
||
@classmethod | ||
def parse(cls, action_dict: Dict) -> "NavigationAction": | ||
action_name = action_dict.get("action", "") | ||
target_type = cls.subtypes.get(action_name, NavigationAction) | ||
return target_type(**action_dict) | ||
|
||
@classmethod | ||
def register_subtype(cls, subtype: str, action: Type[T]): | ||
cls.subtypes[subtype] = action | ||
return cls | ||
|
||
|
||
def register_navigation(name: str): | ||
def wrapper(cls: Type[T]) -> Type[T]: | ||
NavigationAction.register_subtype(name, cls) | ||
return cls | ||
|
||
return wrapper | ||
|
||
|
||
class NavigationWithValueAction(NavigationAction): | ||
"""Navigation action performed by the agent with a value.""" | ||
|
||
value: str | ||
|
||
|
||
@register_navigation("click") | ||
class ClickAction(NavigationAction): | ||
pass | ||
|
||
|
||
@register_navigation("hover") | ||
class HoverAction(NavigationAction): | ||
pass | ||
|
||
|
||
@register_navigation("setValue") | ||
class SetValueAction(NavigationWithValueAction): | ||
pass | ||
|
||
|
||
@register_navigation("setValueAndEnter") | ||
class SetValueAndEnterAction(SetValueAction): | ||
pass | ||
|
||
|
||
@register_navigation("dropdownSelect") | ||
class DropdownSelectAction(NavigationWithValueAction): | ||
pass | ||
|
||
|
||
@register_navigation("scroll_down") | ||
class ScrollDownAction(NavigationAction): | ||
pass | ||
|
||
|
||
@register_navigation("scroll_up") | ||
class ScrollUpAction(NavigationAction): | ||
pass | ||
|
||
|
||
@register_navigation("back") | ||
class BackAction(NavigationAction): | ||
pass | ||
|
||
|
||
@register_navigation("switch_tab") | ||
class SwitchTabAction(NavigationAction): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from lavague.driver.base import BaseDriver | ||
from lavague.driver.base import BaseDriver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,4 +241,4 @@ | |
} | ||
traverse(document.body, '/html/body'); | ||
return results; | ||
""" | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1 @@ | ||
from lavague.exporter.base import ( | ||
TrajectoryExporter, | ||
ActionTranslator, | ||
ActionWrapper, | ||
method_action_translator, | ||
wrap_action_translator, | ||
translate_action, | ||
) | ||
from lavague.exporter.base import TrajectoryExporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from lavague.trajectory.base import Trajectory, TrajectoryStatus | ||
from lavague.trajectory.base import Trajectory, TrajectoryStatus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters