Skip to content

Commit e3fba71

Browse files
author
Matt Sokoloff
committed
query for ontology
1 parent 47bab9d commit e3fba71

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

labelbox/client.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from labelbox.schema.labeling_frontend import LabelingFrontend
2929
from labelbox.schema.iam_integration import IAMIntegration
3030
from labelbox.schema import role
31+
from labelbox.orm.model import Entity
3132

3233
logger = logging.getLogger(__name__)
3334

@@ -709,3 +710,22 @@ def get_data_row_ids_for_external_ids(
709710
})['externalIdsToDataRowIds']:
710711
result[row['externalId']].append(row['dataRowId'])
711712
return result
713+
714+
def get_ontology(self, ontology_id):
715+
return self._get_single(Entity.Ontology, ontology_id)
716+
717+
def get_ontologies(self, name_contains: str):
718+
query_str = """query getOntologiesPyApi($search: String, $filter: OntologyFilter, $from : String, $first: PageSize){
719+
ontologies(where: {filter: $filter, search: $search}, after: $from, first: $first){
720+
nodes {%s}
721+
nextCursor
722+
}
723+
}
724+
""" % query.results_query_part(Entity.Ontology)
725+
res = PaginatedCollection(
726+
self, query_str, {'search' : name_contains, 'filter' :{'status' : 'ALL'}}, ['ontologies', 'nodes'],
727+
Entity.Ontology, ['ontologies', 'nextCursor'])
728+
return res
729+
730+
731+

labelbox/schema/dataset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,12 @@ def data_row_for_external_id(self, external_id):
360360
return data_rows[0]
361361

362362
def export_data_rows(self, timeout_seconds=120):
363-
""" Returns a generator that produces all data rows that are currently
363+
""" Returns a generator that produces all data rows that are currently
364364
attached to this dataset.
365-
366-
Note: For efficiency, the data are cached for 30 minutes. Newly created data rows will not appear
365+
366+
Note: For efficiency, the data are cached for 30 minutes. Newly created data rows will not appear
367367
until the end of the cache period.
368-
368+
369369
Args:
370370
timeout_seconds (float): Max waiting time, in seconds.
371371
Returns:

labelbox/schema/ontology.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ def add_classification(self, classification: Classification):
233233
self.classifications.append(classification)
234234

235235

236+
class FeatureSchema(DbObject):
237+
...
238+
239+
240+
236241
class Ontology(DbObject):
237242
"""An ontology specifies which tools and classifications are available
238243
to a project. This is read only for now.

0 commit comments

Comments
 (0)