Skip to content

Commit 32da99f

Browse files
authored
Merge pull request #161 from Labelbox/ms/model-run
[DIAG-196] model-run entity
2 parents 001f5db + b8ef057 commit 32da99f

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

labelbox/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@
1818
from labelbox.schema.ontology import Ontology
1919
from labelbox.schema.role import Role, ProjectRole
2020
from labelbox.schema.invite import Invite, InviteLimit
21+
from labelbox.schema.model_run import ModelRun

labelbox/client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def get_organization(self):
377377
"""
378378
return self._get_single(Organization, None)
379379

380-
def _get_all(self, db_object_type, where):
380+
def _get_all(self, db_object_type, where, filter_deleted=True):
381381
""" Fetches all the objects of the given type the user has access to.
382382
383383
Args:
@@ -387,8 +387,9 @@ def _get_all(self, db_object_type, where):
387387
Returns:
388388
An iterable of `db_object_type` instances.
389389
"""
390-
not_deleted = db_object_type.deleted == False
391-
where = not_deleted if where is None else where & not_deleted
390+
if filter_deleted:
391+
not_deleted = db_object_type.deleted == False
392+
where = not_deleted if where is None else where & not_deleted
392393
query_str, params = query.get_all(db_object_type, where)
393394

394395
return PaginatedCollection(
@@ -500,7 +501,7 @@ def create_project(self, **kwargs):
500501
def get_roles(self):
501502
"""
502503
Returns:
503-
Roles: Provides information on available roles within an organization.
504+
Roles: Provides information on available roles within an organization.
504505
Roles are used for user management.
505506
"""
506507
return role.get_roles(self)
@@ -531,4 +532,4 @@ def get_models(self, where=None):
531532
Returns:
532533
An iterable of Models (typically a PaginatedCollection).
533534
"""
534-
return self._get_all(Model, where)
535+
return self._get_all(Model, where, filter_deleted=False)

labelbox/schema/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
import labelbox.schema.ontology
1616
import labelbox.schema.invite
1717
import labelbox.schema.role
18+
import labelbox.schema.model_run

labelbox/schema/model.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
class Model(DbObject):
6-
"""A model represents a program that has been trained and
6+
"""A model represents a program that has been trained and
77
can make predictions on new data.
88
Attributes:
99
name (str)
@@ -12,5 +12,7 @@ class Model(DbObject):
1212
slices (Relationship): `ToMany` relationship to Slice (TODO)
1313
"""
1414

15-
name = Field.String("name")
16-
ontology = Relationship.ToOne("Ontology", True)
15+
name = Field.String("name")
16+
17+
model_runs = Relationship.ToMany("ModelRun", False)
18+
ontology = Relationship.ToOne("Ontology", False)

labelbox/schema/model_run.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from labelbox.orm.model import Field, Relationship
2+
from labelbox.orm.db_object import DbObject
3+
4+
5+
class ModelRun(DbObject):
6+
name = Field.String("name")
7+
updated_at = Field.DateTime("updated_at")
8+
created_at = Field.DateTime("created_at")
9+
created_by_id = Field.String("created_by_id", "createdBy")
10+
11+
def upsert_labels(self):
12+
...
13+
14+
def add_predictions(self, predictions):
15+
...

0 commit comments

Comments
 (0)