Skip to content

Commit e9f25f1

Browse files
Improve query param naming.
1 parent f648522 commit e9f25f1

File tree

3 files changed

+31
-29
lines changed

3 files changed

+31
-29
lines changed

labelbox/schema/data_row.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ def create_metadata(self, meta_type, meta_value):
4242
Return:
4343
AssetMetadata DB object.
4444
"""
45-
meta_type_param = "meta_type"
46-
meta_value_param = "meta_value"
47-
data_row_id_param = "data_row_id"
45+
meta_type_param = "metaType"
46+
meta_value_param = "metaValue"
47+
data_row_id_param = "dataRowId"
4848
query_str = """mutation CreateAssetMetadataPyApi(
4949
$%s: MetadataType!, $%s: String!, $%s: ID!) {
5050
createAssetMetadata(data: {

labelbox/schema/dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ def convert_item(item):
119119
descriptor_url = self.client.upload_data(data)
120120

121121
# Create data source
122-
dataset_param = "dataSetId"
123-
url_param = "jsonURL"
122+
dataset_param = "datasetId"
123+
url_param = "jsonUrl"
124124
query_str = """mutation AppendRowsToDatasetPyApi($%s: ID!, $%s: String!){
125125
appendRowsToDataset(data:{datasetId: $%s, jsonFileUrl: $%s}
126126
){ taskId accepted } } """ % (

labelbox/schema/project.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ def labels(self, datasets=None, order_by=None):
8484
else:
8585
order_by_str = ""
8686

87-
query_str = """query GetProjectLabelsPyApi($project_id: ID!)
88-
{project (where: {id: $project_id})
87+
id_param = "projectId"
88+
query_str = """query GetProjectLabelsPyApi($%s: ID!)
89+
{project (where: {id: $%s})
8990
{labels (skip: %%d first: %%d%s%s) {%s}}}""" % (
90-
where, order_by_str, query.results_query_part(Label))
91+
id_param, id_param, where, order_by_str,
92+
query.results_query_part(Label))
9193

9294
return PaginatedCollection(
93-
self.client, query_str, {"project_id": self.uid},
95+
self.client, query_str, {id_param: self.uid},
9496
["project", "labels"], Label)
9597

9698
def export_labels(self, timeout_seconds=60):
@@ -128,13 +130,13 @@ def labeler_performance(self):
128130
Returns:
129131
A PaginatedCollection of LabelerPerformance objects.
130132
"""
131-
project_id_param = "projectId"
133+
id_param = "projectId"
132134
query_str = """query LabelerPerformancePyApi($%s: ID!) {
133135
project(where: {id: $%s}) {
134136
labelerPerformance(skip: %%d first: %%d) {
135137
count user {%s} secondsPerLabel totalTimeLabeling consensus
136138
averageBenchmarkAgreement lastActivityTime}
137-
}}""" % (project_id_param, project_id_param,
139+
}}""" % (id_param, id_param,
138140
query.results_query_part(Entity.User))
139141

140142
def create_labeler_performance(client, result):
@@ -145,7 +147,7 @@ def create_labeler_performance(client, result):
145147
for key, value in result.items()})
146148

147149
return PaginatedCollection(
148-
self.client, query_str, {project_id_param: self.uid},
150+
self.client, query_str, {id_param: self.uid},
149151
["project", "labelerPerformance"], create_labeler_performance)
150152

151153
def review_metrics(self, net_score):
@@ -158,13 +160,13 @@ def review_metrics(self, net_score):
158160
if net_score not in (None,) + tuple(Entity.Review.NetScore):
159161
raise InvalidQueryError("Review metrics net score must be either None "
160162
"or one of Review.NetScore values")
161-
project_id_param = "project_id"
163+
id_param = "projectId"
162164
net_score_literal = "None" if net_score is None else net_score.name
163165
query_str = """query ProjectReviewMetricsPyApi($%s: ID!){
164166
project(where: {id:$%s})
165167
{reviewMetrics {labelAggregate(netScore: %s) {count}}}
166-
}""" % (project_id_param, project_id_param, net_score_literal)
167-
res = self.client.execute(query_str, {project_id_param: self.uid})
168+
}""" % (id_param, id_param, net_score_literal)
169+
res = self.client.execute(query_str, {id_param: self.uid})
168170
return res["data"]["project"]["reviewMetrics"]["labelAggregate"]["count"]
169171

170172
def setup(self, labeling_frontend, labeling_frontend_options):
@@ -202,11 +204,11 @@ def set_labeling_parameter_overrides(self, data):
202204
"{dataRow: {id: \"%s\"}, priority: %d, numLabels: %d }" % (
203205
data_row.uid, priority, num_labels)
204206
for data_row, priority, num_labels in data)
205-
project_param = "projectId"
206-
query_str = """mutation setLabelingParameterOverridesPyApi($%s: ID!){
207+
id_param = "projectId"
208+
query_str = """mutation SetLabelingParameterOverridesPyApi($%s: ID!){
207209
project(where: { id: $%s }) {setLabelingParameterOverrides
208-
(data: [%s]) {success}}} """ % (project_param, project_param, data_str)
209-
res = self.client.execute(query_str, {project_param: self.uid})
210+
(data: [%s]) {success}}} """ % (id_param, id_param, data_str)
211+
res = self.client.execute(query_str, {id_param: self.uid})
210212
return res["data"]["project"]["setLabelingParameterOverrides"]["success"]
211213

212214
def unset_labeling_parameter_overrides(self, data_rows):
@@ -216,13 +218,13 @@ def unset_labeling_parameter_overrides(self, data_rows):
216218
Return:
217219
bool indicating if the operation was a success.
218220
"""
219-
project_param = "projectId"
220-
query_str = """mutation unsetLabelingParameterOverridesPyApi($%s: ID!){
221+
id_param = "projectId"
222+
query_str = """mutation UnsetLabelingParameterOverridesPyApi($%s: ID!){
221223
project(where: { id: $%s}) {
222224
unsetLabelingParameterOverrides(data: [%s]) { success }}}""" % (
223-
project_param, project_param,
225+
id_param, id_param,
224226
",\n".join("{dataRowId: \"%s\"}" % row.uid for row in data_rows))
225-
res = self.client.execute(query_str, {project_param: self.uid})
227+
res = self.client.execute(query_str, {id_param: self.uid})
226228
return res["data"]["project"]["unsetLabelingParameterOverrides"]["success"]
227229

228230
def upsert_review_queue(self, quota_factor):
@@ -231,14 +233,14 @@ def upsert_review_queue(self, quota_factor):
231233
quota_factor (float): Which part (percentage) of the queue
232234
to reinitiate. Between 0 and 1.
233235
"""
234-
project_param = "projectId"
236+
id_param = "projectId"
235237
quota_param = "quotaFactor"
236238
query_str = """mutation UpsertReviewQueuePyApi($%s: ID!, $%s: Float!){
237239
upsertReviewQueue(where:{project: {id: $%s}}
238240
data:{quotaFactor: $%s}) {id}}""" % (
239-
project_param, quota_param, project_param, quota_param)
241+
id_param, quota_param, id_param, quota_param)
240242
res = self.client.execute(
241-
query_str, {project_param: self.uid, quota_param: quota_factor})
243+
query_str, {id_param: self.uid, quota_param: quota_factor})
242244

243245

244246
def extend_reservations(self, queue_type):
@@ -252,11 +254,11 @@ def extend_reservations(self, queue_type):
252254
if queue_type not in ("LabelingQueue", "ReviewQueue"):
253255
raise InvalidQueryError("Unsupported queue type: %s" % queue_type)
254256

255-
project_param = "projectId"
257+
id_param = "projectId"
256258
query_str = """mutation ExtendReservationsPyApi($%s: ID!){
257259
extendReservations(projectId:$%s queueType:%s)}""" % (
258-
project_param, project_param, queue_type)
259-
res = self.client.execute(query_str, {project_param: self.uid})
260+
id_param, id_param, queue_type)
261+
res = self.client.execute(query_str, {id_param: self.uid})
260262
return res["data"]["extendReservations"]
261263

262264

0 commit comments

Comments
 (0)