Skip to content

Commit

Permalink
Minor that caused cross-joins to take place, reflected that in the de…
Browse files Browse the repository at this point in the history
…mo video
  • Loading branch information
Carlo Mazzaferro committed Nov 16, 2018
1 parent b1c2187 commit 974f6b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ usually a big enough challenge to grant the employment of an entire separate tea
the project is removing (or at least softening) the dependency on machine learning engineers and devops,
enabling data scientist to go from concept to production in minutes.

.. note:: **STATUS**: early alpha. Active development, but breaking changes may come.
.. note:: **STATUS**: alpha. Active development, but breaking changes may come.

Features
--------
Expand All @@ -57,7 +57,7 @@ Demo

.. raw:: html

<a href="https://asciinema.org/a/ZVbYSQSjGOg03HmnLNVQGBygI?autoplay=1" target="_blank"><img src="https://asciinema.org/a/dinc7mQrUfO2JqFhV3iyYllIc.svg" width="835"/></a>
<a href="https://asciinema.org/a/xxoebEfyu1bzO84hWWAams577?autoplay=1" target="_blank"><img src="https://asciinema.org/a/dinc7mQrUfO2JqFhV3iyYllIc.svg" width="835"/></a>


Credits
Expand Down
17 changes: 9 additions & 8 deletions racket/operations/schema.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Union
from sqlalchemy import desc

from sqlalchemy.orm.exc import NoResultFound

from racket.managers.server import ServerManager
from racket.managers.version import VersionManager
from racket.models import db
from racket.models.exceptions import ModelNotFoundError
from racket.models.base import MLModelInputs, MLModel, ModelScores
from racket.models.exceptions import ModelNotFoundError


def deactivate() -> None:
Expand Down Expand Up @@ -42,8 +42,8 @@ def active_model_(name: bool = None, scores: bool = False) -> Union[str, dict]:
active = db.session.query(MLModel).filter(MLModel.active == True).one() # NOQA
if scores:
return db.session.query(MLModel, ModelScores).filter(MLModel.model_id == active.model_id) \
.filter(ModelScores.model_id == MLModel.model_id) \
.all()
.filter(ModelScores.model_id == MLModel.model_id) \
.all()
if name:
active = db.session.query(MLModel.model_name).filter(MLModel.model_id == active.model_id).one()
return active[0]
Expand All @@ -69,8 +69,8 @@ def query_by_id_(model_id: int, scores: bool = False) -> MLModel:
with app.app_context():
if scores:
return db.session.query(MLModel, ModelScores).filter(MLModel.model_id == model_id) \
.filter(ModelScores.model_id == MLModel.model_id) \
.all()
.filter(ModelScores.model_id == MLModel.model_id) \
.all()
servable = db.session.query(MLModel).filter(MLModel.model_id == model_id).one_or_none()
if not servable:
raise ModelNotFoundError(f'The model requested with id {model_id} was not found in the database')
Expand All @@ -89,12 +89,13 @@ def model_filterer_(name, version, m_type):
app = ServerManager.create_app('prod', False)
with app.app_context():
query = db.session.query(MLModel, ModelScores) \
.filter(*fs)
.filter(*fs)
return query.all()


def query_all_():
app = ServerManager.create_app('prod', False)
with app.app_context():
query = db.session.query(MLModel, ModelScores)
query = db.session.query(MLModel, ModelScores) \
.filter(MLModel.model_id == ModelScores.model_id)
return query.all()

0 comments on commit 974f6b4

Please sign in to comment.