Complete the code to start an asynchronous batch job.
response = client.post('/batch/start', json=[1])
The batch start endpoint expects a JSON object with a 'tasks' key containing the list of tasks.
Complete the code to check the batch job status asynchronously.
status = client.get(f'/batch/status/[1]').json()
The batch status endpoint requires the batch ID to check the job status.
Fix the error in the code to correctly retrieve batch results asynchronously.
results = client.get(f'/batch/results/[1]').json()['[2]']
The batch results endpoint requires the batch ID to fetch results. The JSON key holding results is 'results'.
Fill both blanks to create a dictionary comprehension that filters completed tasks with results.
completed_tasks = {task['id']: task['result'] for task in tasks if task['status'] [1] 'completed' and task['result'] [2] None}The comprehension filters tasks where status equals 'completed' and result is not None.
Fill all three blanks to build a dictionary of task IDs and their results for tasks with errors.
error_tasks = {task['id']: task['error_message'] for task in tasks if task['status'] [2] 'error' and task.get('{{BLANK_3}}') is not None}The dictionary comprehension collects task IDs and their error messages for tasks with status 'error' and a non-empty error message.