@@ -141,6 +141,7 @@ async def submit_job(
141141 config : Optional [JobConfig ] = None ,
142142 transcription_config : Optional [TranscriptionConfig ] = None ,
143143 parallel_engines : Optional [int ] = None ,
144+ user_id : Optional [str ] = None ,
144145 ) -> JobDetails :
145146 """
146147 Submit a new transcription job.
@@ -159,6 +160,9 @@ async def submit_job(
159160 parallel_engines: Optional number of parallel engines to request for this job.
160161 Sent as ``{"parallel_engines": N}`` in the ``X-SM-Processing-Data`` header.
161162 This only applies when using the container onPrem on http batch mode.
163+ user_id: Optional user identifier to associate with this job.
164+ Sent as ``{"user_id": "..."}`` in the ``X-SM-Processing-Data`` header.
165+ This only applies when using the container onPrem on http batch mode.
162166
163167 Returns:
164168 JobDetails object containing the job ID and initial status.
@@ -205,7 +209,9 @@ async def submit_job(
205209 assert audio_file is not None # for type checker; validated above
206210 multipart_data , filename = await self ._prepare_file_submission (audio_file , config_dict )
207211
208- return await self ._submit_and_create_job_details (multipart_data , filename , config , parallel_engines )
212+ return await self ._submit_and_create_job_details (
213+ multipart_data , filename , config , parallel_engines , user_id
214+ )
209215 except Exception as e :
210216 if isinstance (e , (AuthenticationError , BatchError )):
211217 raise
@@ -441,6 +447,7 @@ async def transcribe(
441447 polling_interval : float = 5.0 ,
442448 timeout : Optional [float ] = None ,
443449 parallel_engines : Optional [int ] = None ,
450+ user_id : Optional [str ] = None ,
444451 ) -> Union [Transcript , str ]:
445452 """
446453 Complete transcription workflow: submit job and wait for completion.
@@ -457,6 +464,9 @@ async def transcribe(
457464 parallel_engines: Optional number of parallel engines to request for this job.
458465 Sent as ``{"parallel_engines": N}`` in the ``X-SM-Processing-Data`` header.
459466 This only applies when using the container onPrem on http batch mode.
467+ user_id: Optional user identifier to associate with this job.
468+ Sent as ``{"user_id": "..."}`` in the ``X-SM-Processing-Data`` header.
469+ This only applies when using the container onPrem on http batch mode.
460470
461471 Returns:
462472 Transcript object containing the transcript and metadata.
@@ -485,6 +495,7 @@ async def transcribe(
485495 config = config ,
486496 transcription_config = transcription_config ,
487497 parallel_engines = parallel_engines ,
498+ user_id = user_id ,
488499 )
489500
490501 # Wait for completion and return result
@@ -538,12 +549,22 @@ async def _prepare_file_submission(self, audio_file: Union[str, BinaryIO], confi
538549 return multipart_data , filename
539550
540551 async def _submit_and_create_job_details (
541- self , multipart_data : dict , filename : str , config : JobConfig , parallel_engines : Optional [int ] = None
552+ self ,
553+ multipart_data : dict ,
554+ filename : str ,
555+ config : JobConfig ,
556+ parallel_engines : Optional [int ] = None ,
557+ user_id : Optional [str ] = None ,
542558 ) -> JobDetails :
543559 """Submit job and create JobDetails response."""
544560 extra_headers : Optional [dict [str , Any ]] = None
561+ processing_data : dict [str , Any ] = {}
545562 if parallel_engines is not None :
546- extra_headers = {PROCESSING_DATA_HEADER : {"parallel_engines" : parallel_engines }}
563+ processing_data ["parallel_engines" ] = parallel_engines
564+ if user_id is not None :
565+ processing_data ["user_id" ] = user_id
566+ if processing_data :
567+ extra_headers = {PROCESSING_DATA_HEADER : processing_data }
547568 response = await self ._transport .post ("/jobs" , multipart_data = multipart_data , extra_headers = extra_headers )
548569 job_id = response .get ("id" )
549570 if not job_id :
0 commit comments