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