class_docstr: The server maintains the port and hands off the requests to workers
  
  example of use:
  
  context = zmq.Context()
  with KnimeBridgeServer(
      context,
      "tcp://127.0.0.1:4000", # server address
      "inproc://Notify        # kill notify address
      ) as server:
      notify_socket = context.socket(zmq.PUB)
      notify_socket.bind("inproc://Notify")
      ....
      notify_socket.send("Stop")
class_docstr_tok: ["The","server","maintains","the","port","and","hands","off","the","requests","to","workers","example","of","use",":","context","=","zmq.Context","(",")","with","KnimeBridgeServer","(","context",",","``","tcp",":","\/\/127.0.0.1:4000","''",",","#","server","address","``","inproc",":","\/\/Notify","#","kill","notify","address",")","as","server",":","notify_socket","=","context.socket","(","zmq.PUB",")","notify_socket.bind","(","``","inproc",":","\/\/Notify","''",")","....","notify_socket.send","(","``","Stop","''",")"]
docstr: Prepare a pipeline and measurements to run
  
  message - the run-request or run-groups-request message
  session_id - the session ID for the session
  grouping_allowed - true to allow grouped images
docstr_tok: ["Prepare","a","pipeline","and","measurements","to","run","message","-","the","run-request","or","run-groups-request","message","session_id","-","the","session","ID","for","the","session","grouping_allowed","-","true","to","allow","grouped","images"]
code: def prepare_run(self, message, session_id, grouping_allowed=False):
      """Prepare a pipeline and measurements to run
  
      message - the run-request or run-groups-request message
      session_id - the session ID for the session
      grouping_allowed - true to allow grouped images
      """
      pipeline = cellprofiler_core.pipeline.Pipeline()
      m = Measurements()
      object_set = cellprofiler_core.object.ObjectSet()
      if len(message) < 2:
          self.raise_cellprofiler_exception(
              session_id, "Missing run request sections"
          )
          return
      pipeline_txt = message.pop(0).bytes
      image_metadata = message.pop(0).bytes
      try:
          image_metadata = json.loads(image_metadata)
          for channel_name, channel_metadata in image_metadata:
              if len(message) < 1:
                  self.raise_cellprofiler_exception(
                      session_id,
                      "Missing binary data for channel %s"
                      % channel_name,
                  )
                  return None, None, None
              pixel_data = self.decode_image(
                  channel_metadata,
                  message.pop(0).bytes,
                  grouping_allowed=grouping_allowed,
              )
              m.add(
                  channel_name,
                  cellprofiler_core.image.Image(pixel_data),
              )
      except Exception as e:
          LOGGER.warning("Failed to decode message")
          self.raise_cellprofiler_exception(session_id, e)
          return None, None, None
      try:
          pipeline.loadtxt(StringIO(pipeline_txt))
      except Exception as e:
          LOGGER.warning(
              "Failed to load pipeline: sending pipeline exception"
          )
          self.raise_pipeline_exception(session_id, str(e))
          return None, None, None
  
      return pipeline, m, object_set
  
imports: import json
  import logging
  import threading
  import uuid
  from io import StringIO
  import numpy
  import zmq
  from cellprofiler_core.constants.measurement import GROUP_NUMBER, GROUP_INDEX, OBJECT_NUMBER, EXPERIMENT, MCA_AVAILABLE_POST_RUN, COLTYPE_FLOAT, COLTYPE_INTEGER, COLTYPE_VARCHAR, IMAGE_NUMBER
  from cellprofiler_core.constants.workspace import DISPOSITION_SKIP, DISPOSITION_CANCEL
  from cellprofiler_core.image import Image
  from cellprofiler_core.measurement import Measurements
  from cellprofiler_core.module import Module
  from cellprofiler_core.setting.text import ImageName
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.workspace
label_desc: Use image node_id 11 for calling the KnimeBridgeServer obj's underlying member method code with example usage: obj.prepare_run(message, session_id, grouping_allowed) and returns: pipeline,  m,  object_set, None,  None,  None, None,  None,  None, None,  None,  None