code: def _update_workflow_stages(stage_data: dict, workflow_stage: WorkflowStage,
                              docker: DockerSwarmClient):
      
      service_status_complete = []
  
      # FIXME(BMo) is not "complete" -> is "running"
      if stage_data["status"] != "complete":
          for service_id, service_dict in stage_data['services'].items():
              service_state = docker.get_service_state(service_id)
              if service_state == 'shutdown':
                  docker.delete_service(service_id)
              service_dict['status'] = service_state
              service_dict['complete'] = (service_state == 'shutdown')
              service_status_complete.append(service_dict['complete'])
              if all(service_status_complete):
                  LOG.info('Workflow stage service %s complete!',
                           workflow_stage.id)
                  stage_data['status'] = "complete"
docs: Check and update the status of a workflow stage.
  
      This function checks and updates the status of a workflow stage
      specified by the parameters in the specified stage_data dictionary.
  
      If the workflow stage is not marked as complete, this function will
      check with the Docker Swarm API on the status of Docker services
      defined for the stage. If **all** services are found to be complete
      (based on their service state being reported as 'shutdown',
      the workflow stage is marked complete.
  
      This function is used by `execute_processing_block`.
  
      TODO(BMo) This function will need refactoring at some point as part
          of an update to the way workflow state metadata is stored in the
          configuration database. Currently the stage_data dictionary
          is a bit of a hack for a badly specified Configuration Database
          backed WorkflowStage object.
  
      Args:
          stage_data (dict): Dictionary holding workflow stage metadata.
          workflow_stage (WorkflowStage): Workflow stage data object.
          docker (DockerClient): Docker Swarm Client object.