1
- from typing import List , Union
1
+ import io
2
+ from typing import List , Union , Dict
2
3
3
4
from indico .client .request import GraphQLRequest , RequestChain , Debouncer
4
5
from indico .errors import IndicoError , IndicoInputError
@@ -249,6 +250,9 @@ class WorkflowSubmission(RequestChain):
249
250
The format of the submission result file. One of:
250
251
{ SUBMISSION_RESULT_VERSIONS }
251
252
If bundle is enabled, this must be version TWO or later.
253
+ streams (Dict[str, io.BufferedIOBase]): List of filename keys mapped to streams
254
+ for upload. Similar to files but mutually exclusive with files.
255
+ Can take for example: io.BufferedReader, io.BinaryIO, or io.BytesIO.
252
256
253
257
Returns:
254
258
List[int]: If `submission`, these will be submission ids.
@@ -266,18 +270,22 @@ def __init__(
266
270
submission : bool = True ,
267
271
bundle : bool = False ,
268
272
result_version : str = None ,
273
+ streams : Dict [str , io .BufferedIOBase ] = None
269
274
):
270
275
self .workflow_id = workflow_id
271
276
self .files = files
272
277
self .urls = urls
273
278
self .submission = submission
274
279
self .bundle = bundle
275
280
self .result_version = result_version
281
+ self .streams = streams .copy ()
276
282
277
- if not self .files and not self .urls :
278
- raise IndicoInputError ("One of 'files' or 'urls' must be specified" )
279
- elif self .files and self .urls :
280
- raise IndicoInputError ("Only one of 'files' or 'urls' must be specified" )
283
+ if not self .files and not self .urls and not len (streams ) > 0 :
284
+ raise IndicoInputError ("One of 'files', 'streams', or 'urls' must be specified" )
285
+ elif self .files and len (self .streams ) > 0 :
286
+ raise IndicoInputError ("Only one of 'files' or 'streams' or 'urls' may be specified." )
287
+ elif (self .files or len (streams ) > 0 ) and self .urls :
288
+ raise IndicoInputError ("Only one of 'files' or 'streams' or 'urls' may be specified" )
281
289
282
290
def requests (self ):
283
291
if self .files :
@@ -299,6 +307,16 @@ def requests(self):
299
307
bundle = self .bundle ,
300
308
result_version = self .result_version ,
301
309
)
310
+ elif len (self .streams ) > 0 :
311
+ yield UploadDocument (streams = self .streams )
312
+ yield _WorkflowSubmission (
313
+ self .detailed_response ,
314
+ workflow_id = self .workflow_id ,
315
+ record_submission = self .submission ,
316
+ files = self .previous ,
317
+ bundle = self .bundle ,
318
+ result_version = self .result_version ,
319
+ )
302
320
303
321
304
322
class WorkflowSubmissionDetailed (WorkflowSubmission ):
0 commit comments