Skip to content

Commit cfd9003

Browse files
authored
Merge pull request #562 from ddps-lab/azure-collector-fix
Azure collector 구독 관리 모듈 개선
2 parents 8bca52e + 947c002 commit cfd9003

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

collector/spot-dataset/azure/lambda/current_collector/load_sps.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ def execute_spot_placement_score_task_by_parameter_pool_df(api_calls_df, desired
201201
result = future.result()
202202
desired_count = future_to_desired_count[future]
203203
if result and result != "NO_AVAILABLE_LOCATIONS":
204-
SS_Resources.succeed_to_get_sps_count += 1
205204
for score in result["placementScores"]:
206205
score_data = {
207206
"DesiredCount": desired_count,
@@ -292,8 +291,8 @@ def execute_spot_placement_score_api(region_chunk, instance_type_chunk, desired_
292291
}
293292
try:
294293
response = requests.post(url, headers=headers, json=request_body, timeout=50)
295-
SL_Manager.update_call_history(subscription_id, location)
296294
response.raise_for_status()
295+
SS_Resources.succeed_to_get_sps_count += 1
297296
return response.json()
298297

299298
except requests.exceptions.Timeout:

collector/spot-dataset/azure/lambda/current_collector/sps_module/sps_location_manager.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ def check_and_add_available_locations(az):
5252
return False
5353

5454

55-
def validation_can_call(location, history, over_limit_locations):
55+
def validation_can_call(subscription_id, location):
5656
"""
5757
이 메서드는 지정된 location으로 호출 가능한지 확인합니다.
5858
초과 요청 여부와 호출 이력의 크기를 기준으로 판단합니다.
5959
"""
60-
if over_limit_locations:
61-
if ((location not in over_limit_locations)
62-
and (len(history[location]) < 10)):
60+
if SS_Resources.locations_over_limit_tmp.get(subscription_id):
61+
if ((location not in SS_Resources.locations_over_limit_tmp.get(subscription_id))
62+
and (len(SS_Resources.locations_call_history_tmp[subscription_id][location]) < 10)):
6363
return True
6464
else:
65-
if len(history[location]) < 10:
65+
if len(SS_Resources.locations_call_history_tmp[subscription_id][location]) < 10:
6666
return True
6767
return False
6868

@@ -105,8 +105,9 @@ def get_next_available_location():
105105
SS_Resources.last_subscription_id_and_location_tmp['last_subscription_id'] = subscription_id
106106
SS_Resources.last_subscription_id_and_location_tmp['last_location'] = location
107107

108-
if validation_can_call(location, SS_Resources.locations_call_history_tmp[subscription_id], SS_Resources.locations_over_limit_tmp.get(subscription_id)):
108+
if validation_can_call(subscription_id, location):
109109
SS_Resources.succeed_to_get_next_available_location_count += 1
110+
update_call_history(subscription_id, location)
110111
return subscription_id, location
111112

112113
return None

0 commit comments

Comments
 (0)