Skip to content

Commit

Permalink
add QoS support for airflow as well
Browse files Browse the repository at this point in the history
  • Loading branch information
saikonen committed Dec 5, 2024
1 parent 31b4725 commit 43e99df
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions metaflow/plugins/airflow/airflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# TODO: Move chevron to _vendor
from metaflow.plugins.cards.card_modules import chevron
from metaflow.plugins.kubernetes.kubernetes import Kubernetes
from metaflow.plugins.kubernetes.kube_utils import qos_requests_and_limits
from metaflow.plugins.timeout_decorator import get_run_time_limit_for_task
from metaflow.util import compress_list, dict_to_cli_options, get_username

Expand Down Expand Up @@ -428,25 +429,25 @@ def _to_job(self, node):
if k8s_deco.attributes["namespace"] is not None
else "default"
)

qos_requests, qos_limits = qos_requests_and_limits(
k8s_deco.attributes["qos"],
k8s_deco.attributes["cpu"],
k8s_deco.attributes["memory"],
k8s_deco.attributes["disk"],
)
resources = dict(
requests={
"cpu": k8s_deco.attributes["cpu"],
"memory": "%sM" % str(k8s_deco.attributes["memory"]),
"ephemeral-storage": str(k8s_deco.attributes["disk"]),
}
requests=qos_requests,
limits={
**qos_limits,
**{
"%s.com/gpu".lower()
% k8s_deco.attributes["gpu_vendor"]: str(k8s_deco.attributes["gpu"])
for k in [0]
# Don't set GPU limits if gpu isn't specified.
if k8s_deco.attributes["gpu"] is not None
},
},
)
if k8s_deco.attributes["gpu"] is not None:
resources.update(
dict(
limits={
"%s.com/gpu".lower()
% k8s_deco.attributes["gpu_vendor"]: str(
k8s_deco.attributes["gpu"]
)
}
)
)

annotations = {
"metaflow/production_token": self.production_token,
Expand Down

0 comments on commit 43e99df

Please sign in to comment.