Skip to content

Commit

Permalink
Merge pull request #447 from ddps-lab/gcp-collector
Browse files Browse the repository at this point in the history
매일 UTC 00시에만 Pricelist에 없는 인스턴스를 전송하도록 수정
  • Loading branch information
red0sena authored Sep 12, 2023
2 parents 7946b26 + 14ead84 commit 22a6321
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions collector/spot-dataset/gcp/lambda/load_pricelist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pandas as pd
from utility import slack_msg_sender
from datetime import datetime

def extract_price(machine_type, price_data, price_type):
# get price from pricelist and put into output data (for N1 : f1-micro, g1-small)
Expand Down Expand Up @@ -46,6 +47,8 @@ def get_price(pricelist, df_instance_metadata, available_region_lists):
# input : pricelist of compute engine unit, metadata, available lists
# output : dictionary data of calculated price

now_hour = datetime.utcnow().hour

global output
output = {}
for instance_type in df_instance_metadata['instance_type']:
Expand All @@ -68,7 +71,8 @@ def get_price(pricelist, df_instance_metadata, available_region_lists):
preemptible_data = pricelist[f'CP-COMPUTEENGINE-VMIMAGE-{instance_type.upper()}-PREEMPTIBLE']
extract_price(instance_type, preemptible_data, 'preemptible')
except:
slack_msg_sender.send_slack_message(f"GCP load pricelist : {instance_type} series is missing in pricelist")
if now_hour == 0:
slack_msg_sender.send_slack_message(f"GCP load pricelist : {instance_type} series is missing in pricelist")

else :
# get gpu data
Expand All @@ -85,13 +89,15 @@ def get_price(pricelist, df_instance_metadata, available_region_lists):
if '80GB' in accelerator :
accelerator =accelerator.replace ('_80GB', '-80GB', 1)
except :
slack_msg_sender.send_slack_message(f"GCP load pricelist : accelerator naming '80GB' seems to be changed in aggregated API result.")
if now_hour == 0:
slack_msg_sender.send_slack_message(f"GCP load pricelist : accelerator naming '80GB' seems to be changed in aggregated API result.")

try:
gpu_data = pricelist[f'GPU_{accelerator}']
gpu_data_preemptible = pricelist[f'GPU_{accelerator}-PREEMPTIBLE']
except:
slack_msg_sender.send_slack_message(f"GCP load pricelist : accelerator {accelerator} naming seems to be changed in pricelist.")
if now_hour == 0:
slack_msg_sender.send_slack_message(f"GCP load pricelist : accelerator {accelerator} naming seems to be changed in pricelist.")

try:
# ondemand
Expand All @@ -107,7 +113,8 @@ def get_price(pricelist, df_instance_metadata, available_region_lists):
except KeyError:
# M2 series doesn't support Spot (preemptible)
if series not in ['m2']:
slack_msg_sender.send_slack_message(f"GCP load pricelist : {instance_type} series is missing in pricelist")
if now_hour == 0:
slack_msg_sender.send_slack_message(f"GCP load pricelist : {instance_type} series is missing in pricelist")

return output

Expand Down

0 comments on commit 22a6321

Please sign in to comment.