Skip to content

Commit

Permalink
[Optimizer] Fix NoneType for egress when pipeline is specified (#2579)
Browse files Browse the repository at this point in the history
* Fix NoneType for egress cost

* Fix type check
  • Loading branch information
Michaelvll authored Sep 19, 2023
1 parent bc4acc8 commit 617603f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sky/clouds/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def accelerators_to_hourly_cost(self,
# GPUs, while the task specifies to use 1 GPU.
return 0

def get_egress_cost(self, num_gigabytes):
def get_egress_cost(self, num_gigabytes: float):
# In general, query this from the cloud:
# https://azure.microsoft.com/en-us/pricing/details/bandwidth/
# NOTE: egress from US East.
Expand Down
2 changes: 1 addition & 1 deletion sky/clouds/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def accelerators_to_hourly_cost(self, accelerators: Dict[str, int],
"""Returns the hourly on-demand price for accelerators."""
raise NotImplementedError

def get_egress_cost(self, num_gigabytes):
def get_egress_cost(self, num_gigabytes: float):
"""Returns the egress cost.
TODO: takes into account "per month" accumulation per account.
Expand Down
2 changes: 1 addition & 1 deletion sky/clouds/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def accelerators_to_hourly_cost(self,
zone=zone,
clouds='gcp')

def get_egress_cost(self, num_gigabytes):
def get_egress_cost(self, num_gigabytes: float):
# In general, query this from the cloud:
# https://cloud.google.com/storage/pricing#network-pricing
# NOTE: egress to worldwide (excl. China, Australia).
Expand Down
4 changes: 2 additions & 2 deletions sky/clouds/ibm.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def accelerators_to_hourly_cost(self,
# Currently Isn't implemented in the same manner by aws and azure.
return 0

def get_egress_cost(self, num_gigabytes):
def get_egress_cost(self, num_gigabytes: float):
"""Returns the egress cost. Currently true for us-south, i.e. Dallas.
based on https://cloud.ibm.com/objectstorage/create#pricing. """
cost = 0
cost = 0.
price_thresholds = [{
'threshold': 150,
'price_per_gb': 0.05
Expand Down
12 changes: 9 additions & 3 deletions sky/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ def _egress_cost_or_time(minimize_cost: bool, parent: task_lib.Task,
if not nbytes:
# nbytes can be None, if the task has no inputs/outputs.
return 0
assert src_cloud is not None and dst_cloud is not None
assert src_cloud is not None and dst_cloud is not None, (src_cloud,
dst_cloud,
nbytes)

if minimize_cost:
fn = Optimizer._egress_cost
Expand Down Expand Up @@ -636,8 +638,12 @@ def _print_egress_plan(graph, plan, minimize_cost):
for parent, child in graph.edges():
src_cloud, dst_cloud, nbytes = Optimizer._get_egress_info(
parent, plan[parent], child, plan[child])
if nbytes == 0:
continue
if not nbytes:
# nbytes can be None, if the task has no inputs/outputs.
return 0
assert src_cloud is not None and dst_cloud is not None, (src_cloud,
dst_cloud,
nbytes)

if minimize_cost:
fn = Optimizer._egress_cost
Expand Down

0 comments on commit 617603f

Please sign in to comment.