Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SS-556 allow flavors with gpu in jupyter labs #246

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/models/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def get_k8s_values(self):
name=(self.subdomain.subdomain if self.subdomain else "deleted") + "-" + self.app.slug,
),
**self.subdomain.to_dict() if self.subdomain else {},
**self.flavor.to_dict() if self.flavor else {},
**self.flavor.to_dict(self.app.slug) if self.flavor else {},
storageClass=settings.STORAGECLASS,
namespace=settings.NAMESPACE,
release=self.subdomain.subdomain if self.subdomain else "deleted", # This is legacy and should be changed
Expand Down
8 changes: 5 additions & 3 deletions projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Flavor(models.Model):
def __str__(self):
return str(self.name)

def to_dict(self):
def to_dict(self, app_slug=None):
flavor_dict = dict(
flavor=dict(
requests={
Expand All @@ -101,8 +101,10 @@ def to_dict(self):
},
)
)
if self.gpu_req and int(self.gpu_req) > 0:
flavor_dict["flavor"]["requests"]["nvidia.com/gpu"] = (self.gpu_req,)
# allow GPU only for specific apps.
apps_allowed_gpus = ["jupyter-lab"]
if self.gpu_req and int(self.gpu_req) > 0 and app_slug in apps_allowed_gpus:
flavor_dict["flavor"]["requests"]["nvidia.com/gpu"] = self.gpu_req
flavor_dict["flavor"]["limits"]["nvidia.com/gpu"] = self.gpu_lim

return flavor_dict
Expand Down