-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nikita Churikov <nikita@chur.ru>
- Loading branch information
Showing
17 changed files
with
1,181 additions
and
990 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from crispy_forms.layout import Div, Field, Layout | ||
|
||
from apps.forms.base import BaseForm | ||
from apps.models import MLFlowInstance | ||
|
||
__all__ = [ | ||
"MLFlowAppForm", | ||
] | ||
|
||
|
||
class MLFlowAppForm(BaseForm): | ||
def _setup_form_helper(self): | ||
super()._setup_form_helper() | ||
body = Div( | ||
Field("name", placeholder="Name your app"), | ||
Field("subdomain", placeholder="Enter a subdomain or leave blank for a random one"), | ||
css_class="card-body", | ||
) | ||
|
||
self.helper.layout = Layout(body, self.footer) | ||
|
||
class Meta: | ||
model = MLFlowInstance | ||
fields = ["name"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
apps/migrations/0022_mlflowinstance_apps_user_can_see_secrets.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 5.1.1 on 2025-02-21 10:44 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("apps", "0021_dashinstance_default_url_subpath"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="MLFlowInstance", | ||
fields=[ | ||
( | ||
"baseappinstance_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="apps.baseappinstance", | ||
), | ||
), | ||
("access", models.CharField(choices=[("project", "Project")], default="project", max_length=20)), | ||
], | ||
options={ | ||
"verbose_name": "MLFlow App Instance", | ||
"verbose_name_plural": "MLFlow App Instances", | ||
"permissions": [("can_access_app", "Can access app service")], | ||
}, | ||
bases=("apps.baseappinstance",), | ||
), | ||
migrations.AddField( | ||
model_name="apps", | ||
name="user_can_see_secrets", | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from django.db import models | ||
from django.utils.crypto import get_random_string | ||
|
||
from apps.models import AppInstanceManager, BaseAppInstance | ||
|
||
|
||
class MlflowAppManager(AppInstanceManager): | ||
model_type = "mlflow" | ||
|
||
|
||
class MLFlowInstance(BaseAppInstance): | ||
objects = MlflowAppManager() | ||
ACCESS_TYPES = (("project", "Project"),) | ||
access = models.CharField(max_length=20, default="project", choices=ACCESS_TYPES) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
def get_k8s_values(self): | ||
k8s_values = super().get_k8s_values() | ||
k8s_values["commonLabels"] = { | ||
"release": self.subdomain.subdomain, | ||
"app": "mlflow", | ||
"project": self.project.slug, | ||
} | ||
k8s_values["tracking"] = { | ||
"auth": {"enabled": True, "username": get_random_string(10), "password": get_random_string(20)}, | ||
"ingress": { | ||
"enabled": True, | ||
"ingressClassName": "nginx", | ||
"hostname": self.url.split("://")[1] if self.url is not None else self.url, | ||
}, | ||
"podLabels": { | ||
"type": "app", | ||
}, | ||
"resources": { | ||
"requests": {"cpu": "1", "memory": "512Mi", "ephemeral-storage": "512Mi"}, | ||
"limits": {"cpu": "2", "memory": "1Gi", "ephemeral-storage": "1Gi"}, | ||
}, | ||
"pdb": {"create": False}, | ||
} | ||
k8s_values["run"] = { | ||
"resources": { | ||
"requests": {"cpu": "1", "memory": "512Mi", "ephemeral-storage": "512Mi"}, | ||
"limits": {"cpu": "2", "memory": "1Gi", "ephemeral-storage": "1Gi"}, | ||
} | ||
} | ||
k8s_values["minio"] = {"pdb": {"create": False}} | ||
k8s_values["postgresql"] = { | ||
"primary": { | ||
"pdb": {"create": False}, | ||
}, | ||
"readReplicas": { | ||
"pdb": {"create": False}, | ||
}, | ||
} | ||
return k8s_values | ||
|
||
class Meta: | ||
verbose_name = "MLFlow App Instance" | ||
verbose_name_plural = "MLFlow App Instances" | ||
permissions = [("can_access_app", "Can access app service")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.