@@ -36,6 +36,7 @@ class Client:
36
36
authentication key). Provides functions for querying and creating
37
37
top-level data objects (Projects, Datasets).
38
38
"""
39
+
39
40
def __init__ (self ,
40
41
api_key = None ,
41
42
endpoint = 'https://api.labelbox.com/graphql' ,
@@ -132,8 +133,7 @@ def convert_value(value):
132
133
if query is not None :
133
134
if params is not None :
134
135
params = {
135
- key : convert_value (value )
136
- for key , value in params .items ()
136
+ key : convert_value (value ) 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,9 +527,7 @@ 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 ,
531
- iam_integration = IAMIntegration ._DEFAULT ,
532
- ** kwargs ):
530
+ def create_dataset (self , iam_integration = IAMIntegration ._DEFAULT , ** kwargs ):
533
531
""" Creates a Dataset object on the server.
534
532
535
533
Attribute values are passed as keyword arguments.
@@ -549,7 +547,8 @@ def create_dataset(self,
549
547
"""
550
548
dataset = self ._create (Entity .Dataset , kwargs )
551
549
552
- if iam_integration == IAMIntegration ._DEFAULT : iam_integration = self .get_organization ().get_default_iam_integration ()
550
+ if iam_integration == IAMIntegration ._DEFAULT :iam_integration = self .get_organization (
551
+ ).get_default_iam_integration ()
553
552
554
553
if iam_integration is None :
555
554
return dataset
@@ -703,7 +702,7 @@ def get_data_row_ids_for_external_ids(
703
702
for row in self .execute (
704
703
query_str ,
705
704
{'externalId_in' : external_ids [i :i + max_ids_per_request ]
706
- })['externalIdsToDataRowIds' ]:
705
+ })['externalIdsToDataRowIds' ]:
707
706
result [row ['externalId' ]].append (row ['dataRowId' ])
708
707
return result
709
708
0 commit comments