Skip to content

Commit

Permalink
Support arm
Browse files Browse the repository at this point in the history
  • Loading branch information
bra-fsn committed May 15, 2024
1 parent 63f47ba commit d5fcc73
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "sparecores-runner"
version = "0.0.2"
version = "0.0.3"
requires-python = ">= 3.9"
dependencies = [
"click",
Expand Down
4 changes: 4 additions & 0 deletions src/sc_runner/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ def servers_vendors(vendor: str, region: str | None = None, zone: str | None = N
if zone:
stmt = stmt.where(ServerPrice.zone_id == zone)
return session.exec(stmt.distinct()).all()


def server_cpu_architecture(vendor: str, server: str) -> str:
return session.exec(select(Server.cpu_architecture).where(Server.vendor_id == vendor).where(Server.api_reference == server)).one().value
5 changes: 4 additions & 1 deletion src/sc_runner/resources/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def resources_aws(
zone: Annotated[str, DefaultOpt(["--zone"], type=click.Choice(data.zones("aws")), help="Availability zone"), StackName()] = os.environ.get("AWS_ZONE", None),
assume_role_arn: Annotated[str, DefaultOpt(["--assume-role-arn"], type=str, help="Role to be assumed")] = os.environ.get("AWS_ASSUME_ROLE_ARN", ""),
ami_owner: Annotated[str, DefaultOpt(["--ami-owner"], type=str, help="AMI owner")] = os.environ.get("AWS_AMI_OWNER", "099720109477"),
ami_name: Annotated[str, DefaultOpt(["--ami-name"], type=str, help="AWS name filter")] = os.environ.get("AWS_AMI_NAME", "ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20240301"),
# to get the available image names:
# aws ec2 describe-images --region us-east-1 --owners 099720109477 | jq '.Images[].Name'
ami_name: Annotated[str, DefaultOpt(["--ami-name"], type=str, help="AWS name filter")] = os.environ.get("AWS_AMI_NAME", "ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-*-server-20240423"),
instance: Annotated[str, DefaultOpt(["--instance"], type=click.Choice(data.servers("aws")), help="Instance type"), StackName()] = os.environ.get("AWS_TYPE", "t3.micro"),
public_key: Annotated[str, DefaultOpt(["--public-key"], type=str, help="SSH public key")] = os.environ.get("SSH_PUBLIC_KEY", ""),
tags: Annotated[str, DefaultOpt(["--tags"], type=JSON, default=defaults(DEFAULTS, "tags"), help="Tags for created resources")] = default(DEFAULTS, "tags"),
Expand Down Expand Up @@ -71,6 +73,7 @@ def resources_aws(
ami = aws.ec2.get_ami(
most_recent=True, # in case of a filter is given as the name
filters=[
aws.ec2.GetAmiFilterArgs(name="architecture", values=[data.server_cpu_architecture("aws", instance)]),
aws.ec2.GetAmiFilterArgs(name="name", values=[ami_name]),
aws.ec2.GetAmiFilterArgs(name="virtualization-type", values=["hvm"]),
],
Expand Down

0 comments on commit d5fcc73

Please sign in to comment.