From c4d54474a7827cb7c684c2dfe4a6ad8b058fd4b2 Mon Sep 17 00:00:00 2001 From: ledell Date: Thu, 30 Aug 2018 18:02:11 -0700 Subject: [PATCH] Adding support for subnet_id in AWS script & config --- aws/AwsDockerOMLRun.py | 6 ++++++ config.json | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/aws/AwsDockerOMLRun.py b/aws/AwsDockerOMLRun.py index dca06ce35..eb549db6e 100644 --- a/aws/AwsDockerOMLRun.py +++ b/aws/AwsDockerOMLRun.py @@ -24,6 +24,10 @@ def __init__(self, aws_instance_type, docker_image, openml_id, fold, self.setup = config["setup"] self.token = config["token"] + if config["subnet_id"] == "": + self.subnet_id = None + else: + self.subnet_id = config["subnet_id"] if region_name is None: if "region_name" in config.keys() and len(config["region_name"]) > 0: @@ -32,6 +36,7 @@ def __init__(self, aws_instance_type, docker_image, openml_id, fold, self.region_name = boto3.session.Session().region_name self.ec2_resource = boto3.resource("ec2", region_name=region_name) + with open("resources/ami.json") as file: amis = json.load(file) @@ -55,6 +60,7 @@ def createInstanceRun(self): MinCount=1, MaxCount=1, InstanceType=self.aws_instance_type, + SubnetId=self.subnet_id, UserData=setup)[0] def terminateInstance(self): diff --git a/config.json b/config.json index bd554a663..dcf008f00 100644 --- a/config.json +++ b/config.json @@ -4,5 +4,6 @@ "overhead_time":600, "query_frequency":10, "max_parallel_jobs":5, - "region_name":"eu-west-1" + "region_name":"us-east-1", + "subnet_id":"" }