Skip to content

Commit c5dabbb

Browse files
committed
Remove spot pricing
1 parent 669938b commit c5dabbb

File tree

3 files changed

+7807
-61858
lines changed

3 files changed

+7807
-61858
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# `resotodata`
2-
Public Resoto Data
2+
Public Resoto Cloud Data
33

44
Location data is open data, licensed under the [Open Data Commons Open Database License (ODbL)](https://opendatacommons.org/licenses/odbl/) by the [OpenStreetMap Foundation (OSMF)](https://wiki.osmfoundation.org/wiki/Main_Page).
55

resotodata/__main__.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ def update_colors() -> None:
2929

3030

3131
def update_ccfdataset() -> None:
32-
write_ccfdataset()
32+
ccfdataset = get_ccfdataset()
33+
write_ccfdataset(ccfdataset)
3334

3435

3536
def update_instances() -> None:
36-
write_instances()
37+
instances = {"aws": get_aws_instances()}
38+
strip_instances(instances)
39+
write_instances(instances)
3740

3841

3942
def gen_digitalocean_regions() -> dict:
@@ -219,29 +222,23 @@ def write_colors() -> None:
219222
f.write("\n")
220223

221224

222-
def write_ccfdataset() -> None:
223-
ccfdataset = get_ccfdataset()
224-
225+
def write_ccfdataset(ccfdataset: dict) -> None:
225226
ccfdataset_file = resource_filename("resotodata", "data/ccfdataset.json")
226227
print(f"Writing CCF dataset to {ccfdataset_file}")
227228
with open(ccfdataset_file, "w") as f:
228229
json.dump(ccfdataset, f, indent=4)
229230
f.write("\n")
230231

231232

232-
def write_instances() -> None:
233-
instances = get_instances()
234-
235-
strip_instances(instances)
236-
233+
def write_instances(instances: dict) -> None:
237234
instances_file = resource_filename("resotodata", "data/instances.json")
238235
print(f"Writing instances dataset to {instances_file}")
239236
with open(instances_file, "w") as f:
240237
json.dump(instances, f, indent=4)
241238
f.write("\n")
242239

243240

244-
def is_float(n):
241+
def is_float(n) -> bool:
245242
try:
246243
_ = float(n)
247244
except ValueError:
@@ -252,14 +249,19 @@ def is_float(n):
252249

253250
def strip_instances(instances: dict) -> None:
254251
print("Stripping instance data")
252+
spot_keywords = ["spot", "spot_min", "spot_max"]
255253
for cloud, cloud_data in instances.items():
256254
for instance_type, instance_type_data in cloud_data.items():
257255
for region, region_pricing_data in instance_type_data.get("pricing", {}).items():
258256
for key in list(region_pricing_data.keys()):
259257
if key not in ("dedicated", "linux", "unknown"):
260-
print(f"Removing {key} from {cloud} {instance_type} {region} pricing data")
261258
del region_pricing_data[key]
262-
259+
if "linux" in region_pricing_data:
260+
for keyword in spot_keywords:
261+
try:
262+
del region_pricing_data["linux"][keyword]
263+
except KeyError:
264+
pass
263265
for price_data in region_pricing_data.values():
264266
if "ondemand" in price_data and is_float(price_data["ondemand"]):
265267
price_data["ondemand"] = float(price_data["ondemand"])
@@ -328,10 +330,6 @@ def get_ccfdataset() -> dict:
328330
return json.loads(result.stdout)
329331

330332

331-
def get_instances() -> dict:
332-
return {"aws": get_aws_instances()}
333-
334-
335333
def get_aws_instances() -> dict:
336334
print("Checking if git is installed")
337335
for tool in ("git",):

0 commit comments

Comments
 (0)