class_docstr: The workspace contains the processing information and state for
  a pipeline run on an image set
class_docstr_tok: ["The","workspace","contains","the","processing","information","and","state","for","a","pipeline","run","on","an","image","set"]
docstr: Load a workspace from a .cpi file
  
  filename - path to file to load
  
  load_pipeline - true to load the pipeline from the file, false to
                  use the current pipeline.
code: def load(self, filename, load_pipeline):
      """Load a workspace from a .cpi file
  
      filename - path to file to load
  
      load_pipeline - true to load the pipeline from the file, false to
                      use the current pipeline.
      """
      import shutil
      from ..constants.pipeline import M_DEFAULT_OUTPUT_FOLDER
      from ..constants.pipeline import M_DEFAULT_INPUT_FOLDER
      from ..constants.pipeline import M_PIPELINE
      import cellprofiler_core.measurement
      from cellprofiler_core.preferences import (
          set_default_image_directory,
          set_default_output_directory,
      )
  
      image_set_and_measurements_are_same = False
      if self.__measurements is not None:
          image_set_and_measurements_are_same = id(
              self.__measurements
          ) == id(self.__image_set)
          self.close()
      self.__loading = True
      try:
          #
          # Copy the file to a temporary location before opening
          #
          (
              fd,
              self.__filename,
          ) = (
              cellprofiler_core.utilities.measurement.make_temporary_file()
          )
          os.close(fd)
  
          shutil.copyfile(filename, self.__filename)
  
          self.__measurements = (
              cellprofiler_core.measurement.Measurements(
                  filename=self.__filename, mode="r+"
              )
          )
          if self.__file_list is not None:
              self.__file_list.remove_notification_callback(
                  self.__on_file_list_changed
              )
          self.__file_list = HDF5FileList(
              self.measurements.hdf5_dict.hdf5_file
          )
          self.__file_list.add_notification_callback(
              self.__on_file_list_changed
          )
          if load_pipeline and self.__measurements.has_feature(
              EXPERIMENT, M_PIPELINE
          ):
              pipeline_txt = (
                  self.__measurements.get_experiment_measurement(
                      M_PIPELINE
                  )
              )
              # CP 3.1.8 cpproj (and possibly before) saved info in bytes; converting to python 3 string
              if type(pipeline_txt) == bytes:
                  pipeline_txt = (
                      pipeline_txt.decode("unicode_escape")
                      .encode("utf-8")
                      .replace(b"\\x00", b"")
                      .decode("unicode_escape")
                      .replace("ÿþ", "")
                  )
              if "\\n" in pipeline_txt:
                  # Loaded pipeline text from a pre-h5py 3 hdf5 will have escaped characters in need of decoding.
                  try:
                      pipeline_txt = pipeline_txt.encode(
                          "latin-1", "backslashreplace"
                      ).decode("unicode-escape")
                  except Exception as e:
                      print(
                          f"Unable to fully decode pipeline, you may encounter some errors. Issue was: {e}"
                      )
              self.pipeline.load(io.StringIO(pipeline_txt))
          elif load_pipeline:
              self.pipeline.clear()
          else:
              fd = io.StringIO()
              self.pipeline.dump(fd, save_image_plane_details=False)
              self.__measurements.add_experiment_measurement(
                  M_PIPELINE, fd.getvalue()
              )
  
          for feature, function in (
              (M_DEFAULT_INPUT_FOLDER, set_default_image_directory),
              (M_DEFAULT_OUTPUT_FOLDER, set_default_output_directory),
          ):
              if self.measurements.has_feature(EXPERIMENT, feature):
                  path = self.measurements[EXPERIMENT, feature]
                  if os.path.isdir(path):
                      function(path)
          if image_set_and_measurements_are_same:
              self.__image_set = self.__measurements
  
      finally:
          self.__loading = False
      self.notify(self.WorkspaceLoadedEvent(self))
  
imports: import io
  import logging
  import os
  import h5py
  import cellprofiler_core.utilities.measurement
  from ._disposition_changed_event import DispositionChangedEvent
  from ..constants.measurement import EXPERIMENT
  from ..constants.workspace import DISPOSITION_CONTINUE
  from ..utilities.hdf5_dict import HDF5FileList
label_desc: Use image node_id 35 for calling the Workspace obj's underlying member method code with example usage: obj.load(filename, load_pipeline) without return types