@@ -35,7 +35,7 @@ class ListWorkflows(GraphQLRequest):
35
35
"""
36
36
37
37
def __init__ (
38
- self , * , dataset_ids : List [int ] = None , workflow_ids : List [int ] = None
38
+ self , * , dataset_ids : List [int ] = None , workflow_ids : List [int ] = None
39
39
):
40
40
super ().__init__ (
41
41
self .query ,
@@ -114,10 +114,10 @@ class UpdateWorkflowSettings(RequestChain):
114
114
"""
115
115
116
116
def __init__ (
117
- self ,
118
- workflow : Union [Workflow , int ],
119
- enable_review : bool = None ,
120
- enable_auto_review : bool = None ,
117
+ self ,
118
+ workflow : Union [Workflow , int ],
119
+ enable_review : bool = None ,
120
+ enable_auto_review : bool = None ,
121
121
):
122
122
self .workflow_id = workflow .id if isinstance (workflow , Workflow ) else workflow
123
123
if enable_review is None and enable_auto_review is None :
@@ -134,7 +134,6 @@ def requests(self):
134
134
135
135
136
136
class _WorkflowSubmission (GraphQLRequest ):
137
-
138
137
query = """
139
138
mutation workflowSubmissionMutation({signature}) {{
140
139
{mutation_name}({args}) {{
@@ -180,9 +179,9 @@ class _WorkflowSubmission(GraphQLRequest):
180
179
}
181
180
182
181
def __init__ (
183
- self ,
184
- detailed_response : bool ,
185
- ** kwargs ,
182
+ self ,
183
+ detailed_response : bool ,
184
+ ** kwargs ,
186
185
):
187
186
self .workflow_id = kwargs ["workflow_id" ]
188
187
self .record_submission = kwargs ["record_submission" ]
@@ -263,28 +262,33 @@ class WorkflowSubmission(RequestChain):
263
262
detailed_response = False
264
263
265
264
def __init__ (
266
- self ,
267
- workflow_id : int ,
268
- files : List [str ] = None ,
269
- urls : List [str ] = None ,
270
- submission : bool = True ,
271
- bundle : bool = False ,
272
- result_version : str = None ,
273
- streams : Dict [str , io .BufferedIOBase ] = None
265
+ self ,
266
+ workflow_id : int ,
267
+ files : List [str ] = None ,
268
+ urls : List [str ] = None ,
269
+ submission : bool = True ,
270
+ bundle : bool = False ,
271
+ result_version : str = None ,
272
+ streams : Dict [str , io .BufferedIOBase ] = None
274
273
):
275
274
self .workflow_id = workflow_id
276
275
self .files = files
277
276
self .urls = urls
278
277
self .submission = submission
279
278
self .bundle = bundle
280
279
self .result_version = result_version
281
- self .streams = streams .copy ()
282
-
283
- if not self .files and not self .urls and not len (streams ) > 0 :
280
+ self .has_streams = False
281
+ if streams is not None :
282
+ self .streams = streams .copy ()
283
+ self .has_streams = True
284
+ else :
285
+ self .streams = None
286
+
287
+ if not self .files and not self .urls and not self .has_streams :
284
288
raise IndicoInputError ("One of 'files', 'streams', or 'urls' must be specified" )
285
- elif self .files and len ( self .streams ) > 0 :
289
+ elif self .files and self .has_streams :
286
290
raise IndicoInputError ("Only one of 'files' or 'streams' or 'urls' may be specified." )
287
- elif (self .files or len ( streams ) > 0 ) and self .urls :
291
+ elif (self .files or self . has_streams ) and self .urls :
288
292
raise IndicoInputError ("Only one of 'files' or 'streams' or 'urls' may be specified" )
289
293
290
294
def requests (self ):
@@ -307,7 +311,7 @@ def requests(self):
307
311
bundle = self .bundle ,
308
312
result_version = self .result_version ,
309
313
)
310
- elif len ( self .streams ) > 0 :
314
+ elif self .has_streams :
311
315
yield UploadDocument (streams = self .streams )
312
316
yield _WorkflowSubmission (
313
317
self .detailed_response ,
@@ -343,12 +347,12 @@ class WorkflowSubmissionDetailed(WorkflowSubmission):
343
347
detailed_response = True
344
348
345
349
def __init__ (
346
- self ,
347
- workflow_id : int ,
348
- files : List [str ] = None ,
349
- urls : List [str ] = None ,
350
- bundle : bool = False ,
351
- result_version : str = None ,
350
+ self ,
351
+ workflow_id : int ,
352
+ files : List [str ] = None ,
353
+ urls : List [str ] = None ,
354
+ bundle : bool = False ,
355
+ result_version : str = None ,
352
356
):
353
357
super ().__init__ (
354
358
workflow_id ,
0 commit comments