code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def set_tasks(self, tasks: List[str], task_contexts: Optional[List[Dict[str, Any]]] = None):
"""
Clears the current task list and sets new tasks from a list.
Each task should be a string.
Args:
tasks: A list of strings, each representing a task.
task_contexts: Op... |
Clears the current task list and sets new tasks from a list.
Each task should be a string.
Args:
tasks: A list of strings, each representing a task.
task_contexts: Optional list of context dictionaries for each task.
| set_tasks | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def add_task(self, task_description: str, task_context: Optional[Dict[str, Any]] = None):
"""
Adds a new task to the list with a 'pending' status.
Args:
task_description: The string describing the task.
task_context: Optional dictionary with context for the task.
... |
Adds a new task to the list with a 'pending' status.
Args:
task_description: The string describing the task.
task_context: Optional dictionary with context for the task.
Returns:
int: The index of the newly added task.
Raises:
ValueErro... | add_task | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def get_task(self, index: int):
"""
Retrieves a specific task by its index.
Args:
index: The integer index of the task.
Returns:
dict: The task dictionary {'description': str, 'status': str}.
Raises:
IndexError: If the index is out of bounds... |
Retrieves a specific task by its index.
Args:
index: The integer index of the task.
Returns:
dict: The task dictionary {'description': str, 'status': str}.
Raises:
IndexError: If the index is out of bounds.
| get_task | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def update_status(self, index: int, new_status: str, result_info: Optional[Dict[str, Any]] = None):
"""
Updates the status of a specific task.
Args:
index: The index of the task to update.
new_status: The new status string (must be one of VALID_STATUSES).
res... |
Updates the status of a specific task.
Args:
index: The index of the task to update.
new_status: The new status string (must be one of VALID_STATUSES).
result_info: Optional dictionary with additional information about the task result.
Raises:
I... | update_status | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def delete_task(self, index: int):
"""
Deletes a task by its index.
Args:
index: The index of the task to delete.
Raises:
IndexError: If the index is out of bounds.
"""
if 0 <= index < len(self.tasks):
del self.tasks[index]
... |
Deletes a task by its index.
Args:
index: The index of the task to delete.
Raises:
IndexError: If the index is out of bounds.
| delete_task | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def clear_tasks(self):
"""Removes all tasks from the list."""
self.tasks = []
print("All tasks cleared.")
self.save_to_file() | Removes all tasks from the list. | clear_tasks | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def get_tasks_by_status(self, status: str):
"""
Filters and returns tasks matching a specific status.
Args:
status: The status string to filter by.
Returns:
list[dict]: A list of tasks matching the status.
Raises:
ValueError: If the status i... |
Filters and returns tasks matching a specific status.
Args:
status: The status string to filter by.
Returns:
list[dict]: A list of tasks matching the status.
Raises:
ValueError: If the status is not a valid status.
| get_tasks_by_status | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def __str__(self):
"""Provides a user-friendly string representation of the task list."""
if not self.tasks:
return "Task List (empty)"
output = "Task List:\n"
output += "----------\n"
for i, task in enumerate(self.tasks):
output += f"{i}: [{task['status'... | Provides a user-friendly string representation of the task list. | __str__ | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def save_to_file(self, filename=file_path):
"""Saves the current task list to a Markdown file."""
try:
with open(filename, 'w', encoding='utf-8') as f:
f.write(str(self))
#print(f"Tasks saved to {filename}.")
except Exception as e:
print(f"Erro... | Saves the current task list to a Markdown file. | save_to_file | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def complete_goal(self, message: str):
"""
Marks the goal as completed, use this whether the task completion was successful or on failure.
This method should be called when the task is finished, regardless of the outcome.
Args:
message: The message to be logged.
"""
... |
Marks the goal as completed, use this whether the task completion was successful or on failure.
This method should be called when the task is finished, regardless of the outcome.
Args:
message: The message to be logged.
| complete_goal | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def start_agent(self):
"""Starts the sub-agent to perform the tasks if there are any tasks to perform.
Use this function after setting the tasks.
Args:
None"""
if len(self.tasks) == 0:
print("No tasks to perform.")
return
self.start_execution = True | Starts the sub-agent to perform the tasks if there are any tasks to perform.
Use this function after setting the tasks.
Args:
None | start_agent | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def get_all_completed_tasks(self) -> List[Dict]:
"""
Returns all completed tasks, including those from previous planning cycles.
Returns:
List of completed task dictionaries
"""
# Get currently active completed tasks
current_completed = self.get_compl... |
Returns all completed tasks, including those from previous planning cycles.
Returns:
List of completed task dictionaries
| get_all_completed_tasks | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def get_all_failed_tasks(self) -> List[Dict]:
"""
Returns all failed tasks, including those from previous planning cycles.
Returns:
List of failed task dictionaries
"""
# Get currently active failed tasks
current_failed = self.get_tasks_by_status(self... |
Returns all failed tasks, including those from previous planning cycles.
Returns:
List of failed task dictionaries
| get_all_failed_tasks | python | droidrun/droidrun | droidrun/agent/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/task_manager.py | MIT |
def create_screenshot_gif(self, output_path: str, duration: int = 1000) -> str:
"""
Create a GIF from a list of screenshots.
Args:
output_path: Base path for the GIF (without extension)
duration: Duration for each frame in milliseconds
Returns:
... |
Create a GIF from a list of screenshots.
Args:
output_path: Base path for the GIF (without extension)
duration: Duration for each frame in milliseconds
Returns:
Path to the created GIF file
| create_screenshot_gif | python | droidrun/droidrun | droidrun/agent/utils/trajectory.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/trajectory.py | MIT |
def save_trajectory(
self,
directory: str = "trajectories",
) -> str:
"""
Save trajectory steps to a JSON file and create a GIF of screenshots if available.
Args:
directory: Directory to save the trajectory files
Returns:
Path... |
Save trajectory steps to a JSON file and create a GIF of screenshots if available.
Args:
directory: Directory to save the trajectory files
Returns:
Path to the saved trajectory file
| save_trajectory | python | droidrun/droidrun | droidrun/agent/utils/trajectory.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/trajectory.py | MIT |
def get_trajectory_statistics(trajectory_data: Dict[str, Any]) -> Dict[str, Any]:
"""
Get statistics about a trajectory.
Args:
trajectory_data: The trajectory data dictionary
Returns:
Dictionary with statistics about the trajectory
""... |
Get statistics about a trajectory.
Args:
trajectory_data: The trajectory data dictionary
Returns:
Dictionary with statistics about the trajectory
| get_trajectory_statistics | python | droidrun/droidrun | droidrun/agent/utils/trajectory.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/trajectory.py | MIT |
def print_trajectory_summary(self, trajectory_data: Dict[str, Any]) -> None:
"""
Print a summary of a trajectory.
Args:
trajectory_data: The trajectory data dictionary
"""
stats = self.get_trajectory_statistics(trajectory_data)
print("=== Tra... |
Print a summary of a trajectory.
Args:
trajectory_data: The trajectory data dictionary
| print_trajectory_summary | python | droidrun/droidrun | droidrun/agent/utils/trajectory.py | https://github.com/droidrun/droidrun/blob/master/droidrun/agent/utils/trajectory.py | MIT |
def __init__(self, logs: List[str], debug: bool = False):
"""
Initialize the event handler.
Args:
logs: List to append log messages to
update_display_callback: Callback function to update the display
"""
self.logs = logs
self.debug = debug... |
Initialize the event handler.
Args:
logs: List to append log messages to
update_display_callback: Callback function to update the display
| __init__ | python | droidrun/droidrun | droidrun/cli/event_handler.py | https://github.com/droidrun/droidrun/blob/master/droidrun/cli/event_handler.py | MIT |
def create_layout():
"""Create a layout with logs at top and status at bottom"""
layout = Layout()
layout.split(
Layout(name="logs"),
Layout(name="goal", size=3),
Layout(name="status", size=3)
)
return layout | Create a layout with logs at top and status at bottom | create_layout | python | droidrun/droidrun | droidrun/cli/main.py | https://github.com/droidrun/droidrun/blob/master/droidrun/cli/main.py | MIT |
def configure_logging(debug: bool):
"""Configure logging verbosity based on debug flag."""
warnings.filterwarnings("ignore")
logging.getLogger().setLevel(logging.CRITICAL + 1)
logging.getLogger().disabled = True
for logger_name in list(logging.Logger.manager.loggerDict.keys()):
log... | Configure logging verbosity based on debug flag. | configure_logging | python | droidrun/droidrun | droidrun/cli/main.py | https://github.com/droidrun/droidrun/blob/master/droidrun/cli/main.py | MIT |
def run(command: str, device: str | None, provider: str, model: str, steps: int, base_url: str, temperature: float, reasoning: bool, tracing: bool, debug: bool, save_trajectory: bool, trajectory_dir: str):
"""Run a command on your Android device using natural language."""
# Call our standalone function
retu... | Run a command on your Android device using natural language. | run | python | droidrun/droidrun | droidrun/cli/main.py | https://github.com/droidrun/droidrun/blob/master/droidrun/cli/main.py | MIT |
async def connect(ip_address: str, port: int):
"""Connect to a device over TCP/IP."""
try:
device = await device_manager.connect(ip_address, port)
if device:
console.print(f"[green]Successfully connected to {ip_address}:{port}[/]")
else:
console.print(f"[red]Faile... | Connect to a device over TCP/IP. | connect | python | droidrun/droidrun | droidrun/cli/main.py | https://github.com/droidrun/droidrun/blob/master/droidrun/cli/main.py | MIT |
async def setup(path: str, device: str | None):
"""Install an APK file and enable it as an accessibility service."""
try:
if not os.path.exists(path):
console.print(f"[bold red]Error:[/] APK file not found at {path}")
return
if not device:
devices... | Install an APK file and enable it as an accessibility service. | setup | python | droidrun/droidrun | droidrun/cli/main.py | https://github.com/droidrun/droidrun/blob/master/droidrun/cli/main.py | MIT |
def get_device_serial(self) -> str:
"""Get the device serial from the instance or environment variable."""
# First try using the instance's serial
if self.serial:
return self.serial | Get the device serial from the instance or environment variable. | get_device_serial | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def get_device(self) -> Optional[Device]:
"""Get the device instance using the instance's serial or from environment variable.
Returns:
Device instance or None if not found
"""
serial = self.get_device_serial()
if not serial:
raise ValueErro... | Get the device instance using the instance's serial or from environment variable.
Returns:
Device instance or None if not found
| get_device | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
def parse_package_list(self, output: str) -> List[Dict[str, str]]:
"""Parse the output of 'pm list packages -f' command.
Args:
output: Raw command output from 'pm list packages -f'
Returns:
List of dictionaries containing package info with 'package' and 'path' keys
... | Parse the output of 'pm list packages -f' command.
Args:
output: Raw command output from 'pm list packages -f'
Returns:
List of dictionaries containing package info with 'package' and 'path' keys
| parse_package_list | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def get_clickables(self, serial: Optional[str] = None) -> str:
"""
Get all clickable UI elements from the device using the custom TopViewService.
This function interacts with the TopViewService app installed on the device
to capture UI elements. The service writes UI data ... |
Get all clickable UI elements from the device using the custom TopViewService.
This function interacts with the TopViewService app installed on the device
to capture UI elements. The service writes UI data to a JSON file on the device,
which is then pulled to the host. If no el... | get_clickables | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def tap_by_index(self, index: int, serial: Optional[str] = None) -> str:
"""
Tap on a UI element by its index.
This function uses the cached clickable elements
to find the element with the given index and tap on its center coordinates.
Args:
in... |
Tap on a UI element by its index.
This function uses the cached clickable elements
to find the element with the given index and tap on its center coordinates.
Args:
index: Index of the element to tap
Returns:
Result message
... | tap_by_index | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
def collect_all_indices(elements):
"""Recursively collect all indices from elements and their children."""
indices = []
for item in elements:
if item.get('index') is not None:
indices.append(item.get('index'))
# Check children if pr... | Recursively collect all indices from elements and their children. | collect_all_indices | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
def find_element_by_index(elements, target_index):
"""Recursively find an element with the given index."""
for item in elements:
if item.get('index') == target_index:
return item
# Check children if present
children = item.get('... | Recursively find an element with the given index. | find_element_by_index | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def tap_by_coordinates(self, x: int, y: int) -> bool:
"""
Tap on the device screen at specific coordinates.
Args:
x: X coordinate
y: Y coordinate
Returns:
Bool indicating success or failure
"""
try:
... |
Tap on the device screen at specific coordinates.
Args:
x: X coordinate
y: Y coordinate
Returns:
Bool indicating success or failure
| tap_by_coordinates | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def tap(self, index: int) -> str:
"""
Tap on a UI element by its index.
This function uses the cached clickable elements from the last get_clickables call
to find the element with the given index and tap on its center coordinates.
Args:
index: ... |
Tap on a UI element by its index.
This function uses the cached clickable elements from the last get_clickables call
to find the element with the given index and tap on its center coordinates.
Args:
index: Index of the element to tap
Return... | tap | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def swipe(
self,
start_x: int,
start_y: int,
end_x: int,
end_y: int,
duration_ms: int = 300
) -> bool:
"""
Performs a straight-line swipe gesture on the device screen.
To perform a hold (long press), set the start and end coordinates to t... |
Performs a straight-line swipe gesture on the device screen.
To perform a hold (long press), set the start and end coordinates to the same values and increase the duration as needed.
Args:
start_x: Starting X coordinate
start_y: Starting Y coordinate
... | swipe | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def input_text(self, text: str, serial: Optional[str] = None) -> str:
"""
Input text on the device using Base64 encoding and broadcast intent.
Args:
text: Text to input. Can contain spaces, newlines, and special characters including non-ASCII.
serial: Optio... |
Input text on the device using Base64 encoding and broadcast intent.
Args:
text: Text to input. Can contain spaces, newlines, and special characters including non-ASCII.
serial: Optional device serial (for backward compatibility)
Returns:
Re... | input_text | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def press_key(self, keycode: int) -> str:
"""
Press a key on the device.
Common keycodes:
- 3: HOME
- 4: BACK
- 24: VOLUME UP
- 25: VOLUME DOWN
- 26: POWER
- 82: MENU
Args:
keycode: Android keycode to pre... |
Press a key on the device.
Common keycodes:
- 3: HOME
- 4: BACK
- 24: VOLUME UP
- 25: VOLUME DOWN
- 26: POWER
- 82: MENU
Args:
keycode: Android keycode to press
| press_key | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def start_app(
self,
package: str,
activity: str = ""
) -> str:
"""
Start an app on the device.
Args:
package: Package name (e.g., "com.android.settings")
activity: Optional activity name
"""
try:
if s... |
Start an app on the device.
Args:
package: Package name (e.g., "com.android.settings")
activity: Optional activity name
| start_app | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def install_app(
self,
apk_path: str,
reinstall: bool = False,
grant_permissions: bool = True
) -> str:
"""
Install an app on the device.
Args:
apk_path: Path to the APK file
reinstall: Whether to reinstall if app exist... |
Install an app on the device.
Args:
apk_path: Path to the APK file
reinstall: Whether to reinstall if app exists
grant_permissions: Whether to grant all permissions
| install_app | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def take_screenshot(self) -> bool:
"""
Take a screenshot of the device.
This function captures the current screen and adds the screenshot to context in the next message.
Also stores the screenshot in the screenshots list with timestamp for later GIF creation.
"""
tr... |
Take a screenshot of the device.
This function captures the current screen and adds the screenshot to context in the next message.
Also stores the screenshot in the screenshots list with timestamp for later GIF creation.
| take_screenshot | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def list_packages(
self,
include_system_apps: bool = False
) -> List[str]:
"""
List installed packages on the device.
Args:
include_system_apps: Whether to include system apps (default: False)
Returns:
List of package na... |
List installed packages on the device.
Args:
include_system_apps: Whether to include system apps (default: False)
Returns:
List of package names
| list_packages | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def extract(self, filename: Optional[str] = None) -> str:
"""Extract and save the current UI state to a JSON file.
This function captures the current UI state including all UI elements
and saves it to a JSON file for later analysis or reference.
Args:
... | Extract and save the current UI state to a JSON file.
This function captures the current UI state including all UI elements
and saves it to a JSON file for later analysis or reference.
Args:
filename: Optional filename to save the UI state (defaults to ui_state_TIME... | extract | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def get_all_elements(self) -> Dict[str, Any]:
"""
Get all UI elements from the device, including non-interactive elements.
This function interacts with the TopViewService app installed on the device
to capture all UI elements, even those that are not interactive. This prov... |
Get all UI elements from the device, including non-interactive elements.
This function interacts with the TopViewService app installed on the device
to capture all UI elements, even those that are not interactive. This provides
a complete view of the UI hierarchy for analysis o... | get_all_elements | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
def complete(self, success: bool, reason: str = ""):
"""
Mark the task as finished.
Args:
success: Indicates if the task was successful.
reason: Reason for failure/success
"""
if success:
self.success = True
self.reason = reason or... |
Mark the task as finished.
Args:
success: Indicates if the task was successful.
reason: Reason for failure/success
| complete | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def get_phone_state(self, serial: Optional[str] = None) -> Dict[str, Any]:
"""
Get the current phone state including current activity and keyboard visibility.
Args:
serial: Optional device serial number
Returns:
Dictionary with current phon... |
Get the current phone state including current activity and keyboard visibility.
Args:
serial: Optional device serial number
Returns:
Dictionary with current phone state information
| get_phone_state | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
async def remember(self, information: str) -> str:
"""
Store important information to remember for future context.
This information will be included in future LLM prompts to help maintain context
across interactions. Use this for critical facts, observations, or user preferences... |
Store important information to remember for future context.
This information will be included in future LLM prompts to help maintain context
across interactions. Use this for critical facts, observations, or user preferences
that should influence future decisions.
... | remember | python | droidrun/droidrun | droidrun/tools/actions.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/actions.py | MIT |
def load_tools(serial: Optional[str] = None) -> Tuple[Dict[str, Callable[..., Any]], Tools]:
"""
Initializes the Tools class and returns a dictionary of available tool functions
and the Tools instance itself. If serial is not provided, it attempts to find
the first connected device.
Args:
s... |
Initializes the Tools class and returns a dictionary of available tool functions
and the Tools instance itself. If serial is not provided, it attempts to find
the first connected device.
Args:
serial: The device serial number. If None, finds the first available device.
Returns:
A ... | load_tools | python | droidrun/droidrun | droidrun/tools/loader.py | https://github.com/droidrun/droidrun/blob/master/droidrun/tools/loader.py | MIT |
def __init__(
self,
task_ids: Optional[List[int]] = None,
task_names: Optional[List[str]] = None,
llm_provider: str = "OpenAI",
llm_model: str = "gpt-4o-mini",
temperature: float = 0.2,
adb_path: str = "adb",
console_port: int = 5554,
perform_emula... | Initialize the benchmark.
Args:
task_ids: List of task IDs to run (1-116)
task_names: List of specific task names to run
llm_provider: LLM provider to use (OpenAI, Anthropic, Gemini, etc.)
llm_model: Model name to use
temperature: Temperature ... | __init__ | python | droidrun/droidrun | eval/android_world_bench.py | https://github.com/droidrun/droidrun/blob/master/eval/android_world_bench.py | MIT |
async def initialize(self):
"""Initialize all components needed for the benchmark."""
# Initialize environment
self.env = initialize_environment(
adb_path=self.adb_path,
console_port=self.console_port,
perform_setup=self.perform_emulator_setup
)
... | Initialize all components needed for the benchmark. | initialize | python | droidrun/droidrun | eval/android_world_bench.py | https://github.com/droidrun/droidrun/blob/master/eval/android_world_bench.py | MIT |
def list_tasks(self):
"""Print the list of available tasks."""
if not self.task_registry:
self.task_registry = TaskRegistry(task_family=self.task_family)
task_ids = self.task_registry.get_task_ids()
print("\nAvailable AndroidWorld Tasks:")
print("---... | Print the list of available tasks. | list_tasks | python | droidrun/droidrun | eval/android_world_bench.py | https://github.com/droidrun/droidrun/blob/master/eval/android_world_bench.py | MIT |
async def run_task(self, task_name: str, task_instance):
"""Run a single task.
Args:
task_name: Name of the task
task_instance: Task instance to run
Returns:
Task result
"""
logger.info(f"Running task: {task_name}")
... | Run a single task.
Args:
task_name: Name of the task
task_instance: Task instance to run
Returns:
Task result
| run_task | python | droidrun/droidrun | eval/android_world_bench.py | https://github.com/droidrun/droidrun/blob/master/eval/android_world_bench.py | MIT |
async def run_benchmark(self):
"""Run the benchmark on the selected tasks."""
# Initialize components
await self.initialize()
# Create task suite
task_suite = self.task_registry.create_task_suite(
task_ids=self.task_ids,
task_names=self.task_names... | Run the benchmark on the selected tasks. | run_benchmark | python | droidrun/droidrun | eval/android_world_bench.py | https://github.com/droidrun/droidrun/blob/master/eval/android_world_bench.py | MIT |
async def main():
"""Main entry point for the benchmark script."""
parser = argparse.ArgumentParser(description="Run AndroidWorld benchmark tasks with DroidRun")
# Task selection arguments
task_group = parser.add_argument_group("Task Selection")
task_group.add_argument("--task-ids", type=int, n... | Main entry point for the benchmark script. | main | python | droidrun/droidrun | eval/android_world_bench.py | https://github.com/droidrun/droidrun/blob/master/eval/android_world_bench.py | MIT |
async def enable_accessibility_service(adb_path: str, device_serial: str,
service_name: str, disable_first: bool = False):
"""Enable the DroidRun accessibility service.
This is crucial for DroidRun to function correctly with Android UI interactions.
Args:
... | Enable the DroidRun accessibility service.
This is crucial for DroidRun to function correctly with Android UI interactions.
Args:
adb_path: Path to ADB executable
device_serial: Device serial number
service_name: Name of the accessibility service to enable
disable_first... | enable_accessibility_service | python | droidrun/droidrun | eval/utils/accessibility.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/accessibility.py | MIT |
async def create_agent(
device_serial: str,
task_description: str,
llm_provider: str,
llm_model: str,
temperature: float = 0.2,
max_steps: int = 50,
timeout: int = 600,
max_retries: int = 3,
vision: bool = True,
debug: bool = True
) -> Tuple[DroidAgent, Dict[str, Any]]:
"""Cr... | Create and configure a DroidRun agent.
Args:
device_serial: Device serial number
task_description: Description of the task
llm_provider: LLM provider name
llm_model: LLM model name
temperature: Temperature for LLM
max_steps: Maximum number of steps
timeou... | create_agent | python | droidrun/droidrun | eval/utils/agent.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/agent.py | MIT |
async def run_agent(agent: DroidAgent, task_name: str) -> Dict[str, Any]:
"""Run the agent on a task.
Args:
agent: The agent to run
task_name: Name of the task
Returns:
Result data
"""
logger.info(f"Running agent for task: {task_name}")
try:
# R... | Run the agent on a task.
Args:
agent: The agent to run
task_name: Name of the task
Returns:
Result data
| run_agent | python | droidrun/droidrun | eval/utils/agent.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/agent.py | MIT |
def check_android_world_path():
"""Check that the ANDROID_WORLD_PATH environment variable is set and valid."""
android_world_path = os.environ.get("ANDROID_WORLD_PATH", None)
if not android_world_path or not os.path.exists(android_world_path):
logger.error("ANDROID_WORLD_PATH environment variable no... | Check that the ANDROID_WORLD_PATH environment variable is set and valid. | check_android_world_path | python | droidrun/droidrun | eval/utils/environment.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/environment.py | MIT |
def initialize_environment(
adb_path: str = "adb",
console_port: int = 5554,
perform_setup: bool = False
) -> Optional[object]:
"""Initialize the AndroidWorld environment.
Args:
adb_path: Path to ADB executable
console_port: Emulator console port
perform_setup: Whether t... | Initialize the AndroidWorld environment.
Args:
adb_path: Path to ADB executable
console_port: Emulator console port
perform_setup: Whether to perform initial emulator setup
Returns:
Initialized environment or None if initialization failed
| initialize_environment | python | droidrun/droidrun | eval/utils/environment.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/environment.py | MIT |
async def get_device_serial() -> Optional[str]:
"""Get the serial number of the connected Android device.
Returns:
Device serial number or None if no device found
"""
try:
from droidrun.tools import DeviceManager
device_manager = DeviceManager()
devices = aw... | Get the serial number of the connected Android device.
Returns:
Device serial number or None if no device found
| get_device_serial | python | droidrun/droidrun | eval/utils/environment.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/environment.py | MIT |
def __init__(
self,
adb_path: str = "adb",
device_serial: Optional[str] = None,
interval: int = 5
):
"""Initialize the keepalive service.
Args:
adb_path: Path to ADB executable
device_serial: Device serial number
interval... | Initialize the keepalive service.
Args:
adb_path: Path to ADB executable
device_serial: Device serial number
interval: Interval in seconds between commands
| __init__ | python | droidrun/droidrun | eval/utils/keepalive.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/keepalive.py | MIT |
def start(self):
"""Start the keepalive service as a subprocess."""
if self.process and self.process.poll() is None:
logger.info("Keepalive service is already running")
return
# Path to the script file
script_path = os.path.join(os.path.dirname(__file__),... | Start the keepalive service as a subprocess. | start | python | droidrun/droidrun | eval/utils/keepalive.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/keepalive.py | MIT |
def _create_script_file(self, script_path: str):
"""Create the keepalive script file.
Args:
script_path: Path to write the script to
"""
script_content = '''#!/usr/bin/env python3
"""
Minimal keepalive script for DroidRun overlay toggling.
"""
import subprocess
impo... | Create the keepalive script file.
Args:
script_path: Path to write the script to
| _create_script_file | python | droidrun/droidrun | eval/utils/keepalive.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/keepalive.py | MIT |
async def disable_overlay_once(adb_path: str, device_serial: str):
"""Disable the overlay once.
Args:
adb_path: Path to ADB executable
device_serial: Device serial number
"""
try:
cmd = [
adb_path,
"-s", device_serial,
"shell",
... | Disable the overlay once.
Args:
adb_path: Path to ADB executable
device_serial: Device serial number
| disable_overlay_once | python | droidrun/droidrun | eval/utils/keepalive.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/keepalive.py | MIT |
def __init__(self, results_dir: str = "eval_results"):
"""Initialize the result manager.
Args:
results_dir: Directory to save results to
"""
self.results_dir = results_dir
self.results = []
# Create results directory if it doesn't exist
... | Initialize the result manager.
Args:
results_dir: Directory to save results to
| __init__ | python | droidrun/droidrun | eval/utils/results.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/results.py | MIT |
def save_task_result(self, result: Dict[str, Any]):
"""Save a task result.
Args:
result: Task result data
"""
# Add to results list
self.results.append(result)
# Save to file
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
... | Save a task result.
Args:
result: Task result data
| save_task_result | python | droidrun/droidrun | eval/utils/results.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/results.py | MIT |
def _update_summary(self, result: Dict[str, Any]):
"""Update the summary with a new result.
Args:
result: Task result data
"""
# Update total tasks
self.summary["total_tasks"] += 1
# Update successful tasks
if result.get("success", Fa... | Update the summary with a new result.
Args:
result: Task result data
| _update_summary | python | droidrun/droidrun | eval/utils/results.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/results.py | MIT |
def create_task_result(task_name: str, task_description: str) -> Dict[str, Any]:
"""Create a new task result object.
Args:
task_name: Name of the task
task_description: Description of the task
Returns:
Task result object
"""
return {
"task_name": task_na... | Create a new task result object.
Args:
task_name: Name of the task
task_description: Description of the task
Returns:
Task result object
| create_task_result | python | droidrun/droidrun | eval/utils/results.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/results.py | MIT |
def update_result_from_agent(result: Dict[str, Any], agent_result: Any, agent: Any) -> Dict[str, Any]:
"""Update a task result with information from an agent run.
Args:
result: Task result to update
agent_result: Result from agent run
agent: Agent instance
Returns:
... | Update a task result with information from an agent run.
Args:
result: Task result to update
agent_result: Result from agent run
agent: Agent instance
Returns:
Updated task result
| update_result_from_agent | python | droidrun/droidrun | eval/utils/results.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/results.py | MIT |
def __init__(self, progress_file: str):
"""Initialize the progress tracker.
Args:
progress_file: Path to progress file
"""
self.progress_file = progress_file
self.completed_tasks = 0
# Ensure directory exists if progress_file includes a direc... | Initialize the progress tracker.
Args:
progress_file: Path to progress file
| __init__ | python | droidrun/droidrun | eval/utils/results.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/results.py | MIT |
def update_progress(self, completed_tasks: int):
"""Update progress with the number of completed tasks.
Args:
completed_tasks: Number of completed tasks
"""
self.completed_tasks = completed_tasks
try:
progress_data = {
"co... | Update progress with the number of completed tasks.
Args:
completed_tasks: Number of completed tasks
| update_progress | python | droidrun/droidrun | eval/utils/results.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/results.py | MIT |
def __init__(self, task_family: str = registry.TaskRegistry.ANDROID_WORLD_FAMILY):
"""Initialize the task registry.
Args:
task_family: The task family to use
"""
self.task_family = task_family
self.registry = registry.TaskRegistry()
self.task_dict = s... | Initialize the task registry.
Args:
task_family: The task family to use
| __init__ | python | droidrun/droidrun | eval/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/task_manager.py | MIT |
def create_task_instance(self, task_name: str, random_seed: int = 42) -> Optional[task_eval.TaskEval]:
"""Create an instance of a task.
Args:
task_name: Name of the task
random_seed: Random seed for parameter generation
Returns:
Task inst... | Create an instance of a task.
Args:
task_name: Name of the task
random_seed: Random seed for parameter generation
Returns:
Task instance or None if task could not be created
| create_task_instance | python | droidrun/droidrun | eval/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/task_manager.py | MIT |
def filter_tasks(self, task_ids: Optional[List[int]] = None,
task_names: Optional[List[str]] = None) -> Dict[str, type]:
"""Filter tasks based on task IDs or names.
Args:
task_ids: List of task IDs to filter
task_names: List of task names to filter
... | Filter tasks based on task IDs or names.
Args:
task_ids: List of task IDs to filter
task_names: List of task names to filter
Returns:
Dictionary of filtered tasks
| filter_tasks | python | droidrun/droidrun | eval/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/task_manager.py | MIT |
def create_task_suite(self, task_ids: Optional[List[int]] = None,
task_names: Optional[List[str]] = None,
n_combinations: int = 1,
random_seed: int = 42) -> List[Tuple[str, task_eval.TaskEval]]:
"""Create a suite of tasks to benchmark... | Create a suite of tasks to benchmark.
Args:
task_ids: List of task IDs to include
task_names: List of task names to include
n_combinations: Number of parameter combinations per task
random_seed: Random seed for reproducibility
Returns... | create_task_suite | python | droidrun/droidrun | eval/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/task_manager.py | MIT |
async def initialize_task(env, task_instance: task_eval.TaskEval) -> bool:
"""Initialize a task in the environment.
Args:
env: AndroidWorld environment
task_instance: Task instance to initialize
Returns:
True if initialization was successful, False otherwise
"""
... | Initialize a task in the environment.
Args:
env: AndroidWorld environment
task_instance: Task instance to initialize
Returns:
True if initialization was successful, False otherwise
| initialize_task | python | droidrun/droidrun | eval/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/task_manager.py | MIT |
def get_task_description(task_instance: task_eval.TaskEval) -> str:
"""Get the description for a task.
Args:
task_instance: Task instance
Returns:
Task description
"""
task_name = task_instance.__class__.__name__
try:
# First try to use get_instruction(... | Get the description for a task.
Args:
task_instance: Task instance
Returns:
Task description
| get_task_description | python | droidrun/droidrun | eval/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/task_manager.py | MIT |
def check_task_success(env, task_instance: task_eval.TaskEval) -> bool:
"""Check if a task was completed successfully.
Args:
env: AndroidWorld environment
task_instance: Task instance
Returns:
True if task was successful, False otherwise
"""
task_name = task_ins... | Check if a task was completed successfully.
Args:
env: AndroidWorld environment
task_instance: Task instance
Returns:
True if task was successful, False otherwise
| check_task_success | python | droidrun/droidrun | eval/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/task_manager.py | MIT |
def teardown_task(env, task_instance: task_eval.TaskEval) -> bool:
"""Tear down a task.
Args:
env: AndroidWorld environment
task_instance: Task instance
Returns:
True if teardown was successful, False otherwise
"""
task_name = task_instance.__class__.__name__
... | Tear down a task.
Args:
env: AndroidWorld environment
task_instance: Task instance
Returns:
True if teardown was successful, False otherwise
| teardown_task | python | droidrun/droidrun | eval/utils/task_manager.py | https://github.com/droidrun/droidrun/blob/master/eval/utils/task_manager.py | MIT |
def __init__(self, path, target_column=None,
ndarray=True, **kwargs):
"""
:param str path:
The *path* represents a filesystem path or URL that's passed
on as the *filepath_or_buffer* argument to
:func:`read_table`.
:param str target_column:
... |
:param str path:
The *path* represents a filesystem path or URL that's passed
on as the *filepath_or_buffer* argument to
:func:`read_table`.
:param str target_column:
The column in the table to load that represents the target
value. This column will n... | __init__ | python | ottogroup/palladium | palladium/dataset.py | https://github.com/ottogroup/palladium/blob/master/palladium/dataset.py | Apache-2.0 |
def __init__(self, url, sql, target_column=None, ndarray=True, **kwargs):
"""
:param str url:
The database *url* that'll be used to make a connection.
Format follows RFC-1738.
:param str sql:
SQL query to be executed or database table name.
:param str targ... |
:param str url:
The database *url* that'll be used to make a connection.
Format follows RFC-1738.
:param str sql:
SQL query to be executed or database table name.
:param str target_column:
The name of the column used as the target. (All other
... | __init__ | python | ottogroup/palladium | palladium/dataset.py | https://github.com/ottogroup/palladium/blob/master/palladium/dataset.py | Apache-2.0 |
def __init__(self,
impl,
update_cache_rrule,
):
"""
:param palladium.interfaces.DatasetLoader impl:
The underlying (decorated) dataset loader object.
:param dict update_cache_rrule:
Keyword arguments for a :class:`dateutil.r... |
:param palladium.interfaces.DatasetLoader impl:
The underlying (decorated) dataset loader object.
:param dict update_cache_rrule:
Keyword arguments for a :class:`dateutil.rrule.rrule` that
determines when the cache will be updated. See
:class:`~palladium.util.R... | __init__ | python | ottogroup/palladium | palladium/dataset.py | https://github.com/ottogroup/palladium/blob/master/palladium/dataset.py | Apache-2.0 |
def test_cmd(argv=sys.argv[1:]): # pragma: no cover
"""\
Test a model.
Uses 'dataset_loader_test' and 'model_persister' from the
configuration to load a test dataset to test the accuracy of a trained
model with.
Usage:
pld-test [options]
Options:
-h --help Show this screen.
--model-versi... | Test a model.
Uses 'dataset_loader_test' and 'model_persister' from the
configuration to load a test dataset to test the accuracy of a trained
model with.
Usage:
pld-test [options]
Options:
-h --help Show this screen.
--model-version=<version> The version of the model to be tested. If
... | test_cmd | python | ottogroup/palladium | palladium/eval.py | https://github.com/ottogroup/palladium/blob/master/palladium/eval.py | Apache-2.0 |
def fit_cmd(argv=sys.argv[1:]): # pragma: no cover
"""\
Fit a model and save to database.
Will use 'dataset_loader_train', 'model', and 'model_perister' from
the configuration file, to load a dataset to train a model with, and
persist it.
Usage:
pld-fit [options]
Options:
-n --no-save Don't per... | Fit a model and save to database.
Will use 'dataset_loader_train', 'model', and 'model_perister' from
the configuration file, to load a dataset to train a model with, and
persist it.
Usage:
pld-fit [options]
Options:
-n --no-save Don't persist the fitted model to disk.
--no-activate D... | fit_cmd | python | ottogroup/palladium | palladium/fit.py | https://github.com/ottogroup/palladium/blob/master/palladium/fit.py | Apache-2.0 |
def admin_cmd(argv=sys.argv[1:]): # pragma: no cover
"""\
Activate or delete models.
Models are usually made active right after fitting (see command
pld-fit). The 'activate' command allows you to explicitly set the
currently active model. Use 'pld-list' to get an overview of all
available models along with thei... | Activate or delete models.
Models are usually made active right after fitting (see command
pld-fit). The 'activate' command allows you to explicitly set the
currently active model. Use 'pld-list' to get an overview of all
available models along with their version identifiers.
Deleting a model will simply remove it ... | admin_cmd | python | ottogroup/palladium | palladium/fit.py | https://github.com/ottogroup/palladium/blob/master/palladium/fit.py | Apache-2.0 |
def grid_search_cmd(argv=sys.argv[1:]): # pragma: no cover
"""\
Grid search parameters for the model.
Uses 'dataset_loader_train', 'model', and 'grid_search' from the
configuration to load a training dataset, and run a grid search on the
model using the grid of hyperparameters.
Usage:
pld-grid-search [options]... | Grid search parameters for the model.
Uses 'dataset_loader_train', 'model', and 'grid_search' from the
configuration to load a training dataset, and run a grid search on the
model using the grid of hyperparameters.
Usage:
pld-grid-search [options]
Options:
--save-results=<fname> Save results to CSV file
--pe... | grid_search_cmd | python | ottogroup/palladium | palladium/fit.py | https://github.com/ottogroup/palladium/blob/master/palladium/fit.py | Apache-2.0 |
def __call__(self):
"""Loads the data and returns a tuple *(data, target)*, or
*(X, y)*.
:return:
A tuple *(data, target*).
*data* is a two dimensional numpy array with shape n x m
(one row per example).
*target* is a one dimensional array with n target... | Loads the data and returns a tuple *(data, target)*, or
*(X, y)*.
:return:
A tuple *(data, target*).
*data* is a two dimensional numpy array with shape n x m
(one row per example).
*target* is a one dimensional array with n target values.
*target* ma... | __call__ | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def __iter__(self):
"""
:return:
Tuples of train/test indices.
""" |
:return:
Tuples of train/test indices.
| __iter__ | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def fit(self, X, y=None):
"""Fit to data array *X* and possibly a target array *y*.
:return: self
""" | Fit to data array *X* and possibly a target array *y*.
:return: self
| fit | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def predict(self, X, **kw):
"""Predict classes for data array *X* with shape n x m.
Some models may accept additional keyword arguments.
:return:
A numpy array of length n with the predicted classes (for
classification problems) or numeric values (for regression
p... | Predict classes for data array *X* with shape n x m.
Some models may accept additional keyword arguments.
:return:
A numpy array of length n with the predicted classes (for
classification problems) or numeric values (for regression
problems).
:raises:
M... | predict | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def read(self, version=None):
"""Returns a :class:`Model` instance.
:param str version:
*version* may be used to read a specific version of a model.
If *version* is ``None``, returns the active model.
:return:
The model object.
:raises:
LookupEr... | Returns a :class:`Model` instance.
:param str version:
*version* may be used to read a specific version of a model.
If *version* is ``None``, returns the active model.
:return:
The model object.
:raises:
LookupError if no model was available.
| read | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def write(self, model):
"""Persists a :class:`Model` and returns a new version number.
It is the :class:`ModelPersister`'s responsibility to annotate
the 'version' information onto the model before it is saved.
The new model will initially be inactive. Use
:meth:`ModelPersiste... | Persists a :class:`Model` and returns a new version number.
It is the :class:`ModelPersister`'s responsibility to annotate
the 'version' information onto the model before it is saved.
The new model will initially be inactive. Use
:meth:`ModelPersister.activate` to activate the model.
... | write | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def activate(self, version):
"""Set the model with the given *version* to be the active
one.
Implies that any previously active model becomes inactive.
:param str version:
The *version* of the model that's activated.
:raises:
LookupError if no model with gi... | Set the model with the given *version* to be the active
one.
Implies that any previously active model becomes inactive.
:param str version:
The *version* of the model that's activated.
:raises:
LookupError if no model with given *version* exists.
| activate | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def delete(self, version):
"""Delete the model with the given *version* from the
database.
:param str version:
The *version* of the model that's activated.
:raises:
LookupError if no model with given *version* exists.
""" | Delete the model with the given *version* from the
database.
:param str version:
The *version* of the model that's activated.
:raises:
LookupError if no model with given *version* exists.
| delete | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def list_models(self):
"""List metadata of all available models.
:return:
A list of dicts, with each dict containing information about
one of the available models. Each dict is guaranteed to
contain the ``version`` key, which is the same version
number that :met... | List metadata of all available models.
:return:
A list of dicts, with each dict containing information about
one of the available models. Each dict is guaranteed to
contain the ``version`` key, which is the same version
number that :meth:`ModelPersister.read` accepts fo... | list_models | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def list_properties(self):
"""List properties of :class:`ModelPersister` itself.
:return:
A dictionary of key and value pairs, where both keys and
values are of type ``str``. Properties will usually include
``active-model`` and ``db-version`` entries.
""" | List properties of :class:`ModelPersister` itself.
:return:
A dictionary of key and value pairs, where both keys and
values are of type ``str``. Properties will usually include
``active-model`` and ``db-version`` entries.
| list_properties | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def upgrade(self, from_version=None, to_version=__version__):
"""Upgrade the underlying database to the latest version.
Newer versions of Palladium may require changes to the
:class:`ModelPersister`'s database. This method provides an
opportunity to run the necessary upgrade steps.
... | Upgrade the underlying database to the latest version.
Newer versions of Palladium may require changes to the
:class:`ModelPersister`'s database. This method provides an
opportunity to run the necessary upgrade steps.
It's the :class:`ModelPersister`'s responsibility to keep
t... | upgrade | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def __call__(self, model, request):
"""
Use the model to run a prediction with the requested data.
:param model:
The :class:`~Model` instance to use for making predictions.
:param request:
A werkzeug ``request`` object. A dictionary with query
parameters ... |
Use the model to run a prediction with the requested data.
:param model:
The :class:`~Model` instance to use for making predictions.
:param request:
A werkzeug ``request`` object. A dictionary with query
parameters is available at *request.values*.
:ret... | __call__ | python | ottogroup/palladium | palladium/interfaces.py | https://github.com/ottogroup/palladium/blob/master/palladium/interfaces.py | Apache-2.0 |
def __init__(self, fit_func, predict_func,
fit_kwargs=None, predict_kwargs=None,
encode_labels=False):
"""
Instantiates a model with the given *fit_func* and
*predict_func* written in Julia.
:param str fit_func:
The dotted name of the Julia fu... |
Instantiates a model with the given *fit_func* and
*predict_func* written in Julia.
:param str fit_func:
The dotted name of the Julia function to use for fitting.
The function must take as its first two arguments the *X*
and *y* arrays. All elements of the option... | __init__ | python | ottogroup/palladium | palladium/julia.py | https://github.com/ottogroup/palladium/blob/master/palladium/julia.py | Apache-2.0 |
def open(self, path, mode='r'):
"""Return a file handle
For normal files, the implementation is:
```python
return open(path, mode)
```
""" | Return a file handle
For normal files, the implementation is:
```python
return open(path, mode)
```
| open | python | ottogroup/palladium | palladium/persistence.py | https://github.com/ottogroup/palladium/blob/master/palladium/persistence.py | Apache-2.0 |
def exists(self, path):
"""Test whether a path exists
For normal files, the implementation is:
```python
return os.path.exists(path)
```
""" | Test whether a path exists
For normal files, the implementation is:
```python
return os.path.exists(path)
```
| exists | python | ottogroup/palladium | palladium/persistence.py | https://github.com/ottogroup/palladium/blob/master/palladium/persistence.py | Apache-2.0 |
def remove(self, path):
"""Remove a file
For normal files, the implementation is:
```python
os.remove(path)
```
""" | Remove a file
For normal files, the implementation is:
```python
os.remove(path)
```
| remove | python | ottogroup/palladium | palladium/persistence.py | https://github.com/ottogroup/palladium/blob/master/palladium/persistence.py | Apache-2.0 |
def __init__(self, path, io):
"""
:param str path:
The *path* template that I will use to store models,
e.g. ``/path/to/model-{version}``.
:param FileLikeIO io:
Used to access low level file handle operations.
"""
if '{version}' not in path:
... |
:param str path:
The *path* template that I will use to store models,
e.g. ``/path/to/model-{version}``.
:param FileLikeIO io:
Used to access low level file handle operations.
| __init__ | python | ottogroup/palladium | palladium/persistence.py | https://github.com/ottogroup/palladium/blob/master/palladium/persistence.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.