Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions labelbox/schema/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,10 @@ class ModelSlice(Slice):
@classmethod
def query_str(cls):
query_str = """
query getDataRowIdenfifiersBySavedModelQueryPyApi($id: ID!, $from: DataRowIdentifierCursorInput, $first: Int!) {
query getDataRowIdenfifiersBySavedModelQueryPyApi($id: ID!, $modelRunId: ID, $from: DataRowIdentifierCursorInput, $first: Int!) {
getDataRowIdentifiersBySavedModelQuery(input: {
savedQueryId: $id,
modelRunId: $modelRunId,
after: $from
first: $first
}) {
Expand All @@ -263,17 +264,23 @@ def query_str(cls):
"""
return query_str

def get_data_row_ids(self) -> PaginatedCollection:
def get_data_row_ids(self, model_run_id: str) -> PaginatedCollection:
"""
Fetches all data row ids that match this Slice

Params
model_run_id: str, required, uid or cuid of model run

Returns:
A PaginatedCollection of data row ids
"""
return PaginatedCollection(
client=self.client,
query=ModelSlice.query_str(),
params={'id': str(self.uid)},
params={
'id': str(self.uid),
'modelRunId': model_run_id
},
dereferencing=['getDataRowIdentifiersBySavedModelQuery', 'nodes'],
obj_class=lambda _, data_row_id_and_gk: data_row_id_and_gk.get('id'
),
Expand All @@ -282,17 +289,24 @@ def get_data_row_ids(self) -> PaginatedCollection:
'endCursor'
])

def get_data_row_identifiers(self) -> PaginatedCollection:
def get_data_row_identifiers(self,
model_run_id: str) -> PaginatedCollection:
"""
Fetches all data row ids and global keys (where defined) that match this Slice

Params:
model_run_id : str, required, uid or cuid of model run

Returns:
A PaginatedCollection of Slice.DataRowIdAndGlobalKey
"""
return PaginatedCollection(
client=self.client,
query=ModelSlice.query_str(),
params={'id': str(self.uid)},
params={
'id': str(self.uid),
'modelRunId': model_run_id
},
dereferencing=['getDataRowIdentifiersBySavedModelQuery', 'nodes'],
obj_class=lambda _, data_row_id_and_gk: Slice.DataRowIdAndGlobalKey(
data_row_id_and_gk.get('id'),
Expand Down