32
32
class Client :
33
33
""" A Labelbox client.
34
34
35
- Contains info necessary for connecting to a Labelbox server (URL, authentication key). Provides functions for querying and creating
35
+ Contains info necessary for connecting to a Labelbox server (URL,
36
+ authentication key). Provides functions for querying and creating
36
37
top-level data objects (Projects, Datasets).
37
38
"""
38
-
39
39
def __init__ (self ,
40
40
api_key = None ,
41
41
endpoint = 'https://api.labelbox.com/graphql' ,
@@ -132,7 +132,8 @@ def convert_value(value):
132
132
if query is not None :
133
133
if params is not None :
134
134
params = {
135
- key : convert_value (value ) for key , value in params .items ()
135
+ key : convert_value (value )
136
+ for key , value in params .items ()
136
137
}
137
138
data = json .dumps ({
138
139
'query' : query ,
@@ -334,18 +335,18 @@ def upload_data(self,
334
335
335
336
request_data = {
336
337
"operations" :
337
- json .dumps ({
338
- "variables" : {
339
- "file" : None ,
340
- "contentLength" : len (content ),
341
- "sign" : sign
342
- },
343
- "query" :
344
- """mutation UploadFile($file: Upload!, $contentLength: Int!,
338
+ json .dumps ({
339
+ "variables" : {
340
+ "file" : None ,
341
+ "contentLength" : len (content ),
342
+ "sign" : sign
343
+ },
344
+ "query" :
345
+ """mutation UploadFile($file: Upload!, $contentLength: Int!,
345
346
$sign: Boolean) {
346
347
uploadFile(file: $file, contentLength: $contentLength,
347
348
sign: $sign) {url filename} } """ ,
348
- }),
349
+ }),
349
350
"map" : (None , json .dumps ({"1" : ["variables.file" ]})),
350
351
}
351
352
response = requests .post (
@@ -354,7 +355,7 @@ def upload_data(self,
354
355
data = request_data ,
355
356
files = {
356
357
"1" : (filename , content , content_type ) if
357
- (filename and content_type ) else content
358
+ (filename and content_type ) else content
358
359
})
359
360
360
361
if response .status_code == 502 :
@@ -527,7 +528,9 @@ def _create(self, db_object_type, data):
527
528
res = res ["create%s" % db_object_type .type_name ()]
528
529
return db_object_type (self , res )
529
530
530
- def create_dataset (self , iam_integration = IAMIntegration ._DEFAULT , ** kwargs ):
531
+ def create_dataset (self ,
532
+ iam_integration = IAMIntegration ._DEFAULT ,
533
+ ** kwargs ):
531
534
""" Creates a Dataset object on the server.
532
535
533
536
Attribute values are passed as keyword arguments.
@@ -703,7 +706,7 @@ def get_data_row_ids_for_external_ids(
703
706
for row in self .execute (
704
707
query_str ,
705
708
{'externalId_in' : external_ids [i :i + max_ids_per_request ]
706
- })['externalIdsToDataRowIds' ]:
709
+ })['externalIdsToDataRowIds' ]:
707
710
result [row ['externalId' ]].append (row ['dataRowId' ])
708
711
return result
709
712
0 commit comments