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

Commit

Permalink
Merge pull request #123 from scaleoutsystems/serve-path-based
Browse files Browse the repository at this point in the history
Serving with path-based routing works
  • Loading branch information
stefanhellander authored Aug 6, 2020
2 parents a99cf66 + 2f8b60e commit 6d9f153
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cli/scaleout/cli/create_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create_model_cmd(ctx, model, name, tag, description):
@click.option('-p', '--path_predict')
@click.pass_context
def create_deployment_definition(ctx, name, filepath, path_predict=''):
""" Create a depliyment definition. """
""" Create a deployment definition. """
client = ctx.obj['CLIENT']
client.create_deployment_definition(name, filepath, path_predict)

Expand Down
10 changes: 9 additions & 1 deletion components/studio/deployments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class DeploymentInstance(models.Model):
model = models.OneToOneField('models.Model', on_delete=models.CASCADE, related_name='deployed_model', unique=True)
access = models.CharField(max_length=2, choices=ACCESS, default=PRIVATE)
endpoint = models.CharField(max_length=512)
path = models.CharField(max_length=512)
release = models.CharField(max_length=512)
# sample_input = models.TextField(blank=True, null=True)
# sample_output = models.TextField(blank=True, null=True)
Expand Down Expand Up @@ -81,8 +82,14 @@ def pre_save_deployment(sender, instance, using, **kwargs):
deployment_endpoint = '{}-{}.{}'.format(model.name,
model.tag,
settings.DOMAIN)
instance.endpoint = deployment_endpoint

deployment_endpoint = settings.DOMAIN
deployment_path = '/{}/serve/{}/{}'.format(model.project.slug,
model.name,
model.tag)

instance.endpoint = deployment_endpoint
instance.path = deployment_path

context = instance.deployment
context_image = context.image
Expand All @@ -109,6 +116,7 @@ def pre_save_deployment(sender, instance, using, **kwargs):
'deployment.version': deployment_version,
'deployment.name': deployment_name,
'deployment.endpoint': deployment_endpoint,
'deployment.path': deployment_path,
'context.image': context_image,
'model.bucket': model_bucket,
'model.file': model_file,
Expand Down
2 changes: 1 addition & 1 deletion components/studio/deployments/templates/deploy/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h2>Deployments</h2>
<td>{{ deploy.model.name }}</td>
<td>{{ deploy.model.tag }}</td>
<td>{{ deploy.deployment.name }}</td>
<td>https://{{ deploy.endpoint }}/{{ deploy.deployment.path_predict }}</td>
<td>https://{{ deploy.endpoint }}{{ deploy.path }}/{{ deploy.deployment.path_predict }}</td>
{% if authorized_as %}
<td>{{ deploy.definition }}</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion components/studio/deployments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def predict(request, id, project):
import requests
import json

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

# Get user token
from rest_framework.authtoken.models import Token
Expand Down
2 changes: 1 addition & 1 deletion components/studio/models/templates/models_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ <h2>{{ model.name }}</h2>
<th scope="row">{{ d.pk }}</th>
<td>{{ d.model.name }}:{{ d.model.tag }}</td>
<td>
<a href="{{ d.endpoint }}" target="_blank">{{ d.endpoint }}</a>
<a href="https://{{ d.endpoint }}{{ d.path }}/{{ d.deployment.path_predict }}" target="_blank">{{ d.endpoint }}{{ d.path }}/{{ d.deployment.path_predict }}</a>
</td>
<td>{{ d.created_at }}</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h2>{{ model.name }}</h2>
<th scope="row">{{ d.pk }}</th>
<td>{{ d.model.name }}:{{ d.model.tag }}</td>
<td>
<a href="{{ d.endpoint }}" target="_blank">{{ d.endpoint }}</a>
<a href="https://{{ d.endpoint }}{{ d.path }}/{{ d.deployment.path_predict }}" target="_blank">{{ d.endpoint }}/{{ d.path }}/{{ d.deployment.path_predict }}</a>
</td>
<td>{{ d.created_at }}</td>
</tr>
Expand Down
28 changes: 26 additions & 2 deletions components/studio/projects/fixtures/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@
"updated_at": "2020-03-17T08:36:01.459Z",
"created_at": "2020-03-16T12:01:51.999Z"
}
},
{
}, {
"model": "projects.environment",
"pk": 2,
"fields": {
"name": "Tensorflow",
"slug": "tensorflow",
"image": "scaleoutsystems/jupyter-tensflow-stackn:master",
"dockerfile": "FROM scaleoutsystems/jupyter-tensflow-stackn:master",
"startup": "",
"teardown": "",
"updated_at": "2020-03-17T08:36:01.459Z",
"created_at": "2020-03-16T12:01:51.999Z"
}
}, {
"model": "projects.flavor",
"pk": 1,
"fields": {
Expand All @@ -36,4 +48,16 @@
"updated_at": "2020-04-30T09:00:59.305Z",
"created_at": "2020-04-30T09:00:59.305Z"
}
}, {
"model": "projects.flavor",
"pk": 3,
"fields": {
"name": "Large CPU: 1000m Memory: 2Gi",
"slug": "large",
"cpu": "1000m",
"mem": "2Gi",
"gpu": "",
"updated_at": "2020-04-30T09:00:59.305Z",
"created_at": "2020-04-30T09:00:59.305Z"
}
}]

0 comments on commit 6d9f153

Please sign in to comment.