Skip to content

Commit

Permalink
Add headless environment support for mouse policy testing
Browse files Browse the repository at this point in the history
- Conditionally import pyautogui based on display availability
- Add mock for pyautogui in headless environments
- Skip GUI tests when no display is present
- Improve test compatibility across different runtime environments
  • Loading branch information
beduffy committed Feb 22, 2025
1 parent b3c4e73 commit 89e54b9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion imitate_mouse/run_mouse_policy.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import time
import argparse
import os
import pytest

import numpy as np
import torch
import pyautogui

from imitate_mouse.imitate_mouse import MouseRecorder, ACTPolicy

# Only import pyautogui if we have a display
if 'DISPLAY' in os.environ or 'PYTEST_CURRENT_TEST' in os.environ:
import pyautogui
else:
pyautogui = None # Mock for headless environments


def run_policy_eval(args, num_steps=100):
# Skip if in headless environment
if pyautogui is None:
pytest.skip("Skipping GUI test in headless environment")

device = "cuda" if torch.cuda.is_available() and not args.cpu else "cpu"

# Load checkpoint with proper error handling
Expand Down

0 comments on commit 89e54b9

Please sign in to comment.