in ezsmdeploy/__init__.py [0:0]
def process_instance_type(self):
# ------ instance checks --------
self.instancedict = {}
if self.instance_type == None:
# ------ load instance types dict ---------
instancetypepath = pkg_resources.resource_filename(
"ezsmdeploy", "data/instancetypes.csv"
)
with open(instancetypepath, mode="r") as infile:
reader = csv.reader(infile)
for rows in reader: # memGb / vcpu, cost, cost/memGb-per-vcpu
self.instancedict[rows[0]] = (
float(rows[2]) / (2 * float(rows[1])),
self.costdict[rows[0]],
self.costdict[rows[0]] / float(rows[2]) / (2 * float(rows[1])),
)
# ------ auto instance selection ---------
self.choose_instance_type()
else:
if (self.instance_type in list(self.costdict.keys())) or (
self.instance_type in ["local", "local_gpu"]
):
if self.instance_type not in ["local", "local_gpu"]:
self.costperhour = self.costdict[self.instance_type]
if self.ei != None:
eicosts = {
"ml.eia2.medium": 0.12,
"ml.eia2.large": 0.24,
"ml.eia2.xlarge": 0.34,
"ml.eia.medium": 0.13,
"ml.eia.large": 0.26,
"ml.eia.xlarge": 0.52,
}
self.costperhour = self.costperhour + eicosts[self.ei]
else:
self.costperhour = 0
else:
raise ValueError(
"Please choose an instance type in",
list(self.costdict.keys()),
", or choose local for local testing.",
)