Skip to content
This repository was archived by the owner on Mar 17, 2024. It is now read-only.

Commit 6d9f153

Browse files
Merge pull request #123 from scaleoutsystems/serve-path-based
Serving with path-based routing works
2 parents a99cf66 + 2f8b60e commit 6d9f153

File tree

7 files changed

+40
-8
lines changed

7 files changed

+40
-8
lines changed

cli/scaleout/cli/create_cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def create_model_cmd(ctx, model, name, tag, description):
3535
@click.option('-p', '--path_predict')
3636
@click.pass_context
3737
def create_deployment_definition(ctx, name, filepath, path_predict=''):
38-
""" Create a depliyment definition. """
38+
""" Create a deployment definition. """
3939
client = ctx.obj['CLIENT']
4040
client.create_deployment_definition(name, filepath, path_predict)
4141

components/studio/deployments/models.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class DeploymentInstance(models.Model):
4646
model = models.OneToOneField('models.Model', on_delete=models.CASCADE, related_name='deployed_model', unique=True)
4747
access = models.CharField(max_length=2, choices=ACCESS, default=PRIVATE)
4848
endpoint = models.CharField(max_length=512)
49+
path = models.CharField(max_length=512)
4950
release = models.CharField(max_length=512)
5051
# sample_input = models.TextField(blank=True, null=True)
5152
# sample_output = models.TextField(blank=True, null=True)
@@ -81,8 +82,14 @@ def pre_save_deployment(sender, instance, using, **kwargs):
8182
deployment_endpoint = '{}-{}.{}'.format(model.name,
8283
model.tag,
8384
settings.DOMAIN)
84-
instance.endpoint = deployment_endpoint
8585

86+
deployment_endpoint = settings.DOMAIN
87+
deployment_path = '/{}/serve/{}/{}'.format(model.project.slug,
88+
model.name,
89+
model.tag)
90+
91+
instance.endpoint = deployment_endpoint
92+
instance.path = deployment_path
8693

8794
context = instance.deployment
8895
context_image = context.image
@@ -109,6 +116,7 @@ def pre_save_deployment(sender, instance, using, **kwargs):
109116
'deployment.version': deployment_version,
110117
'deployment.name': deployment_name,
111118
'deployment.endpoint': deployment_endpoint,
119+
'deployment.path': deployment_path,
112120
'context.image': context_image,
113121
'model.bucket': model_bucket,
114122
'model.file': model_file,

components/studio/deployments/templates/deploy/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ <h2>Deployments</h2>
4747
<td>{{ deploy.model.name }}</td>
4848
<td>{{ deploy.model.tag }}</td>
4949
<td>{{ deploy.deployment.name }}</td>
50-
<td>https://{{ deploy.endpoint }}/{{ deploy.deployment.path_predict }}</td>
50+
<td>https://{{ deploy.endpoint }}{{ deploy.path }}/{{ deploy.deployment.path_predict }}</td>
5151
{% if authorized_as %}
5252
<td>{{ deploy.definition }}</td>
5353
<td>

components/studio/deployments/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def predict(request, id, project):
2727
import requests
2828
import json
2929

30-
predict_url = 'https://{}/{}'.format(deployment.endpoint, deployment.deployment.path_predict)
30+
predict_url = 'https://{}{}/{}'.format(deployment.endpoint, deployment.path, deployment.deployment.path_predict)
3131

3232
# Get user token
3333
from rest_framework.authtoken.models import Token

components/studio/models/templates/models_details.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ <h2>{{ model.name }}</h2>
124124
<th scope="row">{{ d.pk }}</th>
125125
<td>{{ d.model.name }}:{{ d.model.tag }}</td>
126126
<td>
127-
<a href="{{ d.endpoint }}" target="_blank">{{ d.endpoint }}</a>
127+
<a href="https://{{ d.endpoint }}{{ d.path }}/{{ d.deployment.path_predict }}" target="_blank">{{ d.endpoint }}{{ d.path }}/{{ d.deployment.path_predict }}</a>
128128
</td>
129129
<td>{{ d.created_at }}</td>
130130
</tr>

components/studio/models/templates/models_details_public.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ <h2>{{ model.name }}</h2>
9191
<th scope="row">{{ d.pk }}</th>
9292
<td>{{ d.model.name }}:{{ d.model.tag }}</td>
9393
<td>
94-
<a href="{{ d.endpoint }}" target="_blank">{{ d.endpoint }}</a>
94+
<a href="https://{{ d.endpoint }}{{ d.path }}/{{ d.deployment.path_predict }}" target="_blank">{{ d.endpoint }}/{{ d.path }}/{{ d.deployment.path_predict }}</a>
9595
</td>
9696
<td>{{ d.created_at }}</td>
9797
</tr>

components/studio/projects/fixtures/data.json

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,20 @@
1111
"updated_at": "2020-03-17T08:36:01.459Z",
1212
"created_at": "2020-03-16T12:01:51.999Z"
1313
}
14-
},
15-
{
14+
}, {
15+
"model": "projects.environment",
16+
"pk": 2,
17+
"fields": {
18+
"name": "Tensorflow",
19+
"slug": "tensorflow",
20+
"image": "scaleoutsystems/jupyter-tensflow-stackn:master",
21+
"dockerfile": "FROM scaleoutsystems/jupyter-tensflow-stackn:master",
22+
"startup": "",
23+
"teardown": "",
24+
"updated_at": "2020-03-17T08:36:01.459Z",
25+
"created_at": "2020-03-16T12:01:51.999Z"
26+
}
27+
}, {
1628
"model": "projects.flavor",
1729
"pk": 1,
1830
"fields": {
@@ -36,4 +48,16 @@
3648
"updated_at": "2020-04-30T09:00:59.305Z",
3749
"created_at": "2020-04-30T09:00:59.305Z"
3850
}
51+
}, {
52+
"model": "projects.flavor",
53+
"pk": 3,
54+
"fields": {
55+
"name": "Large CPU: 1000m Memory: 2Gi",
56+
"slug": "large",
57+
"cpu": "1000m",
58+
"mem": "2Gi",
59+
"gpu": "",
60+
"updated_at": "2020-04-30T09:00:59.305Z",
61+
"created_at": "2020-04-30T09:00:59.305Z"
62+
}
3963
}]

0 commit comments

Comments
 (0)