Environment is_used flag; OS domain fix (#219)
* Refactor evaluator structure in LibreOffice Writer example JSON to support multiple expected and result files, enhancing evaluation flexibility. * Update instance type to t3.large and add VNC access URL logging for allocated VMs, enhancing remote access capabilities. * Update instance type to t3.large and add VNC access URL logging for allocated VMs, enhancing remote access capabilities. * Update time format in get_vm_file function to include hours, minutes, and seconds for more precise file naming with time suffix. * More delay for 936321ce-5236-426a-9a20-e0e3c5dc536f; support one more potential solutions. * Enhance SetupController with configurable retry limit and improved error handling for file opening requests. Introduce new function to compare unique training records, and update logging for better debugging. Adjust JSON examples for evaluation to support multiple expected and result files. * Clean debug code * Enhance DesktopEnv to track environment usage for optimized snapshot management. Introduce is_environment_used flag to determine if a snapshot revert is necessary based on provider type. Update setup and step methods to mark environment usage appropriately. Add new execute_with_verification method in SetupController for command execution with result verification, improving reliability. Change AWS instance type to m5.large for better performance and update AMI ID for compatibility. Update file opening logic in main.py to handle both file paths and application commands more effectively. --------- Co-authored-by: yuanmengqi <yuanmengqi@mail.ustc.edu.cn>
This commit is contained in:
@@ -305,6 +305,57 @@ class SetupController:
|
||||
if not terminates:
|
||||
time.sleep(0.3)
|
||||
|
||||
def _execute_with_verification_setup(
|
||||
self,
|
||||
command: List[str],
|
||||
verification: Dict[str, Any] = None,
|
||||
max_wait_time: int = 10,
|
||||
check_interval: float = 1.0,
|
||||
shell: bool = False
|
||||
):
|
||||
"""Execute command with verification of results
|
||||
|
||||
Args:
|
||||
command: Command to execute
|
||||
verification: Dict with verification criteria:
|
||||
- window_exists: Check if window with this name exists
|
||||
- command_success: Execute this command and check if it succeeds
|
||||
max_wait_time: Maximum time to wait for verification
|
||||
check_interval: Time between verification checks
|
||||
shell: Whether to use shell
|
||||
"""
|
||||
if not command:
|
||||
raise Exception("Empty command to launch.")
|
||||
|
||||
verification = verification or {}
|
||||
|
||||
payload = json.dumps({
|
||||
"command": command,
|
||||
"shell": shell,
|
||||
"verification": verification,
|
||||
"max_wait_time": max_wait_time,
|
||||
"check_interval": check_interval
|
||||
})
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
try:
|
||||
response = requests.post(self.http_server + "/setup" + "/execute_with_verification",
|
||||
headers=headers, data=payload, timeout=max_wait_time + 10)
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
logger.info("Command executed and verified successfully: %s -> %s"
|
||||
, " ".join(command) if isinstance(command, list) else command
|
||||
, response.text
|
||||
)
|
||||
return result
|
||||
else:
|
||||
logger.error("Failed to execute with verification. Status code: %s", response.text)
|
||||
raise Exception(f"Command verification failed: {response.text}")
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error("An error occurred while trying to send the request: %s", e)
|
||||
traceback.print_exc()
|
||||
raise Exception(f"Request failed: {e}")
|
||||
|
||||
def _command_setup(self, command: List[str], **kwargs):
|
||||
self._execute_setup(command, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user