Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions agentdesk/vm/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@
class EC2Provider(DesktopProvider):
"""VM provider using AWS EC2"""

AVAILABLE_REGIONS = {"us-east-1", "us-west-1", "us-west-2", "eu-west-1", "eu-central-1", "ap-southeast-1", "ap-northeast-1"}
AVAILABLE_REGIONS = {
"us-east-1",
"us-west-1",
"us-west-2",
"eu-west-1",
"eu-central-1",
"ap-southeast-1",
"ap-northeast-1",
}

def __init__(
self,
Expand Down Expand Up @@ -69,7 +77,7 @@ def create(
raise ValueError(f"VM name '{name}' already exists")

if not image:
image = self._get_ami_id_by_name(JAMMY.ec2)
image = self._get_ami_id_by_name(JAMMY.ec2) # type: ignore

if not ssh_key_pair:
key_pair = SSHKeyPair.generate_key(
Expand Down Expand Up @@ -328,16 +336,13 @@ def _get_ami_id_by_name(self, ami_name: str) -> str:
The AMI ID of the latest custom AMI if found, otherwise None.
"""
images = self.ec2_client.describe_images(
Filters=[
{
'Name': 'name',
'Values': [ami_name]
}
]
Filters=[{"Name": "name", "Values": [ami_name]}]
).get("Images", [])
if not images:
raise ValueError(f"No images found with name: {ami_name} in region {self.region}")
return images[0]["ImageId"]
raise ValueError(
f"No images found with name: {ami_name} in region {self.region}"
)
return images[0]["ImageId"] # type: ignore

def _release_eip(self, instance: EC2Instance) -> None:
# Assuming you have tagged your EIPs or have a way to associate them with instances
Expand Down
6 changes: 5 additions & 1 deletion agentdesk/vm/qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def create(

agentd_port: int = 8000
ssh_port = find_open_port(2222, 3333)
if not ssh_port:
raise RuntimeError("could not find an open port for SSH")

self._create_iso("cidata.iso", user_data, meta_data)

Expand Down Expand Up @@ -208,7 +210,9 @@ def create(
print(f"\nsuccessfully created desktop '{name}'")
return desktop

def _wait_till_ready(self, ssh_port: int, private_ssh_key: Optional[str] = None) -> None:
def _wait_till_ready(
self, ssh_port: int, private_ssh_key: Optional[str] = None
) -> None:
local_agentd_port = find_open_port(8000, 9000)
if not local_agentd_port:
raise ValueError("could not find open port")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "agentdesk"
version = "0.2.93"
version = "0.2.94"
description = "A desktop for AI agents"
authors = ["Patrick Barker <patrickbarkerco@gmail.com>"]
license = "MIT"
Expand Down